diff options
28 files changed, 3665 insertions, 3744 deletions
diff --git a/html/001help.cc.html b/html/001help.cc.html index 52cd0df3..cb115add 100644 --- a/html/001help.cc.html +++ b/html/001help.cc.html @@ -220,7 +220,7 @@ if ('onhashchange' in window) { <span id="L159" class="LineNr">159 </span><span class="Comment">//: yadda-yadda. Instead use this macro below to perform an unsafe cast to</span> <span id="L160" class="LineNr">160 </span><span class="Comment">//: signed. We'll just give up immediately if a container's ever too large.</span> <span id="L161" class="LineNr">161 </span><span class="Comment">//: Basically, Mu is not concerned about this being a little slower than it</span> -<span id="L162" class="LineNr">162 </span><span class="Comment">//: could be. (<a href="https://gist.github.com/rygorous/e0f055bfb74e3d5f0af20690759de5a7)">https://gist.github.com/rygorous/e0f055bfb74e3d5f0af20690759de5a7)</a></span> +<span id="L162" class="LineNr">162 </span><span class="Comment">//: could be. (<a href="https://gist.github.com/rygorous/e0f055bfb74e3d5f0af20690759de5a7">https://gist.github.com/rygorous/e0f055bfb74e3d5f0af20690759de5a7</a>)</span> <span id="L163" class="LineNr">163 </span><span class="Comment">//:</span> <span id="L164" class="LineNr">164 </span><span class="Comment">//: Addendum to corollary: We're going to uniformly use int everywhere, to</span> <span id="L165" class="LineNr">165 </span><span class="Comment">//: indicate that we're oblivious to number size, and since Clang on 32-bit</span> @@ -232,7 +232,7 @@ if ('onhashchange' in window) { <span id="L171" class="LineNr">171 </span> <span id="L172" class="LineNr">172 </span><span class="Comment">//: 5. Integer overflow is guarded against at runtime using the -ftrapv flag</span> <span id="L173" class="LineNr">173 </span><span class="Comment">//: to the compiler, supported by Clang (GCC version only works sometimes:</span> -<span id="L174" class="LineNr">174 </span><span class="Comment">//: <a href="http://stackoverflow.com/questions/20851061/how-to-make-gcc-ftrapv-work).">http://stackoverflow.com/questions/20851061/how-to-make-gcc-ftrapv-work).</a></span> +<span id="L174" class="LineNr">174 </span><span class="Comment">//: <a href="http://stackoverflow.com/questions/20851061/how-to-make-gcc-ftrapv-work">http://stackoverflow.com/questions/20851061/how-to-make-gcc-ftrapv-work</a>).</span> <span id="L175" class="LineNr">175 </span><span class="Delimiter">:(before "atexit(<a href='000organization.cc.html#L150'>reset</a>)")</span> <span id="L176" class="LineNr">176 </span><a href='001help.cc.html#L181'>initialize_signal_handlers</a><span class="Delimiter">();</span> <span class="Comment">// not always necessary, but doesn't hurt</span> <span id="L177" class="LineNr">177 </span><span class="CommentedCode">//? cerr << INT_MAX+1 << '\n'; // test overflow</span> diff --git a/html/002test.cc.html b/html/002test.cc.html index 18215ec6..13e7959d 100644 --- a/html/002test.cc.html +++ b/html/002test.cc.html @@ -61,7 +61,7 @@ if ('onhashchange' in window) { <pre id='vimCodeElement'> <span id="L1" class="LineNr"> 1 </span><span class="Comment">//: A simple test harness. To create new tests, define functions starting with</span> <span id="L2" class="LineNr"> 2 </span><span class="Comment">//: 'test_'. To run all tests so defined, run:</span> -<span id="L3" class="LineNr"> 3 </span><span class="Comment">//: $ ./mu test</span> +<span id="L3" class="LineNr"> 3 </span><span class="Comment">//: $ ./bootstrap test</span> <span id="L4" class="LineNr"> 4 </span><span class="Comment">//:</span> <span id="L5" class="LineNr"> 5 </span><span class="Comment">//: Every layer should include tests, and can reach into previous layers.</span> <span id="L6" class="LineNr"> 6 </span><span class="Comment">//: However, it seems like a good idea never to reach into tests from previous</span> @@ -101,7 +101,7 @@ if ('onhashchange' in window) { <span id="L40" class="LineNr"> 40 </span><span class="Special"><a href='002test.cc.html#L21'>Passed</a></span> = <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L41" class="LineNr"> 41 </span> <span id="L42" class="LineNr"> 42 </span><span class="Delimiter">:(before "End Commandline Parsing")</span> -<span id="L43" class="LineNr"> 43 </span><span class="Normal">if</span> <span class="Delimiter">(</span>argc > <span class="Constant">1</span> && <a href='001help.cc.html#L101'>is_equal</a><span class="Delimiter">(</span>argv[<span class="Constant">1</span>]<span class="Delimiter">,</span> <span class="Constant">"test"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L43" class="LineNr"> 43 </span><span class="Normal">if</span> <span class="Delimiter">(</span>argc > <span class="Constant">1</span> && <a href='001help.cc.html#L102'>is_equal</a><span class="Delimiter">(</span>argv[<span class="Constant">1</span>]<span class="Delimiter">,</span> <span class="Constant">"test"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L44" class="LineNr"> 44 </span> <span class="Special"><a href='002test.cc.html#L20'>Run_tests</a></span> = <span class="Constant">true</span><span class="Delimiter">;</span> --argc<span class="Delimiter">;</span> ++argv<span class="Delimiter">;</span> <span class="Comment">// shift 'test' out of commandline args</span> <span id="L45" class="LineNr"> 45 </span><span class="Delimiter">}</span> <span id="L46" class="LineNr"> 46 </span> @@ -133,7 +133,7 @@ if ('onhashchange' in window) { <span id="L72" class="LineNr"> 72 </span> <span id="L73" class="LineNr"> 73 </span><span class="Delimiter">:(after "End Main")</span> <span id="L74" class="LineNr"> 74 </span><span class="Comment">//: Raise other unrecognized sub-commands as errors.</span> -<span id="L75" class="LineNr"> 75 </span><span class="Comment">//: We couldn't do this until now because we want `./subx test` to always</span> +<span id="L75" class="LineNr"> 75 </span><span class="Comment">//: We couldn't do this until now because we want `./bootstrap test` to always</span> <span id="L76" class="LineNr"> 76 </span><span class="Comment">//: succeed, no matter how many layers are included in the build.</span> <span id="L77" class="LineNr"> 77 </span>cerr << <span class="Constant">"nothing to do\n"</span><span class="Delimiter">;</span> <span id="L78" class="LineNr"> 78 </span><span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> @@ -158,18 +158,16 @@ if ('onhashchange' in window) { <span id="L97" class="LineNr"> 97 </span><span class="Delimiter">};</span> <span id="L98" class="LineNr"> 98 </span><span class="Delimiter">:(after "Test Runs")</span> <span id="L99" class="LineNr"> 99 </span>string <a href='002test.cc.html#L99'>maybe_single_test_to_run</a> = argv[argc-<span class="Constant">1</span>]<span class="Delimiter">;</span> -<span id="L100" class="LineNr">100 </span><span class="Normal">if</span> <span class="Delimiter">(</span>!starts_with<span class="Delimiter">(</span><a href='002test.cc.html#L99'>maybe_single_test_to_run</a><span class="Delimiter">,</span> <span class="Constant">"test_"</span><span class="Delimiter">))</span> -<span id="L101" class="LineNr">101 </span> <a href='002test.cc.html#L99'>maybe_single_test_to_run</a><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">"test_"</span><span class="Delimiter">);</span> -<span id="L102" class="LineNr">102 </span><span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i=<span class="Constant">0</span><span class="Delimiter">;</span> i < <span class="Normal">sizeof</span><span class="Delimiter">(</span><span class="Special"><a href='002test.cc.html#L15'>Tests</a></span><span class="Delimiter">)</span>/<span class="Normal">sizeof</span><span class="Delimiter">(</span><span class="Special"><a href='002test.cc.html#L15'>Tests</a></span>[<span class="Constant">0</span>]<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L103" class="LineNr">103 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='002test.cc.html#L95'>Test_names</a></span>[i] == <a href='002test.cc.html#L99'>maybe_single_test_to_run</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L104" class="LineNr">104 </span> <a href='002test.cc.html#L81'>run_test</a><span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L105" class="LineNr">105 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='002test.cc.html#L21'>Passed</a></span><span class="Delimiter">)</span> cerr << <span class="Constant">".\n"</span><span class="Delimiter">;</span> -<span id="L106" class="LineNr">106 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L107" class="LineNr">107 </span> <span class="Delimiter">}</span> -<span id="L108" class="LineNr">108 </span><span class="Delimiter">}</span> -<span id="L109" class="LineNr">109 </span> -<span id="L110" class="LineNr">110 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L111" class="LineNr">111 </span><span class="PreProc">#include </span><span class="Constant"><stdlib.h></span> +<span id="L100" class="LineNr">100 </span><span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i=<span class="Constant">0</span><span class="Delimiter">;</span> i < <span class="Normal">sizeof</span><span class="Delimiter">(</span><span class="Special"><a href='002test.cc.html#L15'>Tests</a></span><span class="Delimiter">)</span>/<span class="Normal">sizeof</span><span class="Delimiter">(</span><span class="Special"><a href='002test.cc.html#L15'>Tests</a></span>[<span class="Constant">0</span>]<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L101" class="LineNr">101 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='002test.cc.html#L95'>Test_names</a></span>[i] == <a href='002test.cc.html#L99'>maybe_single_test_to_run</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L102" class="LineNr">102 </span> <a href='002test.cc.html#L81'>run_test</a><span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L103" class="LineNr">103 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='002test.cc.html#L21'>Passed</a></span><span class="Delimiter">)</span> cerr << <span class="Constant">".\n"</span><span class="Delimiter">;</span> +<span id="L104" class="LineNr">104 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L105" class="LineNr">105 </span> <span class="Delimiter">}</span> +<span id="L106" class="LineNr">106 </span><span class="Delimiter">}</span> +<span id="L107" class="LineNr">107 </span> +<span id="L108" class="LineNr">108 </span><span class="Delimiter">:(before "End Includes")</span> +<span id="L109" class="LineNr">109 </span><span class="PreProc">#include </span><span class="Constant"><stdlib.h></span> </pre> </body> </html> diff --git a/html/003trace.cc.html b/html/003trace.cc.html index 2b5fba00..1aa53854 100644 --- a/html/003trace.cc.html +++ b/html/003trace.cc.html @@ -192,7 +192,7 @@ if ('onhashchange' in window) { <span id="L131" class="LineNr">131 </span> <span id="L132" class="LineNr">132 </span>string <a href='003trace.cc.html#L132'>unescape_newline</a><span class="Delimiter">(</span>string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L133" class="LineNr">133 </span> std::stringstream ss<span class="Delimiter">;</span> -<span id="L134" class="LineNr">134 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L134" class="LineNr">134 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L135" class="LineNr">135 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> <span id="L136" class="LineNr">136 </span> ss << <span class="Constant">"\\n"</span><span class="Delimiter">;</span> <span id="L137" class="LineNr">137 </span> <span class="Normal">else</span> @@ -202,7 +202,7 @@ if ('onhashchange' in window) { <span id="L141" class="LineNr">141 </span><span class="Delimiter">}</span> <span id="L142" class="LineNr">142 </span> <span id="L143" class="LineNr">143 </span><span class="Normal">void</span> <a href='003trace.cc.html#L143'>dump_trace_line</a><span class="Delimiter">(</span>ostream& s<span class="Delimiter">,</span> trace_line& t<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L144" class="LineNr">144 </span> s << std::setw<span class="Delimiter">(</span><span class="Constant">4</span><span class="Delimiter">)</span> << t<span class="Delimiter">.</span><a href='003trace.cc.html#L119'>depth</a> << <span class="Constant">' '</span> << t<span class="Delimiter">.</span>label << <span class="Constant">": "</span> << <a href='003trace.cc.html#L132'>unescape_newline</a><span class="Delimiter">(</span>t<span class="Delimiter">.</span><a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L144" class="LineNr">144 </span> s << std::setw<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">)</span> << t<span class="Delimiter">.</span><a href='003trace.cc.html#L119'>depth</a> << <span class="Constant">' '</span> << t<span class="Delimiter">.</span>label << <span class="Constant">": "</span> << <a href='003trace.cc.html#L132'>unescape_newline</a><span class="Delimiter">(</span>t<span class="Delimiter">.</span><a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span id="L145" class="LineNr">145 </span><span class="Delimiter">}</span> <span id="L146" class="LineNr">146 </span> <span id="L147" class="LineNr">147 </span><span class="Comment">//: Starting a new trace line.</span> @@ -245,14 +245,14 @@ if ('onhashchange' in window) { <span id="L184" class="LineNr">184 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!curr_stream<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L185" class="LineNr">185 </span> string curr_contents = curr_stream<span class="Delimiter">-></span>str<span class="Delimiter">();</span> <span id="L186" class="LineNr">186 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!curr_contents<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L187" class="LineNr">187 </span> <a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>trace_line<span class="Delimiter">(</span>curr_contents<span class="Delimiter">,</span> <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><a href='003trace.cc.html#L101'>curr_label</a><span class="Delimiter">),</span> <a href='003trace.cc.html#L102'>curr_depth</a><span class="Delimiter">));</span> <span class="Comment">// preserve indent in contents</span> +<span id="L187" class="LineNr">187 </span> <a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>trace_line<span class="Delimiter">(</span>curr_contents<span class="Delimiter">,</span> <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><a href='003trace.cc.html#L101'>curr_label</a><span class="Delimiter">),</span> <a href='003trace.cc.html#L102'>curr_depth</a><span class="Delimiter">));</span> <span class="Comment">// preserve indent in contents</span> <span id="L188" class="LineNr">188 </span> <span class="Comment">// maybe incrementally dump trace</span> <span id="L189" class="LineNr">189 </span> trace_line& t = <a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>back<span class="Delimiter">();</span> <span id="L190" class="LineNr">190 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L245'>should_incrementally_print_trace</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> <span id="L191" class="LineNr">191 </span> <a href='003trace.cc.html#L143'>dump_trace_line</a><span class="Delimiter">(</span>cerr<span class="Delimiter">,</span> t<span class="Delimiter">);</span> <span id="L192" class="LineNr">192 </span> <span class="Delimiter">}</span> -<span id="L193" class="LineNr">193 </span> <span class="Comment">// Hack: on 'subx --trace --dump', emit only to stderr, not 'last_run'.</span> -<span id="L194" class="LineNr">194 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L484'>Dump_trace</a></span><span class="Delimiter">)</span> <a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>pop_back<span class="Delimiter">();</span> <span class="Comment">// economize on memory</span> +<span id="L193" class="LineNr">193 </span> <span class="Comment">// Hack: on 'bootstrap --trace --dump', emit only to stderr, not 'last_run'.</span> +<span id="L194" class="LineNr">194 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L485'>Dump_trace</a></span><span class="Delimiter">)</span> <a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>pop_back<span class="Delimiter">();</span> <span class="Comment">// economize on memory</span> <span id="L195" class="LineNr">195 </span> <span class="Comment">// End trace Commit</span> <span id="L196" class="LineNr">196 </span> <span class="Delimiter">}</span> <span id="L197" class="LineNr">197 </span> @@ -381,24 +381,24 @@ if ('onhashchange' in window) { <span id="L320" class="LineNr">320 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!<span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L321" class="LineNr">321 </span> vector<string> expected_lines = <a href='003trace.cc.html#L409'>split</a><span class="Delimiter">(</span>expected<span class="Delimiter">,</span> <span class="Constant">"\n"</span><span class="Delimiter">);</span> <span id="L322" class="LineNr">322 </span> <span class="Normal">int</span> curr_expected_line = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L323" class="LineNr">323 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr_expected_line < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>expected_lines<span class="Delimiter">)</span> && expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">).</span>empty<span class="Delimiter">())</span> +<span id="L323" class="LineNr">323 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr_expected_line < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>expected_lines<span class="Delimiter">)</span> && expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">).</span>empty<span class="Delimiter">())</span> <span id="L324" class="LineNr">324 </span> ++curr_expected_line<span class="Delimiter">;</span> -<span id="L325" class="LineNr">325 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_expected_line == <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>expected_lines<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L325" class="LineNr">325 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_expected_line == <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>expected_lines<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L326" class="LineNr">326 </span> string label<span class="Delimiter">,</span> <a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">;</span> <span id="L327" class="LineNr">327 </span> <a href='003trace.cc.html#L388'>split_label_contents</a><span class="Delimiter">(</span>expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">),</span> &label<span class="Delimiter">,</span> &contents<span class="Delimiter">);</span> <span id="L328" class="LineNr">328 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span><span class="Delimiter">-></span><a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span><span class="Delimiter">-></span><a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L329" class="LineNr">329 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>label != p<span class="Delimiter">-></span>label<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L330" class="LineNr">330 </span> string t = <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span>p<span class="Delimiter">-></span><a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">);</span> +<span id="L330" class="LineNr">330 </span> string t = <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span>p<span class="Delimiter">-></span><a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">);</span> <span id="L331" class="LineNr">331 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L117'>contents</a> != <a href='003trace.cc.html#L132'>unescape_newline</a><span class="Delimiter">(</span>t<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span id="L332" class="LineNr">332 </span> ++curr_expected_line<span class="Delimiter">;</span> -<span id="L333" class="LineNr">333 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr_expected_line < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>expected_lines<span class="Delimiter">)</span> && expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">).</span>empty<span class="Delimiter">())</span> +<span id="L333" class="LineNr">333 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr_expected_line < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>expected_lines<span class="Delimiter">)</span> && expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">).</span>empty<span class="Delimiter">())</span> <span id="L334" class="LineNr">334 </span> ++curr_expected_line<span class="Delimiter">;</span> -<span id="L335" class="LineNr">335 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_expected_line == <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>expected_lines<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L335" class="LineNr">335 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_expected_line == <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>expected_lines<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L336" class="LineNr">336 </span> <a href='003trace.cc.html#L388'>split_label_contents</a><span class="Delimiter">(</span>expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">),</span> &label<span class="Delimiter">,</span> &contents<span class="Delimiter">);</span> <span id="L337" class="LineNr">337 </span> <span class="Delimiter">}</span> <span id="L338" class="LineNr">338 </span> <span id="L339" class="LineNr">339 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L401'>line_exists_anywhere</a><span class="Delimiter">(</span>label<span class="Delimiter">,</span> <a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L340" class="LineNr">340 </span> cerr << <span class="Constant">"\nF - "</span> << FUNCTION << <span class="Constant">"("</span> << <span class="Normal">FILE</span> << <span class="Constant">":"</span> << LINE << <span class="Constant">"): <a href='011run.cc.html#L122'>line</a> ["</span> << label << <span class="Constant">": "</span> << <a href='003trace.cc.html#L117'>contents</a> << <span class="Constant">"] out of order in <a href='003trace.cc.html#L96'>trace</a>:\n"</span><span class="Delimiter">;</span> +<span id="L340" class="LineNr">340 </span> cerr << <span class="Constant">"\nF - "</span> << FUNCTION << <span class="Constant">"("</span> << <span class="Normal">FILE</span> << <span class="Constant">":"</span> << LINE << <span class="Constant">"): <a href='011run.cc.html#L121'>line</a> ["</span> << label << <span class="Constant">": "</span> << <a href='003trace.cc.html#L117'>contents</a> << <span class="Constant">"] out of order in <a href='003trace.cc.html#L96'>trace</a>:\n"</span><span class="Delimiter">;</span> <span id="L341" class="LineNr">341 </span> <a href='003trace.cc.html#L437'>DUMP</a><span class="Delimiter">(</span><span class="Constant">""</span><span class="Delimiter">);</span> <span id="L342" class="LineNr">342 </span> <span class="Delimiter">}</span> <span id="L343" class="LineNr">343 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> @@ -411,7 +411,7 @@ if ('onhashchange' in window) { <span id="L350" class="LineNr">350 </span> <span id="L351" class="LineNr">351 </span><span class="Normal">bool</span> <a href='003trace.cc.html#L351'>trace_doesnt_contain</a><span class="Delimiter">(</span>string expected<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L352" class="LineNr">352 </span> vector<string> tmp = <a href='003trace.cc.html#L424'>split_first</a><span class="Delimiter">(</span>expected<span class="Delimiter">,</span> <span class="Constant">": "</span><span class="Delimiter">);</span> -<span id="L353" class="LineNr">353 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>tmp<span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L353" class="LineNr">353 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>tmp<span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L354" class="LineNr">354 </span> <a href='003trace.cc.html#L228'>raise</a> << expected << <span class="Constant">": missing label or <a href='003trace.cc.html#L117'>contents</a> in <a href='003trace.cc.html#L96'>trace</a> line\n"</span> << end<span class="Delimiter">();</span> <span id="L355" class="LineNr">355 </span> assert<span class="Delimiter">(</span><span class="Constant">false</span><span class="Delimiter">);</span> <span id="L356" class="LineNr">356 </span> <span class="Delimiter">}</span> @@ -422,12 +422,12 @@ if ('onhashchange' in window) { <span id="L361" class="LineNr">361 </span> <span class="Identifier">return</span> trace_count<span class="Delimiter">(</span>label<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span id="L362" class="LineNr">362 </span><span class="Delimiter">}</span> <span id="L363" class="LineNr">363 </span> -<span id="L364" class="LineNr">364 </span><span class="Normal">int</span> trace_count<span class="Delimiter">(</span>string label<span class="Delimiter">,</span> string <a href='011run.cc.html#L122'>line</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L364" class="LineNr">364 </span><span class="Normal">int</span> trace_count<span class="Delimiter">(</span>string label<span class="Delimiter">,</span> string <a href='011run.cc.html#L121'>line</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L365" class="LineNr">365 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!<span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> <span id="L366" class="LineNr">366 </span> <span class="Normal">long</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> <span id="L367" class="LineNr">367 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span><span class="Delimiter">-></span><a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span><span class="Delimiter">-></span><a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L368" class="LineNr">368 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>label == p<span class="Delimiter">-></span>label<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L369" class="LineNr">369 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='011run.cc.html#L122'>line</a> == <span class="Constant">""</span> || <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><a href='011run.cc.html#L122'>line</a><span class="Delimiter">)</span> == <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span>p<span class="Delimiter">-></span><a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">))</span> +<span id="L369" class="LineNr">369 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='011run.cc.html#L121'>line</a> == <span class="Constant">""</span> || <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><a href='011run.cc.html#L121'>line</a><span class="Delimiter">)</span> == <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span>p<span class="Delimiter">-></span><a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">))</span> <span id="L370" class="LineNr">370 </span> ++result<span class="Delimiter">;</span> <span id="L371" class="LineNr">371 </span> <span class="Delimiter">}</span> <span id="L372" class="LineNr">372 </span> <span class="Delimiter">}</span> @@ -439,7 +439,7 @@ if ('onhashchange' in window) { <span id="L378" class="LineNr">378 </span> <span class="Normal">long</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> <span id="L379" class="LineNr">379 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span><span class="Delimiter">-></span><a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span><span class="Delimiter">-></span><a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L380" class="LineNr">380 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>label == p<span class="Delimiter">-></span>label<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L381" class="LineNr">381 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L105'>starts_with</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span>p<span class="Delimiter">-></span><a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">),</span> <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span>prefix<span class="Delimiter">)))</span> +<span id="L381" class="LineNr">381 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L106'>starts_with</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span>p<span class="Delimiter">-></span><a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">),</span> <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span>prefix<span class="Delimiter">)))</span> <span id="L382" class="LineNr">382 </span> ++result<span class="Delimiter">;</span> <span id="L383" class="LineNr">383 </span> <span class="Delimiter">}</span> <span id="L384" class="LineNr">384 </span> <span class="Delimiter">}</span> @@ -451,18 +451,18 @@ if ('onhashchange' in window) { <span id="L390" class="LineNr">390 </span> <span class="Normal">size_t</span> pos = s<span class="Delimiter">.</span>find<span class="Delimiter">(</span>delim<span class="Delimiter">);</span> <span id="L391" class="LineNr">391 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>pos == string::npos<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L392" class="LineNr">392 </span> *label = <span class="Constant">""</span><span class="Delimiter">;</span> -<span id="L393" class="LineNr">393 </span> *contents = <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span>s<span class="Delimiter">);</span> +<span id="L393" class="LineNr">393 </span> *contents = <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span>s<span class="Delimiter">);</span> <span id="L394" class="LineNr">394 </span> <span class="Delimiter">}</span> <span id="L395" class="LineNr">395 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L396" class="LineNr">396 </span> *label = <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span>substr<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> pos<span class="Delimiter">));</span> -<span id="L397" class="LineNr">397 </span> *contents = <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span>substr<span class="Delimiter">(</span>pos+SIZE<span class="Delimiter">(</span>delim<span class="Delimiter">)));</span> +<span id="L396" class="LineNr">396 </span> *label = <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span>substr<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> pos<span class="Delimiter">));</span> +<span id="L397" class="LineNr">397 </span> *contents = <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span>substr<span class="Delimiter">(</span>pos+SIZE<span class="Delimiter">(</span>delim<span class="Delimiter">)));</span> <span id="L398" class="LineNr">398 </span> <span class="Delimiter">}</span> <span id="L399" class="LineNr">399 </span><span class="Delimiter">}</span> <span id="L400" class="LineNr">400 </span> <span id="L401" class="LineNr">401 </span><span class="Normal">bool</span> <a href='003trace.cc.html#L401'>line_exists_anywhere</a><span class="Delimiter">(</span><span class="Normal">const</span> string& label<span class="Delimiter">,</span> <span class="Normal">const</span> string& <a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L402" class="LineNr">402 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span><span class="Delimiter">-></span><a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span><span class="Delimiter">-></span><a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L403" class="LineNr">403 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>label != p<span class="Delimiter">-></span>label<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L404" class="LineNr">404 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L117'>contents</a> == <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span>p<span class="Delimiter">-></span><a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L404" class="LineNr">404 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L117'>contents</a> == <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span>p<span class="Delimiter">-></span><a href='003trace.cc.html#L117'>contents</a><span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L405" class="LineNr">405 </span> <span class="Delimiter">}</span> <span id="L406" class="LineNr">406 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L407" class="LineNr">407 </span><span class="Delimiter">}</span> @@ -508,79 +508,80 @@ if ('onhashchange' in window) { <span id="L447" class="LineNr">447 </span><span class="Delimiter">:(before "End Globals")</span> <span id="L448" class="LineNr">448 </span>ofstream <span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">;</span> <span id="L449" class="LineNr">449 </span><span class="Delimiter">:(before "End Commandline Options(*arg)")</span> -<span id="L450" class="LineNr">450 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L101'>is_equal</a><span class="Delimiter">(</span>*arg<span class="Delimiter">,</span> <span class="Constant">"--trace"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L450" class="LineNr">450 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L102'>is_equal</a><span class="Delimiter">(</span>*arg<span class="Delimiter">,</span> <span class="Constant">"--trace"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L451" class="LineNr">451 </span> cerr << <span class="Constant">"saving <a href='003trace.cc.html#L96'>trace</a> to 'last_run'\n"</span><span class="Delimiter">;</span> <span id="L452" class="LineNr">452 </span> <span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">.</span>open<span class="Delimiter">(</span><span class="Constant">"last_run"</span><span class="Delimiter">);</span> <span id="L453" class="LineNr">453 </span> <span class="Comment">// Add a dummy line up top; otherwise the `browse_trace` tool currently has</span> <span id="L454" class="LineNr">454 </span> <span class="Comment">// no way to expand any lines above an error.</span> <span id="L455" class="LineNr">455 </span> <span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span> << <span class="Constant">" 0 dummy: start\n"</span><span class="Delimiter">;</span> -<span id="L456" class="LineNr">456 </span><span class="Delimiter">}</span> -<span id="L457" class="LineNr">457 </span><span class="Delimiter">:(before "End <a href='003trace.cc.html#L96'>trace</a> Commit")</span> -<span id="L458" class="LineNr">458 </span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L459" class="LineNr">459 </span> <a href='003trace.cc.html#L143'>dump_trace_line</a><span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">,</span> t<span class="Delimiter">);</span> -<span id="L460" class="LineNr">460 </span><span class="Delimiter">}</span> -<span id="L461" class="LineNr">461 </span><span class="Delimiter">:(before "End One-time Setup")</span> -<span id="L462" class="LineNr">462 </span>atexit<span class="Delimiter">(</span><a href='003trace.cc.html#L464'>cleanup_main</a><span class="Delimiter">);</span> -<span id="L463" class="LineNr">463 </span><span class="Delimiter">:(code)</span> -<span id="L464" class="LineNr">464 </span><span class="Normal">void</span> <a href='003trace.cc.html#L464'>cleanup_main</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L465" class="LineNr">465 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">.</span>close<span class="Delimiter">();</span> -<span id="L466" class="LineNr">466 </span> <span class="Comment">// End cleanup_main</span> -<span id="L467" class="LineNr">467 </span><span class="Delimiter">}</span> -<span id="L468" class="LineNr">468 </span> -<span id="L469" class="LineNr">469 </span><span class="Delimiter">:(before "End trace_stream Methods")</span> -<span id="L470" class="LineNr">470 </span>string <a href='003trace.cc.html#L470'>readable_contents</a><span class="Delimiter">(</span>string label<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L471" class="LineNr">471 </span> string <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">);</span> <span class="Comment">// prototype</span> -<span id="L472" class="LineNr">472 </span> ostringstream output<span class="Delimiter">;</span> -<span id="L473" class="LineNr">473 </span> label = <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span>label<span class="Delimiter">);</span> -<span id="L474" class="LineNr">474 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = <a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> -<span id="L475" class="LineNr">475 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>label<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> || label == p<span class="Delimiter">-></span>label<span class="Delimiter">)</span> -<span id="L476" class="LineNr">476 </span> <a href='003trace.cc.html#L143'>dump_trace_line</a><span class="Delimiter">(</span>output<span class="Delimiter">,</span> *p<span class="Delimiter">);</span> -<span id="L477" class="LineNr">477 </span> <span class="Identifier">return</span> output<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L478" class="LineNr">478 </span><span class="Delimiter">}</span> -<span id="L479" class="LineNr">479 </span> -<span id="L480" class="LineNr">480 </span><span class="Comment">//: Print traces to the screen as they happen.</span> -<span id="L481" class="LineNr">481 </span><span class="Comment">//: Particularly useful when juggling multiple trace streams, like when</span> -<span id="L482" class="LineNr">482 </span><span class="Comment">//: debugging sandboxes.</span> -<span id="L483" class="LineNr">483 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L484" class="LineNr">484 </span><span class="Normal">bool</span> <span class="Special"><a href='003trace.cc.html#L484'>Dump_trace</a></span> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L485" class="LineNr">485 </span><span class="Delimiter">:(before "End Commandline Options(*arg)")</span> -<span id="L486" class="LineNr">486 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L101'>is_equal</a><span class="Delimiter">(</span>*arg<span class="Delimiter">,</span> <span class="Constant">"--dump"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L487" class="LineNr">487 </span> <span class="Special"><a href='003trace.cc.html#L484'>Dump_trace</a></span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L488" class="LineNr">488 </span><span class="Delimiter">}</span> -<span id="L489" class="LineNr">489 </span><span class="Delimiter">:(before "End Incremental Trace Print Conditions")</span> -<span id="L490" class="LineNr">490 </span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L484'>Dump_trace</a></span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L491" class="LineNr">491 </span> -<span id="L492" class="LineNr">492 </span><span class="Comment">//: Miscellaneous helpers.</span> -<span id="L493" class="LineNr">493 </span> -<span id="L494" class="LineNr">494 </span><span class="Delimiter">:(code)</span> -<span id="L495" class="LineNr">495 </span>string <a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L496" class="LineNr">496 </span> string::const_iterator first = s<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> -<span id="L497" class="LineNr">497 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>first != s<span class="Delimiter">.</span>end<span class="Delimiter">()</span> && isspace<span class="Delimiter">(</span>*first<span class="Delimiter">))</span> -<span id="L498" class="LineNr">498 </span> ++first<span class="Delimiter">;</span> -<span id="L499" class="LineNr">499 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>first == s<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> -<span id="L500" class="LineNr">500 </span> -<span id="L501" class="LineNr">501 </span> string::const_iterator last = --s<span class="Delimiter">.</span>end<span class="Delimiter">();</span> -<span id="L502" class="LineNr">502 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>last != s<span class="Delimiter">.</span>begin<span class="Delimiter">()</span> && isspace<span class="Delimiter">(</span>*last<span class="Delimiter">))</span> -<span id="L503" class="LineNr">503 </span> --last<span class="Delimiter">;</span> -<span id="L504" class="LineNr">504 </span> ++last<span class="Delimiter">;</span> -<span id="L505" class="LineNr">505 </span> <span class="Identifier">return</span> string<span class="Delimiter">(</span>first<span class="Delimiter">,</span> last<span class="Delimiter">);</span> -<span id="L506" class="LineNr">506 </span><span class="Delimiter">}</span> -<span id="L507" class="LineNr">507 </span> -<span id="L508" class="LineNr">508 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L509" class="LineNr">509 </span><span class="PreProc">#include </span><span class="Constant"><vector></span> -<span id="L510" class="LineNr">510 </span><span class="Normal">using</span> std::vector<span class="Delimiter">;</span> -<span id="L511" class="LineNr">511 </span><span class="PreProc">#include </span><span class="Constant"><list></span> -<span id="L512" class="LineNr">512 </span><span class="Normal">using</span> std::list<span class="Delimiter">;</span> -<span id="L513" class="LineNr">513 </span><span class="PreProc">#include </span><span class="Constant"><set></span> -<span id="L514" class="LineNr">514 </span><span class="Normal">using</span> std::set<span class="Delimiter">;</span> -<span id="L515" class="LineNr">515 </span> -<span id="L516" class="LineNr">516 </span><span class="PreProc">#include </span><span class="Constant"><sstream></span> -<span id="L517" class="LineNr">517 </span><span class="Normal">using</span> std::istringstream<span class="Delimiter">;</span> -<span id="L518" class="LineNr">518 </span><span class="Normal">using</span> std::ostringstream<span class="Delimiter">;</span> -<span id="L519" class="LineNr">519 </span> -<span id="L520" class="LineNr">520 </span><span class="PreProc">#include </span><span class="Constant"><fstream></span> -<span id="L521" class="LineNr">521 </span><span class="Normal">using</span> std::ifstream<span class="Delimiter">;</span> -<span id="L522" class="LineNr">522 </span><span class="Normal">using</span> std::ofstream<span class="Delimiter">;</span> +<span id="L456" class="LineNr">456 </span> <span class="Comment">// End --trace Settings</span> +<span id="L457" class="LineNr">457 </span><span class="Delimiter">}</span> +<span id="L458" class="LineNr">458 </span><span class="Delimiter">:(before "End <a href='003trace.cc.html#L96'>trace</a> Commit")</span> +<span id="L459" class="LineNr">459 </span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L460" class="LineNr">460 </span> <a href='003trace.cc.html#L143'>dump_trace_line</a><span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">,</span> t<span class="Delimiter">);</span> +<span id="L461" class="LineNr">461 </span><span class="Delimiter">}</span> +<span id="L462" class="LineNr">462 </span><span class="Delimiter">:(before "End One-time Setup")</span> +<span id="L463" class="LineNr">463 </span>atexit<span class="Delimiter">(</span><a href='003trace.cc.html#L465'>cleanup_main</a><span class="Delimiter">);</span> +<span id="L464" class="LineNr">464 </span><span class="Delimiter">:(code)</span> +<span id="L465" class="LineNr">465 </span><span class="Normal">void</span> <a href='003trace.cc.html#L465'>cleanup_main</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L466" class="LineNr">466 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">.</span>close<span class="Delimiter">();</span> +<span id="L467" class="LineNr">467 </span> <span class="Comment">// End cleanup_main</span> +<span id="L468" class="LineNr">468 </span><span class="Delimiter">}</span> +<span id="L469" class="LineNr">469 </span> +<span id="L470" class="LineNr">470 </span><span class="Delimiter">:(before "End trace_stream Methods")</span> +<span id="L471" class="LineNr">471 </span>string <a href='003trace.cc.html#L471'>readable_contents</a><span class="Delimiter">(</span>string label<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L472" class="LineNr">472 </span> string <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">);</span> <span class="Comment">// prototype</span> +<span id="L473" class="LineNr">473 </span> ostringstream output<span class="Delimiter">;</span> +<span id="L474" class="LineNr">474 </span> label = <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span>label<span class="Delimiter">);</span> +<span id="L475" class="LineNr">475 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>vector<trace_line>::iterator p = <a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <a href='003trace.cc.html#L76'>past_lines</a><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> +<span id="L476" class="LineNr">476 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>label<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> || label == p<span class="Delimiter">-></span>label<span class="Delimiter">)</span> +<span id="L477" class="LineNr">477 </span> <a href='003trace.cc.html#L143'>dump_trace_line</a><span class="Delimiter">(</span>output<span class="Delimiter">,</span> *p<span class="Delimiter">);</span> +<span id="L478" class="LineNr">478 </span> <span class="Identifier">return</span> output<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L479" class="LineNr">479 </span><span class="Delimiter">}</span> +<span id="L480" class="LineNr">480 </span> +<span id="L481" class="LineNr">481 </span><span class="Comment">//: Print traces to the screen as they happen.</span> +<span id="L482" class="LineNr">482 </span><span class="Comment">//: Particularly useful when juggling multiple trace streams, like when</span> +<span id="L483" class="LineNr">483 </span><span class="Comment">//: debugging sandboxes.</span> +<span id="L484" class="LineNr">484 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L485" class="LineNr">485 </span><span class="Normal">bool</span> <span class="Special"><a href='003trace.cc.html#L485'>Dump_trace</a></span> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L486" class="LineNr">486 </span><span class="Delimiter">:(before "End Commandline Options(*arg)")</span> +<span id="L487" class="LineNr">487 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L102'>is_equal</a><span class="Delimiter">(</span>*arg<span class="Delimiter">,</span> <span class="Constant">"--dump"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L488" class="LineNr">488 </span> <span class="Special"><a href='003trace.cc.html#L485'>Dump_trace</a></span> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L489" class="LineNr">489 </span><span class="Delimiter">}</span> +<span id="L490" class="LineNr">490 </span><span class="Delimiter">:(before "End Incremental Trace Print Conditions")</span> +<span id="L491" class="LineNr">491 </span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L485'>Dump_trace</a></span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L492" class="LineNr">492 </span> +<span id="L493" class="LineNr">493 </span><span class="Comment">//: Miscellaneous helpers.</span> +<span id="L494" class="LineNr">494 </span> +<span id="L495" class="LineNr">495 </span><span class="Delimiter">:(code)</span> +<span id="L496" class="LineNr">496 </span>string <a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L497" class="LineNr">497 </span> string::const_iterator first = s<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> +<span id="L498" class="LineNr">498 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>first != s<span class="Delimiter">.</span>end<span class="Delimiter">()</span> && isspace<span class="Delimiter">(</span>*first<span class="Delimiter">))</span> +<span id="L499" class="LineNr">499 </span> ++first<span class="Delimiter">;</span> +<span id="L500" class="LineNr">500 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>first == s<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> +<span id="L501" class="LineNr">501 </span> +<span id="L502" class="LineNr">502 </span> string::const_iterator last = --s<span class="Delimiter">.</span>end<span class="Delimiter">();</span> +<span id="L503" class="LineNr">503 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>last != s<span class="Delimiter">.</span>begin<span class="Delimiter">()</span> && isspace<span class="Delimiter">(</span>*last<span class="Delimiter">))</span> +<span id="L504" class="LineNr">504 </span> --last<span class="Delimiter">;</span> +<span id="L505" class="LineNr">505 </span> ++last<span class="Delimiter">;</span> +<span id="L506" class="LineNr">506 </span> <span class="Identifier">return</span> string<span class="Delimiter">(</span>first<span class="Delimiter">,</span> last<span class="Delimiter">);</span> +<span id="L507" class="LineNr">507 </span><span class="Delimiter">}</span> +<span id="L508" class="LineNr">508 </span> +<span id="L509" class="LineNr">509 </span><span class="Delimiter">:(before "End Includes")</span> +<span id="L510" class="LineNr">510 </span><span class="PreProc">#include </span><span class="Constant"><vector></span> +<span id="L511" class="LineNr">511 </span><span class="Normal">using</span> std::vector<span class="Delimiter">;</span> +<span id="L512" class="LineNr">512 </span><span class="PreProc">#include </span><span class="Constant"><list></span> +<span id="L513" class="LineNr">513 </span><span class="Normal">using</span> std::list<span class="Delimiter">;</span> +<span id="L514" class="LineNr">514 </span><span class="PreProc">#include </span><span class="Constant"><set></span> +<span id="L515" class="LineNr">515 </span><span class="Normal">using</span> std::set<span class="Delimiter">;</span> +<span id="L516" class="LineNr">516 </span> +<span id="L517" class="LineNr">517 </span><span class="PreProc">#include </span><span class="Constant"><sstream></span> +<span id="L518" class="LineNr">518 </span><span class="Normal">using</span> std::istringstream<span class="Delimiter">;</span> +<span id="L519" class="LineNr">519 </span><span class="Normal">using</span> std::ostringstream<span class="Delimiter">;</span> +<span id="L520" class="LineNr">520 </span> +<span id="L521" class="LineNr">521 </span><span class="PreProc">#include </span><span class="Constant"><fstream></span> +<span id="L522" class="LineNr">522 </span><span class="Normal">using</span> std::ifstream<span class="Delimiter">;</span> +<span id="L523" class="LineNr">523 </span><span class="Normal">using</span> std::ofstream<span class="Delimiter">;</span> </pre> </body> </html> diff --git a/html/003trace.test.cc.html b/html/003trace.test.cc.html index 136345cd..c885cafd 100644 --- a/html/003trace.test.cc.html +++ b/html/003trace.test.cc.html @@ -173,19 +173,19 @@ if ('onhashchange' in window) { <span id="L117" class="LineNr">117 </span><span class="Delimiter">}</span> <span id="L118" class="LineNr">118 </span> <span id="L119" class="LineNr">119 </span><span class="Normal">void</span> <a href='003trace.test.cc.html#L119'>test_trim</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L120" class="LineNr">120 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">""</span><span class="Delimiter">),</span> <span class="Constant">""</span><span class="Delimiter">);</span> -<span id="L121" class="LineNr">121 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">" "</span><span class="Delimiter">),</span> <span class="Constant">""</span><span class="Delimiter">);</span> -<span id="L122" class="LineNr">122 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">" "</span><span class="Delimiter">),</span> <span class="Constant">""</span><span class="Delimiter">);</span> -<span id="L123" class="LineNr">123 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">"a"</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> -<span id="L124" class="LineNr">124 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">" a"</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> -<span id="L125" class="LineNr">125 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">" a"</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> -<span id="L126" class="LineNr">126 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">" ab"</span><span class="Delimiter">),</span> <span class="Constant">"ab"</span><span class="Delimiter">);</span> -<span id="L127" class="LineNr">127 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">"a "</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> -<span id="L128" class="LineNr">128 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">"a "</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> -<span id="L129" class="LineNr">129 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">"ab "</span><span class="Delimiter">),</span> <span class="Constant">"ab"</span><span class="Delimiter">);</span> -<span id="L130" class="LineNr">130 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">" a "</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> -<span id="L131" class="LineNr">131 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">" a "</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> -<span id="L132" class="LineNr">132 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L495'>trim</a><span class="Delimiter">(</span><span class="Constant">" ab "</span><span class="Delimiter">),</span> <span class="Constant">"ab"</span><span class="Delimiter">);</span> +<span id="L120" class="LineNr">120 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">""</span><span class="Delimiter">),</span> <span class="Constant">""</span><span class="Delimiter">);</span> +<span id="L121" class="LineNr">121 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">" "</span><span class="Delimiter">),</span> <span class="Constant">""</span><span class="Delimiter">);</span> +<span id="L122" class="LineNr">122 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">" "</span><span class="Delimiter">),</span> <span class="Constant">""</span><span class="Delimiter">);</span> +<span id="L123" class="LineNr">123 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">"a"</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> +<span id="L124" class="LineNr">124 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">" a"</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> +<span id="L125" class="LineNr">125 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">" a"</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> +<span id="L126" class="LineNr">126 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">" ab"</span><span class="Delimiter">),</span> <span class="Constant">"ab"</span><span class="Delimiter">);</span> +<span id="L127" class="LineNr">127 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">"a "</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> +<span id="L128" class="LineNr">128 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">"a "</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> +<span id="L129" class="LineNr">129 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">"ab "</span><span class="Delimiter">),</span> <span class="Constant">"ab"</span><span class="Delimiter">);</span> +<span id="L130" class="LineNr">130 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">" a "</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> +<span id="L131" class="LineNr">131 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">" a "</span><span class="Delimiter">),</span> <span class="Constant">"a"</span><span class="Delimiter">);</span> +<span id="L132" class="LineNr">132 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='003trace.cc.html#L496'>trim</a><span class="Delimiter">(</span><span class="Constant">" ab "</span><span class="Delimiter">),</span> <span class="Constant">"ab"</span><span class="Delimiter">);</span> <span id="L133" class="LineNr">133 </span><span class="Delimiter">}</span> </pre> </body> diff --git a/html/010---vm.cc.html b/html/010---vm.cc.html index 6d55cc8a..52d5cfba 100644 --- a/html/010---vm.cc.html +++ b/html/010---vm.cc.html @@ -59,410 +59,404 @@ if ('onhashchange' in window) { <body onload='JumpToLine();'> <a href='https://github.com/akkartik/mu/blob/master/010---vm.cc'>https://github.com/akkartik/mu/blob/master/010---vm.cc</a> <pre id='vimCodeElement'> -<span id="L1" class="LineNr"> 1 </span><span class="Comment">//: Core data structures for simulating the SubX VM (subset of an x86 processor)</span> -<span id="L2" class="LineNr"> 2 </span><span class="Comment">//:</span> -<span id="L3" class="LineNr"> 3 </span><span class="Comment">//: At the lowest level ("level 1") of abstraction, SubX executes x86</span> -<span id="L4" class="LineNr"> 4 </span><span class="Comment">//: instructions provided in the form of an array of bytes, loaded into memory</span> -<span id="L5" class="LineNr"> 5 </span><span class="Comment">//: starting at a specific address.</span> -<span id="L6" class="LineNr"> 6 </span><span class="Comment">//:</span> -<span id="L7" class="LineNr"> 7 </span><span class="Comment">//: SubX is fundamentally a translator. But having a VM to execute its</span> -<span id="L8" class="LineNr"> 8 </span><span class="Comment">//: translations affords greater confidence in it.</span> -<span id="L9" class="LineNr"> 9 </span> -<span id="L10" class="LineNr"> 10 </span><span class="SalientComment">//:: registers</span> -<span id="L11" class="LineNr"> 11 </span><span class="Comment">//: assume segment registers are hard-coded to 0</span> -<span id="L12" class="LineNr"> 12 </span><span class="Comment">//: no floating-point, MMX, etc. yet</span> -<span id="L13" class="LineNr"> 13 </span> -<span id="L14" class="LineNr"> 14 </span><span class="Delimiter">:(before "End Types")</span> -<span id="L15" class="LineNr"> 15 </span><span class="Normal">enum</span> <span class="Delimiter">{</span> -<span id="L16" class="LineNr"> 16 </span> <a href='010---vm.cc.html#L16'>EAX</a><span class="Delimiter">,</span> -<span id="L17" class="LineNr"> 17 </span> <a href='010---vm.cc.html#L17'>ECX</a><span class="Delimiter">,</span> -<span id="L18" class="LineNr"> 18 </span> <a href='010---vm.cc.html#L18'>EDX</a><span class="Delimiter">,</span> -<span id="L19" class="LineNr"> 19 </span> <a href='010---vm.cc.html#L19'>EBX</a><span class="Delimiter">,</span> -<span id="L20" class="LineNr"> 20 </span> <a href='010---vm.cc.html#L20'>ESP</a><span class="Delimiter">,</span> -<span id="L21" class="LineNr"> 21 </span> <a href='010---vm.cc.html#L21'>EBP</a><span class="Delimiter">,</span> -<span id="L22" class="LineNr"> 22 </span> <a href='010---vm.cc.html#L22'>ESI</a><span class="Delimiter">,</span> -<span id="L23" class="LineNr"> 23 </span> <a href='010---vm.cc.html#L23'>EDI</a><span class="Delimiter">,</span> -<span id="L24" class="LineNr"> 24 </span> <a href='010---vm.cc.html#L24'>NUM_INT_REGISTERS</a><span class="Delimiter">,</span> -<span id="L25" class="LineNr"> 25 </span><span class="Delimiter">};</span> -<span id="L26" class="LineNr"> 26 </span><span class="Normal">union</span> <a href='010---vm.cc.html#L26'>reg</a> <span class="Delimiter">{</span> -<span id="L27" class="LineNr"> 27 </span> <span class="Normal">int32_t</span> i<span class="Delimiter">;</span> -<span id="L28" class="LineNr"> 28 </span> <span class="Normal">uint32_t</span> u<span class="Delimiter">;</span> -<span id="L29" class="LineNr"> 29 </span><span class="Delimiter">};</span> -<span id="L30" class="LineNr"> 30 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L31" class="LineNr"> 31 </span><a href='010---vm.cc.html#L26'>reg</a> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[NUM_INT_REGISTERS] = <span class="Delimiter">{</span> <span class="Delimiter">{</span><span class="Constant">0</span><span class="Delimiter">}</span> <span class="Delimiter">};</span> -<span id="L32" class="LineNr"> 32 </span><span class="Normal">uint32_t</span> <a href='010---vm.cc.html#L32'>EIP</a> = <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// preserve null pointer</span> -<span id="L33" class="LineNr"> 33 </span><span class="Delimiter">:(before "End Reset")</span> -<span id="L34" class="LineNr"> 34 </span>bzero<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span><span class="Delimiter">,</span> <span class="Normal">sizeof</span><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span><span class="Delimiter">));</span> -<span id="L35" class="LineNr"> 35 </span><a href='010---vm.cc.html#L32'>EIP</a> = <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// preserve null pointer</span> -<span id="L36" class="LineNr"> 36 </span> -<span id="L37" class="LineNr"> 37 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Contents")</span> -<span id="L38" class="LineNr"> 38 </span>cerr << <span class="Constant">" registers\n"</span><span class="Delimiter">;</span> -<span id="L39" class="LineNr"> 39 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Texts")</span> -<span id="L40" class="LineNr"> 40 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='001help.cc.html#L53'>Help</a></span><span class="Delimiter">,</span> <span class="Constant">"registers"</span><span class="Delimiter">,</span> -<span id="L41" class="LineNr"> 41 </span> <span class="Constant">"SubX currently supports eight 32-bit integer registers. From 0 to 7, they are:\n"</span> -<span id="L42" class="LineNr"> 42 </span> <span class="Constant">" <a href='010---vm.cc.html#L16'>EAX</a> <a href='010---vm.cc.html#L17'>ECX</a> <a href='010---vm.cc.html#L18'>EDX</a> <a href='010---vm.cc.html#L19'>EBX</a> <a href='010---vm.cc.html#L20'>ESP</a> <a href='010---vm.cc.html#L21'>EBP</a> <a href='010---vm.cc.html#L22'>ESI</a> EDI\n"</span> -<span id="L43" class="LineNr"> 43 </span> <span class="Constant">"ESP contains the top of the stack.\n"</span> -<span id="L44" class="LineNr"> 44 </span> <span class="Constant">"\n"</span> -<span id="L45" class="LineNr"> 45 </span> <span class="Constant">"-- 8-bit registers\n"</span> -<span id="L46" class="LineNr"> 46 </span> <span class="Constant">"Some instructions operate on eight *overlapping* 8-bit registers.\n"</span> -<span id="L47" class="LineNr"> 47 </span> <span class="Constant">"From 0 to 7, they are:\n"</span> -<span id="L48" class="LineNr"> 48 </span> <span class="Constant">" AL CL DL BL AH CH DH BH\n"</span> -<span id="L49" class="LineNr"> 49 </span> <span class="Constant">"The 8-bit registers overlap with the 32-bit ones. AL is the lowest signicant byte\n"</span> -<span id="L50" class="LineNr"> 50 </span> <span class="Constant">"of <a href='010---vm.cc.html#L16'>EAX</a>, AH is the second lowest significant byte, and so on.\n"</span> -<span id="L51" class="LineNr"> 51 </span> <span class="Constant">"\n"</span> -<span id="L52" class="LineNr"> 52 </span> <span class="Constant">"For example, if <a href='010---vm.cc.html#L19'>EBX</a> contains 0x11223344, then BL contains 0x44, and BH contains 0x33.\n"</span> -<span id="L53" class="LineNr"> 53 </span> <span class="Constant">"\n"</span> -<span id="L54" class="LineNr"> 54 </span> <span class="Constant">"There is no way to access bytes within <a href='010---vm.cc.html#L20'>ESP</a>, <a href='010---vm.cc.html#L21'>EBP</a>, <a href='010---vm.cc.html#L22'>ESI</a> or EDI.\n"</span> +<span id="L1" class="LineNr"> 1 </span><span class="Comment">//: Core data structures for simulating the SubX VM (subset of an x86 processor),</span> +<span id="L2" class="LineNr"> 2 </span><span class="Comment">//: either in tests or debug aids.</span> +<span id="L3" class="LineNr"> 3 </span> +<span id="L4" class="LineNr"> 4 </span><span class="SalientComment">//:: registers</span> +<span id="L5" class="LineNr"> 5 </span><span class="Comment">//: assume segment registers are hard-coded to 0</span> +<span id="L6" class="LineNr"> 6 </span><span class="Comment">//: no floating-point, MMX, etc. yet</span> +<span id="L7" class="LineNr"> 7 </span> +<span id="L8" class="LineNr"> 8 </span><span class="Delimiter">:(before "End Types")</span> +<span id="L9" class="LineNr"> 9 </span><span class="Normal">enum</span> <span class="Delimiter">{</span> +<span id="L10" class="LineNr"> 10 </span> <a href='010---vm.cc.html#L10'>EAX</a><span class="Delimiter">,</span> +<span id="L11" class="LineNr"> 11 </span> <a href='010---vm.cc.html#L11'>ECX</a><span class="Delimiter">,</span> +<span id="L12" class="LineNr"> 12 </span> <a href='010---vm.cc.html#L12'>EDX</a><span class="Delimiter">,</span> +<span id="L13" class="LineNr"> 13 </span> <a href='010---vm.cc.html#L13'>EBX</a><span class="Delimiter">,</span> +<span id="L14" class="LineNr"> 14 </span> <a href='010---vm.cc.html#L14'>ESP</a><span class="Delimiter">,</span> +<span id="L15" class="LineNr"> 15 </span> <a href='010---vm.cc.html#L15'>EBP</a><span class="Delimiter">,</span> +<span id="L16" class="LineNr"> 16 </span> <a href='010---vm.cc.html#L16'>ESI</a><span class="Delimiter">,</span> +<span id="L17" class="LineNr"> 17 </span> <a href='010---vm.cc.html#L17'>EDI</a><span class="Delimiter">,</span> +<span id="L18" class="LineNr"> 18 </span> <a href='010---vm.cc.html#L18'>NUM_INT_REGISTERS</a><span class="Delimiter">,</span> +<span id="L19" class="LineNr"> 19 </span><span class="Delimiter">};</span> +<span id="L20" class="LineNr"> 20 </span><span class="Normal">union</span> <a href='010---vm.cc.html#L20'>reg</a> <span class="Delimiter">{</span> +<span id="L21" class="LineNr"> 21 </span> <span class="Normal">int32_t</span> i<span class="Delimiter">;</span> +<span id="L22" class="LineNr"> 22 </span> <span class="Normal">uint32_t</span> u<span class="Delimiter">;</span> +<span id="L23" class="LineNr"> 23 </span><span class="Delimiter">};</span> +<span id="L24" class="LineNr"> 24 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L25" class="LineNr"> 25 </span><a href='010---vm.cc.html#L20'>reg</a> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[NUM_INT_REGISTERS] = <span class="Delimiter">{</span> <span class="Delimiter">{</span><span class="Constant">0</span><span class="Delimiter">}</span> <span class="Delimiter">};</span> +<span id="L26" class="LineNr"> 26 </span><span class="Normal">uint32_t</span> <a href='010---vm.cc.html#L26'>EIP</a> = <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// preserve null pointer</span> +<span id="L27" class="LineNr"> 27 </span><span class="Delimiter">:(before "End Reset")</span> +<span id="L28" class="LineNr"> 28 </span>bzero<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span><span class="Delimiter">,</span> <span class="Normal">sizeof</span><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span><span class="Delimiter">));</span> +<span id="L29" class="LineNr"> 29 </span><a href='010---vm.cc.html#L26'>EIP</a> = <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// preserve null pointer</span> +<span id="L30" class="LineNr"> 30 </span> +<span id="L31" class="LineNr"> 31 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Contents")</span> +<span id="L32" class="LineNr"> 32 </span>cerr << <span class="Constant">" registers\n"</span><span class="Delimiter">;</span> +<span id="L33" class="LineNr"> 33 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Texts")</span> +<span id="L34" class="LineNr"> 34 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='001help.cc.html#L53'>Help</a></span><span class="Delimiter">,</span> <span class="Constant">"registers"</span><span class="Delimiter">,</span> +<span id="L35" class="LineNr"> 35 </span> <span class="Constant">"SubX currently supports eight 32-bit integer registers. From 0 to 7, they are:\n"</span> +<span id="L36" class="LineNr"> 36 </span> <span class="Constant">" <a href='010---vm.cc.html#L10'>EAX</a> <a href='010---vm.cc.html#L11'>ECX</a> <a href='010---vm.cc.html#L12'>EDX</a> <a href='010---vm.cc.html#L13'>EBX</a> <a href='010---vm.cc.html#L14'>ESP</a> <a href='010---vm.cc.html#L15'>EBP</a> <a href='010---vm.cc.html#L16'>ESI</a> EDI\n"</span> +<span id="L37" class="LineNr"> 37 </span> <span class="Constant">"ESP contains the top of the stack.\n"</span> +<span id="L38" class="LineNr"> 38 </span> <span class="Constant">"\n"</span> +<span id="L39" class="LineNr"> 39 </span> <span class="Constant">"-- 8-bit registers\n"</span> +<span id="L40" class="LineNr"> 40 </span> <span class="Constant">"Some instructions operate on eight *overlapping* 8-bit registers.\n"</span> +<span id="L41" class="LineNr"> 41 </span> <span class="Constant">"From 0 to 7, they are:\n"</span> +<span id="L42" class="LineNr"> 42 </span> <span class="Constant">" AL CL DL BL AH CH DH BH\n"</span> +<span id="L43" class="LineNr"> 43 </span> <span class="Constant">"The 8-bit registers overlap with the 32-bit ones. AL is the lowest signicant byte\n"</span> +<span id="L44" class="LineNr"> 44 </span> <span class="Constant">"of <a href='010---vm.cc.html#L10'>EAX</a>, AH is the second lowest significant byte, and so on.\n"</span> +<span id="L45" class="LineNr"> 45 </span> <span class="Constant">"\n"</span> +<span id="L46" class="LineNr"> 46 </span> <span class="Constant">"For example, if <a href='010---vm.cc.html#L13'>EBX</a> contains 0x11223344, then BL contains 0x44, and BH contains 0x33.\n"</span> +<span id="L47" class="LineNr"> 47 </span> <span class="Constant">"\n"</span> +<span id="L48" class="LineNr"> 48 </span> <span class="Constant">"There is no way to access bytes within <a href='010---vm.cc.html#L14'>ESP</a>, <a href='010---vm.cc.html#L15'>EBP</a>, <a href='010---vm.cc.html#L16'>ESI</a> or EDI.\n"</span> +<span id="L49" class="LineNr"> 49 </span> <span class="Constant">"\n"</span> +<span id="L50" class="LineNr"> 50 </span> <span class="Constant">"For complete details consult the IA-32 software developer's manual, volume 2,\n"</span> +<span id="L51" class="LineNr"> 51 </span> <span class="Constant">"table 2-2, \"</span><span class="Constant">32</span>-bit addressing forms with the ModR/<span class="Special">M</span> byte\<span class="Constant">".\n"</span> +<span id="L52" class="LineNr"> 52 </span> <span class="Constant">"It is included in this repository as 'modrm.pdf'.\n"</span> +<span id="L53" class="LineNr"> 53 </span> <span class="Constant">"The register encodings are described in the top row of the table, but you'll need\n"</span> +<span id="L54" class="LineNr"> 54 </span> <span class="Constant">"to spend some time with it.\n"</span> <span id="L55" class="LineNr"> 55 </span> <span class="Constant">"\n"</span> -<span id="L56" class="LineNr"> 56 </span> <span class="Constant">"For complete details consult the IA-32 software developer's manual, volume 2,\n"</span> -<span id="L57" class="LineNr"> 57 </span> <span class="Constant">"table 2-2, \"</span><span class="Constant">32</span>-bit addressing forms with the ModR/<span class="Special">M</span> byte\<span class="Constant">".\n"</span> -<span id="L58" class="LineNr"> 58 </span> <span class="Constant">"It is included in this repository as 'modrm.pdf'.\n"</span> -<span id="L59" class="LineNr"> 59 </span> <span class="Constant">"The register encodings are described in the top row of the table, but you'll need\n"</span> -<span id="L60" class="LineNr"> 60 </span> <span class="Constant">"to spend some time with it.\n"</span> -<span id="L61" class="LineNr"> 61 </span> <span class="Constant">"\n"</span> -<span id="L62" class="LineNr"> 62 </span> <span class="Constant">"-- flag registers\n"</span> -<span id="L63" class="LineNr"> 63 </span> <span class="Constant">"Various instructions (particularly 'compare') modify one or more of four 1-bit\n"</span> -<span id="L64" class="LineNr"> 64 </span> <span class="Constant">"'flag' registers, as a side-effect:\n"</span> -<span id="L65" class="LineNr"> 65 </span> <span class="Constant">"- the sign flag (SF): usually set if an arithmetic result is negative, or\n"</span> -<span id="L66" class="LineNr"> 66 </span> <span class="Constant">" <a href='000organization.cc.html#L150'>reset</a> if not.\n"</span> -<span id="L67" class="LineNr"> 67 </span> <span class="Constant">"- the zero flag (<a href='010---vm.cc.html#L86'>ZF</a>): usually set if a result is zero, or <a href='000organization.cc.html#L150'>reset</a> if not.\n"</span> -<span id="L68" class="LineNr"> 68 </span> <span class="Constant">"- the carry flag (<a href='010---vm.cc.html#L87'>CF</a>): usually set if an arithmetic result overflows by just one bit.\n"</span> -<span id="L69" class="LineNr"> 69 </span> <span class="Constant">" Useful for operating on unsigned numbers.\n"</span> -<span id="L70" class="LineNr"> 70 </span> <span class="Constant">"- the overflow flag (<a href='010---vm.cc.html#L88'>OF</a>): usually set if an arithmetic result overflows by more\n"</span> -<span id="L71" class="LineNr"> 71 </span> <span class="Constant">" than one bit. Useful for operating on signed numbers.\n"</span> -<span id="L72" class="LineNr"> 72 </span> <span class="Constant">"The flag bits are read by conditional jumps.\n"</span> -<span id="L73" class="LineNr"> 73 </span> <span class="Constant">"\n"</span> -<span id="L74" class="LineNr"> 74 </span> <span class="Constant">"For complete details on how different instructions update the flags, consult the IA-32\n"</span> -<span id="L75" class="LineNr"> 75 </span> <span class="Constant">"manual (volume 2). There's various versions of it online, such as <a href="https://c9x.me/x86,">https://c9x.me/x86,</a>\n"</span> -<span id="L76" class="LineNr"> 76 </span> <span class="Constant">"though of course you'll need to be careful to ignore instructions and flag registers\n"</span> -<span id="L77" class="LineNr"> 77 </span> <span class="Constant">"that SubX doesn't support.\n"</span> -<span id="L78" class="LineNr"> 78 </span> <span class="Constant">"\n"</span> -<span id="L79" class="LineNr"> 79 </span> <span class="Constant">"It isn't simple, but if this is the processor you have running on your computer.\n"</span> -<span id="L80" class="LineNr"> 80 </span> <span class="Constant">"Might as well get good at it.\n"</span> -<span id="L81" class="LineNr"> 81 </span><span class="Delimiter">);</span> -<span id="L82" class="LineNr"> 82 </span> -<span id="L83" class="LineNr"> 83 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L84" class="LineNr"> 84 </span><span class="Comment">// the subset of x86 flag registers we care about</span> -<span id="L85" class="LineNr"> 85 </span><span class="Normal">bool</span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// sign flag</span> -<span id="L86" class="LineNr"> 86 </span><span class="Normal">bool</span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// zero flag</span> -<span id="L87" class="LineNr"> 87 </span><span class="Normal">bool</span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// carry flag</span> -<span id="L88" class="LineNr"> 88 </span><span class="Normal">bool</span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// overflow flag</span> -<span id="L89" class="LineNr"> 89 </span><span class="Delimiter">:(before "End Reset")</span> -<span id="L90" class="LineNr"> 90 </span>SF = <a href='010---vm.cc.html#L86'>ZF</a> = <a href='010---vm.cc.html#L87'>CF</a> = <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L91" class="LineNr"> 91 </span> -<span id="L92" class="LineNr"> 92 </span><span class="SalientComment">//:: simulated RAM</span> +<span id="L56" class="LineNr"> 56 </span> <span class="Constant">"-- flag registers\n"</span> +<span id="L57" class="LineNr"> 57 </span> <span class="Constant">"Various instructions (particularly 'compare') modify one or more of four 1-bit\n"</span> +<span id="L58" class="LineNr"> 58 </span> <span class="Constant">"'flag' registers, as a side-effect:\n"</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Constant">"- the sign flag (SF): usually set if an arithmetic result is negative, or\n"</span> +<span id="L60" class="LineNr"> 60 </span> <span class="Constant">" <a href='000organization.cc.html#L150'>reset</a> if not.\n"</span> +<span id="L61" class="LineNr"> 61 </span> <span class="Constant">"- the zero flag (<a href='010---vm.cc.html#L80'>ZF</a>): usually set if a result is zero, or <a href='000organization.cc.html#L150'>reset</a> if not.\n"</span> +<span id="L62" class="LineNr"> 62 </span> <span class="Constant">"- the carry flag (<a href='010---vm.cc.html#L81'>CF</a>): usually set if an arithmetic result overflows by just one bit.\n"</span> +<span id="L63" class="LineNr"> 63 </span> <span class="Constant">" Useful for operating on unsigned numbers.\n"</span> +<span id="L64" class="LineNr"> 64 </span> <span class="Constant">"- the overflow flag (<a href='010---vm.cc.html#L82'>OF</a>): usually set if an arithmetic result overflows by more\n"</span> +<span id="L65" class="LineNr"> 65 </span> <span class="Constant">" than one bit. Useful for operating on signed numbers.\n"</span> +<span id="L66" class="LineNr"> 66 </span> <span class="Constant">"The flag bits are read by conditional jumps.\n"</span> +<span id="L67" class="LineNr"> 67 </span> <span class="Constant">"\n"</span> +<span id="L68" class="LineNr"> 68 </span> <span class="Constant">"For complete details on how different instructions update the flags, consult the IA-32\n"</span> +<span id="L69" class="LineNr"> 69 </span> <span class="Constant">"manual (volume 2). There's various versions of it online, such as <a href="https://c9x.me/x86">https://c9x.me/x86</a>,\n"</span> +<span id="L70" class="LineNr"> 70 </span> <span class="Constant">"though of course you'll need to be careful to ignore instructions and flag registers\n"</span> +<span id="L71" class="LineNr"> 71 </span> <span class="Constant">"that SubX doesn't support.\n"</span> +<span id="L72" class="LineNr"> 72 </span> <span class="Constant">"\n"</span> +<span id="L73" class="LineNr"> 73 </span> <span class="Constant">"It isn't simple, but if this is the processor you have running on your computer.\n"</span> +<span id="L74" class="LineNr"> 74 </span> <span class="Constant">"Might as well get good at it.\n"</span> +<span id="L75" class="LineNr"> 75 </span><span class="Delimiter">);</span> +<span id="L76" class="LineNr"> 76 </span> +<span id="L77" class="LineNr"> 77 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L78" class="LineNr"> 78 </span><span class="Comment">// the subset of x86 flag registers we care about</span> +<span id="L79" class="LineNr"> 79 </span><span class="Normal">bool</span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// sign flag</span> +<span id="L80" class="LineNr"> 80 </span><span class="Normal">bool</span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// zero flag</span> +<span id="L81" class="LineNr"> 81 </span><span class="Normal">bool</span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// carry flag</span> +<span id="L82" class="LineNr"> 82 </span><span class="Normal">bool</span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// overflow flag</span> +<span id="L83" class="LineNr"> 83 </span><span class="Delimiter">:(before "End Reset")</span> +<span id="L84" class="LineNr"> 84 </span>SF = <a href='010---vm.cc.html#L80'>ZF</a> = <a href='010---vm.cc.html#L81'>CF</a> = <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L85" class="LineNr"> 85 </span> +<span id="L86" class="LineNr"> 86 </span><span class="SalientComment">//:: simulated RAM</span> +<span id="L87" class="LineNr"> 87 </span> +<span id="L88" class="LineNr"> 88 </span><span class="Delimiter">:(before "End Types")</span> +<span id="L89" class="LineNr"> 89 </span><span class="Normal">const</span> <span class="Normal">uint32_t</span> <a href='010---vm.cc.html#L89'>SEGMENT_ALIGNMENT</a> = <span class="Constant">0x1000000</span><span class="Delimiter">;</span> <span class="Comment">// 16MB</span> +<span id="L90" class="LineNr"> 90 </span><span class="Normal">inline</span> <span class="Normal">uint32_t</span> <a href='010---vm.cc.html#L90'>align_upwards</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> x<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> align<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L91" class="LineNr"> 91 </span> <span class="Identifier">return</span> <span class="Delimiter">(</span>x+align-<span class="Constant">1</span><span class="Delimiter">)</span> & -<span class="Delimiter">(</span>align<span class="Delimiter">);</span> +<span id="L92" class="LineNr"> 92 </span><span class="Delimiter">}</span> <span id="L93" class="LineNr"> 93 </span> -<span id="L94" class="LineNr"> 94 </span><span class="Delimiter">:(before "End Types")</span> -<span id="L95" class="LineNr"> 95 </span><span class="Normal">const</span> <span class="Normal">uint32_t</span> <a href='010---vm.cc.html#L95'>SEGMENT_ALIGNMENT</a> = <span class="Constant">0x1000000</span><span class="Delimiter">;</span> <span class="Comment">// 16MB</span> -<span id="L96" class="LineNr"> 96 </span><span class="Normal">inline</span> <span class="Normal">uint32_t</span> <a href='010---vm.cc.html#L96'>align_upwards</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> x<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> align<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L97" class="LineNr"> 97 </span> <span class="Identifier">return</span> <span class="Delimiter">(</span>x+align-<span class="Constant">1</span><span class="Delimiter">)</span> & -<span class="Delimiter">(</span>align<span class="Delimiter">);</span> -<span id="L98" class="LineNr"> 98 </span><span class="Delimiter">}</span> -<span id="L99" class="LineNr"> 99 </span> -<span id="L100" class="LineNr">100 </span><span class="Comment">// Like in real-world Linux, we'll allocate RAM for our programs in disjoint</span> -<span id="L101" class="LineNr">101 </span><span class="Comment">// slabs called VMAs or Virtual Memory Areas.</span> -<span id="L102" class="LineNr">102 </span><span class="Normal">struct</span> vma <span class="Delimiter">{</span> -<span id="L103" class="LineNr">103 </span> <span class="Normal">uint32_t</span> start<span class="Delimiter">;</span> <span class="Comment">// inclusive</span> -<span id="L104" class="LineNr">104 </span> <span class="Normal">uint32_t</span> end<span class="Delimiter">;</span> <span class="Comment">// exclusive</span> -<span id="L105" class="LineNr">105 </span> vector<<span class="Normal">uint8_t</span>> <a href='010---vm.cc.html#L105'>_data</a><span class="Delimiter">;</span> -<span id="L106" class="LineNr">106 </span> vma<span class="Delimiter">(</span><span class="Normal">uint32_t</span> s<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> e<span class="Delimiter">)</span> :start<span class="Delimiter">(</span>s<span class="Delimiter">),</span> end<span class="Delimiter">(</span>e<span class="Delimiter">)</span> <span class="Delimiter">{}</span> -<span id="L107" class="LineNr">107 </span> vma<span class="Delimiter">(</span><span class="Normal">uint32_t</span> s<span class="Delimiter">)</span> :start<span class="Delimiter">(</span>s<span class="Delimiter">),</span> end<span class="Delimiter">(</span><a href='010---vm.cc.html#L96'>align_upwards</a><span class="Delimiter">(</span>s+<span class="Constant">1</span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L95'>SEGMENT_ALIGNMENT</a><span class="Delimiter">))</span> <span class="Delimiter">{}</span> -<span id="L108" class="LineNr">108 </span> <span class="Normal">bool</span> <a href='010---vm.cc.html#L108'>match</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> a<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L109" class="LineNr">109 </span> <span class="Identifier">return</span> a >= start && a < end<span class="Delimiter">;</span> -<span id="L110" class="LineNr">110 </span> <span class="Delimiter">}</span> -<span id="L111" class="LineNr">111 </span> <span class="Normal">bool</span> <a href='010---vm.cc.html#L111'>match32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> a<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L112" class="LineNr">112 </span> <span class="Identifier">return</span> a >= start && a+<span class="Constant">4</span> <= end<span class="Delimiter">;</span> -<span id="L113" class="LineNr">113 </span> <span class="Delimiter">}</span> -<span id="L114" class="LineNr">114 </span> <span class="Normal">uint8_t</span>& data<span class="Delimiter">(</span><span class="Normal">uint32_t</span> a<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L115" class="LineNr">115 </span> assert<span class="Delimiter">(</span><a href='010---vm.cc.html#L108'>match</a><span class="Delimiter">(</span>a<span class="Delimiter">));</span> -<span id="L116" class="LineNr">116 </span> <span class="Normal">uint32_t</span> result_index = a-start<span class="Delimiter">;</span> -<span id="L117" class="LineNr">117 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L105'>_data</a><span class="Delimiter">.</span>size<span class="Delimiter">()</span> <= result_index<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L118" class="LineNr">118 </span> <span class="Normal">const</span> <span class="Normal">int</span> align = <span class="Constant">0x1000</span><span class="Delimiter">;</span> -<span id="L119" class="LineNr">119 </span> <span class="Normal">uint32_t</span> result_size = result_index + <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// size needed for result_index to be valid</span> -<span id="L120" class="LineNr">120 </span> <span class="Normal">uint32_t</span> new_size = <a href='010---vm.cc.html#L96'>align_upwards</a><span class="Delimiter">(</span>result_size<span class="Delimiter">,</span> align<span class="Delimiter">);</span> -<span id="L121" class="LineNr">121 </span> <span class="Comment">// grow at least 2x to maintain some amortized complexity guarantees</span> -<span id="L122" class="LineNr">122 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>new_size < <a href='010---vm.cc.html#L105'>_data</a><span class="Delimiter">.</span>size<span class="Delimiter">()</span> * <span class="Constant">2</span><span class="Delimiter">)</span> -<span id="L123" class="LineNr">123 </span> new_size = <a href='010---vm.cc.html#L105'>_data</a><span class="Delimiter">.</span>size<span class="Delimiter">()</span> * <span class="Constant">2</span><span class="Delimiter">;</span> -<span id="L124" class="LineNr">124 </span> <span class="Comment">// never grow past the stated limit</span> -<span id="L125" class="LineNr">125 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>new_size > end-start<span class="Delimiter">)</span> -<span id="L126" class="LineNr">126 </span> new_size = end-start<span class="Delimiter">;</span> -<span id="L127" class="LineNr">127 </span> <a href='010---vm.cc.html#L105'>_data</a><span class="Delimiter">.</span>resize<span class="Delimiter">(</span>new_size<span class="Delimiter">);</span> -<span id="L128" class="LineNr">128 </span> <span class="Delimiter">}</span> -<span id="L129" class="LineNr">129 </span> <span class="Identifier">return</span> <a href='010---vm.cc.html#L105'>_data</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>result_index<span class="Delimiter">);</span> -<span id="L130" class="LineNr">130 </span> <span class="Delimiter">}</span> -<span id="L131" class="LineNr">131 </span> <span class="Normal">void</span> <a href='010---vm.cc.html#L131'>grow_until</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> new_end_address<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L132" class="LineNr">132 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>new_end_address < end<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L133" class="LineNr">133 </span> <span class="Comment">// Ugly: vma knows about the global Memory list of vmas</span> -<span id="L134" class="LineNr">134 </span> <span class="Normal">void</span> <a href='010---vm.cc.html#L141'>sanity_check</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> start<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> end<span class="Delimiter">);</span> -<span id="L135" class="LineNr">135 </span> <a href='010---vm.cc.html#L141'>sanity_check</a><span class="Delimiter">(</span>start<span class="Delimiter">,</span> new_end_address<span class="Delimiter">);</span> -<span id="L136" class="LineNr">136 </span> end = new_end_address<span class="Delimiter">;</span> -<span id="L137" class="LineNr">137 </span> <span class="Delimiter">}</span> -<span id="L138" class="LineNr">138 </span> <span class="Comment">// End vma Methods</span> -<span id="L139" class="LineNr">139 </span><span class="Delimiter">};</span> -<span id="L140" class="LineNr">140 </span><span class="Delimiter">:(code)</span> -<span id="L141" class="LineNr">141 </span><span class="Normal">void</span> <a href='010---vm.cc.html#L141'>sanity_check</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> start<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> end<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L142" class="LineNr">142 </span> <span class="Normal">bool</span> dup_found = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L143" class="LineNr">143 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L144" class="LineNr">144 </span> <span class="Normal">const</span> vma& curr = <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L145" class="LineNr">145 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>start == start<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L146" class="LineNr">146 </span> assert<span class="Delimiter">(</span>!dup_found<span class="Delimiter">);</span> -<span id="L147" class="LineNr">147 </span> dup_found = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L94" class="LineNr"> 94 </span><span class="Comment">// Like in real-world Linux, we'll allocate RAM for our programs in disjoint</span> +<span id="L95" class="LineNr"> 95 </span><span class="Comment">// slabs called VMAs or Virtual Memory Areas.</span> +<span id="L96" class="LineNr"> 96 </span><span class="Normal">struct</span> vma <span class="Delimiter">{</span> +<span id="L97" class="LineNr"> 97 </span> <span class="Normal">uint32_t</span> start<span class="Delimiter">;</span> <span class="Comment">// inclusive</span> +<span id="L98" class="LineNr"> 98 </span> <span class="Normal">uint32_t</span> end<span class="Delimiter">;</span> <span class="Comment">// exclusive</span> +<span id="L99" class="LineNr"> 99 </span> vector<<span class="Normal">uint8_t</span>> <a href='010---vm.cc.html#L99'>_data</a><span class="Delimiter">;</span> +<span id="L100" class="LineNr">100 </span> vma<span class="Delimiter">(</span><span class="Normal">uint32_t</span> s<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> e<span class="Delimiter">)</span> :start<span class="Delimiter">(</span>s<span class="Delimiter">),</span> end<span class="Delimiter">(</span>e<span class="Delimiter">)</span> <span class="Delimiter">{}</span> +<span id="L101" class="LineNr">101 </span> vma<span class="Delimiter">(</span><span class="Normal">uint32_t</span> s<span class="Delimiter">)</span> :start<span class="Delimiter">(</span>s<span class="Delimiter">),</span> end<span class="Delimiter">(</span><a href='010---vm.cc.html#L90'>align_upwards</a><span class="Delimiter">(</span>s+<span class="Constant">1</span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L89'>SEGMENT_ALIGNMENT</a><span class="Delimiter">))</span> <span class="Delimiter">{}</span> +<span id="L102" class="LineNr">102 </span> <span class="Normal">bool</span> <a href='010---vm.cc.html#L102'>match</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> a<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L103" class="LineNr">103 </span> <span class="Identifier">return</span> a >= start && a < end<span class="Delimiter">;</span> +<span id="L104" class="LineNr">104 </span> <span class="Delimiter">}</span> +<span id="L105" class="LineNr">105 </span> <span class="Normal">bool</span> <a href='010---vm.cc.html#L105'>match32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> a<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L106" class="LineNr">106 </span> <span class="Identifier">return</span> a >= start && a+<span class="Constant">4</span> <= end<span class="Delimiter">;</span> +<span id="L107" class="LineNr">107 </span> <span class="Delimiter">}</span> +<span id="L108" class="LineNr">108 </span> <span class="Normal">uint8_t</span>& data<span class="Delimiter">(</span><span class="Normal">uint32_t</span> a<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L109" class="LineNr">109 </span> assert<span class="Delimiter">(</span><a href='010---vm.cc.html#L102'>match</a><span class="Delimiter">(</span>a<span class="Delimiter">));</span> +<span id="L110" class="LineNr">110 </span> <span class="Normal">uint32_t</span> result_index = a-start<span class="Delimiter">;</span> +<span id="L111" class="LineNr">111 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L99'>_data</a><span class="Delimiter">.</span>size<span class="Delimiter">()</span> <= result_index<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L112" class="LineNr">112 </span> <span class="Normal">const</span> <span class="Normal">int</span> align = <span class="Constant">0x1000</span><span class="Delimiter">;</span> +<span id="L113" class="LineNr">113 </span> <span class="Normal">uint32_t</span> result_size = result_index + <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// size needed for result_index to be valid</span> +<span id="L114" class="LineNr">114 </span> <span class="Normal">uint32_t</span> new_size = <a href='010---vm.cc.html#L90'>align_upwards</a><span class="Delimiter">(</span>result_size<span class="Delimiter">,</span> align<span class="Delimiter">);</span> +<span id="L115" class="LineNr">115 </span> <span class="Comment">// grow at least 2x to maintain some amortized complexity guarantees</span> +<span id="L116" class="LineNr">116 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>new_size < <a href='010---vm.cc.html#L99'>_data</a><span class="Delimiter">.</span>size<span class="Delimiter">()</span> * <span class="Constant">2</span><span class="Delimiter">)</span> +<span id="L117" class="LineNr">117 </span> new_size = <a href='010---vm.cc.html#L99'>_data</a><span class="Delimiter">.</span>size<span class="Delimiter">()</span> * <span class="Constant">2</span><span class="Delimiter">;</span> +<span id="L118" class="LineNr">118 </span> <span class="Comment">// never grow past the stated limit</span> +<span id="L119" class="LineNr">119 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>new_size > end-start<span class="Delimiter">)</span> +<span id="L120" class="LineNr">120 </span> new_size = end-start<span class="Delimiter">;</span> +<span id="L121" class="LineNr">121 </span> <a href='010---vm.cc.html#L99'>_data</a><span class="Delimiter">.</span>resize<span class="Delimiter">(</span>new_size<span class="Delimiter">);</span> +<span id="L122" class="LineNr">122 </span> <span class="Delimiter">}</span> +<span id="L123" class="LineNr">123 </span> <span class="Identifier">return</span> <a href='010---vm.cc.html#L99'>_data</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>result_index<span class="Delimiter">);</span> +<span id="L124" class="LineNr">124 </span> <span class="Delimiter">}</span> +<span id="L125" class="LineNr">125 </span> <span class="Normal">void</span> <a href='010---vm.cc.html#L125'>grow_until</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> new_end_address<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L126" class="LineNr">126 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>new_end_address < end<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L127" class="LineNr">127 </span> <span class="Comment">// Ugly: vma knows about the global Memory list of vmas</span> +<span id="L128" class="LineNr">128 </span> <span class="Normal">void</span> <a href='010---vm.cc.html#L135'>sanity_check</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> start<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> end<span class="Delimiter">);</span> +<span id="L129" class="LineNr">129 </span> <a href='010---vm.cc.html#L135'>sanity_check</a><span class="Delimiter">(</span>start<span class="Delimiter">,</span> new_end_address<span class="Delimiter">);</span> +<span id="L130" class="LineNr">130 </span> end = new_end_address<span class="Delimiter">;</span> +<span id="L131" class="LineNr">131 </span> <span class="Delimiter">}</span> +<span id="L132" class="LineNr">132 </span> <span class="Comment">// End vma Methods</span> +<span id="L133" class="LineNr">133 </span><span class="Delimiter">};</span> +<span id="L134" class="LineNr">134 </span><span class="Delimiter">:(code)</span> +<span id="L135" class="LineNr">135 </span><span class="Normal">void</span> <a href='010---vm.cc.html#L135'>sanity_check</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> start<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> end<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L136" class="LineNr">136 </span> <span class="Normal">bool</span> dup_found = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L137" class="LineNr">137 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L138" class="LineNr">138 </span> <span class="Normal">const</span> vma& curr = <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L139" class="LineNr">139 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>start == start<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L140" class="LineNr">140 </span> assert<span class="Delimiter">(</span>!dup_found<span class="Delimiter">);</span> +<span id="L141" class="LineNr">141 </span> dup_found = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L142" class="LineNr">142 </span> <span class="Delimiter">}</span> +<span id="L143" class="LineNr">143 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>start > start<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L144" class="LineNr">144 </span> assert<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>start > end<span class="Delimiter">);</span> +<span id="L145" class="LineNr">145 </span> <span class="Delimiter">}</span> +<span id="L146" class="LineNr">146 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>start < start<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L147" class="LineNr">147 </span> assert<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>end < start<span class="Delimiter">);</span> <span id="L148" class="LineNr">148 </span> <span class="Delimiter">}</span> -<span id="L149" class="LineNr">149 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>start > start<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L150" class="LineNr">150 </span> assert<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>start > end<span class="Delimiter">);</span> -<span id="L151" class="LineNr">151 </span> <span class="Delimiter">}</span> -<span id="L152" class="LineNr">152 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>start < start<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L153" class="LineNr">153 </span> assert<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>end < start<span class="Delimiter">);</span> -<span id="L154" class="LineNr">154 </span> <span class="Delimiter">}</span> -<span id="L155" class="LineNr">155 </span> <span class="Delimiter">}</span> -<span id="L156" class="LineNr">156 </span><span class="Delimiter">}</span> -<span id="L157" class="LineNr">157 </span> -<span id="L158" class="LineNr">158 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L159" class="LineNr">159 </span><span class="Comment">// RAM is made of VMAs.</span> -<span id="L160" class="LineNr">160 </span>vector<vma> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">;</span> -<span id="L161" class="LineNr">161 </span><span class="Delimiter">:(code)</span> -<span id="L162" class="LineNr">162 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L163" class="LineNr">163 </span><span class="Normal">uint32_t</span> <span class="Special"><a href='010---vm.cc.html#L163'>End_of_program</a></span> = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// when the program executes past this address in tests we'll stop the test</span> -<span id="L164" class="LineNr">164 </span><span class="Comment">// The stack grows downward. Can't increase its size for now.</span> -<span id="L165" class="LineNr">165 </span><span class="Delimiter">:(before "End Reset")</span> -<span id="L166" class="LineNr">166 </span><span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>clear<span class="Delimiter">();</span> -<span id="L167" class="LineNr">167 </span><span class="Special"><a href='010---vm.cc.html#L163'>End_of_program</a></span> = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L168" class="LineNr">168 </span><span class="Delimiter">:(code)</span> -<span id="L169" class="LineNr">169 </span><span class="Comment">// These helpers depend on Mem being laid out contiguously (so you can't use a</span> -<span id="L170" class="LineNr">170 </span><span class="Comment">// map, etc.) and on the host also being little-endian.</span> -<span id="L171" class="LineNr">171 </span><span class="Normal">inline</span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L171'>read_mem_u8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L172" class="LineNr">172 </span> <span class="Normal">uint8_t</span>* handle = <a href='010---vm.cc.html#L186'>mem_addr_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> <span class="Comment">// error messages get printed here</span> -<span id="L173" class="LineNr">173 </span> <span class="Identifier">return</span> handle ? *handle : <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L174" class="LineNr">174 </span><span class="Delimiter">}</span> -<span id="L175" class="LineNr">175 </span><span class="Normal">inline</span> <span class="Normal">int8_t</span> <a href='010---vm.cc.html#L175'>read_mem_i8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L176" class="LineNr">176 </span> <span class="Identifier">return</span> <span class="Normal">static_cast</span><<span class="Normal">int8_t</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L171'>read_mem_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> -<span id="L177" class="LineNr">177 </span><span class="Delimiter">}</span> -<span id="L178" class="LineNr">178 </span><span class="Normal">inline</span> <span class="Normal">uint32_t</span> <a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L179" class="LineNr">179 </span> <span class="Normal">uint32_t</span>* handle = <a href='010---vm.cc.html#L205'>mem_addr_u32</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> <span class="Comment">// error messages get printed here</span> -<span id="L180" class="LineNr">180 </span> <span class="Identifier">return</span> handle ? *handle : <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L181" class="LineNr">181 </span><span class="Delimiter">}</span> -<span id="L182" class="LineNr">182 </span><span class="Normal">inline</span> <span class="Normal">int32_t</span> <a href='010---vm.cc.html#L182'>read_mem_i32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L183" class="LineNr">183 </span> <span class="Identifier">return</span> <span class="Normal">static_cast</span><<span class="Normal">int32_t</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> -<span id="L184" class="LineNr">184 </span><span class="Delimiter">}</span> -<span id="L185" class="LineNr">185 </span> -<span id="L186" class="LineNr">186 </span><span class="Normal">inline</span> <span class="Normal">uint8_t</span>* <a href='010---vm.cc.html#L186'>mem_addr_u8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L187" class="LineNr">187 </span> <span class="Normal">uint8_t</span>* result = <span class="Constant">NULL</span><span class="Delimiter">;</span> -<span id="L188" class="LineNr">188 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L189" class="LineNr">189 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='010---vm.cc.html#L108'>match</a><span class="Delimiter">(</span>addr<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L190" class="LineNr">190 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">)</span> -<span id="L191" class="LineNr">191 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"address 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" is in two segments\n"</span> << end<span class="Delimiter">();</span> -<span id="L192" class="LineNr">192 </span> result = &<span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">(</span>addr<span class="Delimiter">);</span> -<span id="L193" class="LineNr">193 </span> <span class="Delimiter">}</span> -<span id="L194" class="LineNr">194 </span> <span class="Delimiter">}</span> -<span id="L195" class="LineNr">195 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L196" class="LineNr">196 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">.</span><a href='011run.cc.html#L199'>flush</a><span class="Delimiter">();</span> -<span id="L197" class="LineNr">197 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"Tried to access uninitialized memory at address 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> -<span id="L198" class="LineNr">198 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L199" class="LineNr">199 </span> <span class="Delimiter">}</span> -<span id="L200" class="LineNr">200 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L201" class="LineNr">201 </span><span class="Delimiter">}</span> -<span id="L202" class="LineNr">202 </span><span class="Normal">inline</span> <span class="Normal">int8_t</span>* <a href='010---vm.cc.html#L202'>mem_addr_i8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L203" class="LineNr">203 </span> <span class="Identifier">return</span> <span class="Normal">reinterpret_cast</span><<span class="Normal">int8_t</span>*><span class="Delimiter">(</span><a href='010---vm.cc.html#L186'>mem_addr_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> -<span id="L204" class="LineNr">204 </span><span class="Delimiter">}</span> -<span id="L205" class="LineNr">205 </span><span class="Normal">inline</span> <span class="Normal">uint32_t</span>* <a href='010---vm.cc.html#L205'>mem_addr_u32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L206" class="LineNr">206 </span> <span class="Normal">uint32_t</span>* result = <span class="Constant">NULL</span><span class="Delimiter">;</span> -<span id="L207" class="LineNr">207 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L208" class="LineNr">208 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='010---vm.cc.html#L111'>match32</a><span class="Delimiter">(</span>addr<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L209" class="LineNr">209 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">)</span> -<span id="L210" class="LineNr">210 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"address 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" is in two segments\n"</span> << end<span class="Delimiter">();</span> -<span id="L211" class="LineNr">211 </span> result = <span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>&<span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">(</span>addr<span class="Delimiter">));</span> -<span id="L212" class="LineNr">212 </span> <span class="Delimiter">}</span> +<span id="L149" class="LineNr">149 </span> <span class="Delimiter">}</span> +<span id="L150" class="LineNr">150 </span><span class="Delimiter">}</span> +<span id="L151" class="LineNr">151 </span> +<span id="L152" class="LineNr">152 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L153" class="LineNr">153 </span><span class="Comment">// RAM is made of VMAs.</span> +<span id="L154" class="LineNr">154 </span>vector<vma> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">;</span> +<span id="L155" class="LineNr">155 </span><span class="Delimiter">:(code)</span> +<span id="L156" class="LineNr">156 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L157" class="LineNr">157 </span><span class="Normal">uint32_t</span> <span class="Special"><a href='010---vm.cc.html#L157'>End_of_program</a></span> = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// when the program executes past this address in tests we'll stop the test</span> +<span id="L158" class="LineNr">158 </span><span class="Comment">// The stack grows downward. Can't increase its size for now.</span> +<span id="L159" class="LineNr">159 </span><span class="Delimiter">:(before "End Reset")</span> +<span id="L160" class="LineNr">160 </span><span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>clear<span class="Delimiter">();</span> +<span id="L161" class="LineNr">161 </span><span class="Special"><a href='010---vm.cc.html#L157'>End_of_program</a></span> = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L162" class="LineNr">162 </span><span class="Delimiter">:(code)</span> +<span id="L163" class="LineNr">163 </span><span class="Comment">// These helpers depend on Mem being laid out contiguously (so you can't use a</span> +<span id="L164" class="LineNr">164 </span><span class="Comment">// map, etc.) and on the host also being little-endian.</span> +<span id="L165" class="LineNr">165 </span><span class="Normal">inline</span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L165'>read_mem_u8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L166" class="LineNr">166 </span> <span class="Normal">uint8_t</span>* handle = <a href='010---vm.cc.html#L180'>mem_addr_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> <span class="Comment">// error messages get printed here</span> +<span id="L167" class="LineNr">167 </span> <span class="Identifier">return</span> handle ? *handle : <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L168" class="LineNr">168 </span><span class="Delimiter">}</span> +<span id="L169" class="LineNr">169 </span><span class="Normal">inline</span> <span class="Normal">int8_t</span> <a href='010---vm.cc.html#L169'>read_mem_i8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L170" class="LineNr">170 </span> <span class="Identifier">return</span> <span class="Normal">static_cast</span><<span class="Normal">int8_t</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L165'>read_mem_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> +<span id="L171" class="LineNr">171 </span><span class="Delimiter">}</span> +<span id="L172" class="LineNr">172 </span><span class="Normal">inline</span> <span class="Normal">uint32_t</span> <a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L173" class="LineNr">173 </span> <span class="Normal">uint32_t</span>* handle = <a href='010---vm.cc.html#L199'>mem_addr_u32</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> <span class="Comment">// error messages get printed here</span> +<span id="L174" class="LineNr">174 </span> <span class="Identifier">return</span> handle ? *handle : <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L175" class="LineNr">175 </span><span class="Delimiter">}</span> +<span id="L176" class="LineNr">176 </span><span class="Normal">inline</span> <span class="Normal">int32_t</span> <a href='010---vm.cc.html#L176'>read_mem_i32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L177" class="LineNr">177 </span> <span class="Identifier">return</span> <span class="Normal">static_cast</span><<span class="Normal">int32_t</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> +<span id="L178" class="LineNr">178 </span><span class="Delimiter">}</span> +<span id="L179" class="LineNr">179 </span> +<span id="L180" class="LineNr">180 </span><span class="Normal">inline</span> <span class="Normal">uint8_t</span>* <a href='010---vm.cc.html#L180'>mem_addr_u8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L181" class="LineNr">181 </span> <span class="Normal">uint8_t</span>* result = <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L182" class="LineNr">182 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L183" class="LineNr">183 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='010---vm.cc.html#L102'>match</a><span class="Delimiter">(</span>addr<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L184" class="LineNr">184 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">)</span> +<span id="L185" class="LineNr">185 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"address 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" is in two segments\n"</span> << end<span class="Delimiter">();</span> +<span id="L186" class="LineNr">186 </span> result = &<span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">(</span>addr<span class="Delimiter">);</span> +<span id="L187" class="LineNr">187 </span> <span class="Delimiter">}</span> +<span id="L188" class="LineNr">188 </span> <span class="Delimiter">}</span> +<span id="L189" class="LineNr">189 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L190" class="LineNr">190 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">.</span><a href='011run.cc.html#L198'>flush</a><span class="Delimiter">();</span> +<span id="L191" class="LineNr">191 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"Tried to access uninitialized memory at address 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L192" class="LineNr">192 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L193" class="LineNr">193 </span> <span class="Delimiter">}</span> +<span id="L194" class="LineNr">194 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L195" class="LineNr">195 </span><span class="Delimiter">}</span> +<span id="L196" class="LineNr">196 </span><span class="Normal">inline</span> <span class="Normal">int8_t</span>* <a href='010---vm.cc.html#L196'>mem_addr_i8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L197" class="LineNr">197 </span> <span class="Identifier">return</span> <span class="Normal">reinterpret_cast</span><<span class="Normal">int8_t</span>*><span class="Delimiter">(</span><a href='010---vm.cc.html#L180'>mem_addr_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> +<span id="L198" class="LineNr">198 </span><span class="Delimiter">}</span> +<span id="L199" class="LineNr">199 </span><span class="Normal">inline</span> <span class="Normal">uint32_t</span>* <a href='010---vm.cc.html#L199'>mem_addr_u32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L200" class="LineNr">200 </span> <span class="Normal">uint32_t</span>* result = <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L201" class="LineNr">201 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L202" class="LineNr">202 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='010---vm.cc.html#L105'>match32</a><span class="Delimiter">(</span>addr<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L203" class="LineNr">203 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">)</span> +<span id="L204" class="LineNr">204 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"address 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" is in two segments\n"</span> << end<span class="Delimiter">();</span> +<span id="L205" class="LineNr">205 </span> result = <span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>&<span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">(</span>addr<span class="Delimiter">));</span> +<span id="L206" class="LineNr">206 </span> <span class="Delimiter">}</span> +<span id="L207" class="LineNr">207 </span> <span class="Delimiter">}</span> +<span id="L208" class="LineNr">208 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L209" class="LineNr">209 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">.</span><a href='011run.cc.html#L198'>flush</a><span class="Delimiter">();</span> +<span id="L210" class="LineNr">210 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"Tried to access uninitialized memory at address 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L211" class="LineNr">211 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"The entire 4-byte <a href='011run.cc.html#L127'>word</a> should be initialized and lie in a single segment.\n"</span> << end<span class="Delimiter">();</span> +<span id="L212" class="LineNr">212 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L213" class="LineNr">213 </span> <span class="Delimiter">}</span> -<span id="L214" class="LineNr">214 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L215" class="LineNr">215 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">.</span><a href='011run.cc.html#L199'>flush</a><span class="Delimiter">();</span> -<span id="L216" class="LineNr">216 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"Tried to access uninitialized memory at address 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> -<span id="L217" class="LineNr">217 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"The entire 4-byte <a href='011run.cc.html#L128'>word</a> should be initialized and lie in a single segment.\n"</span> << end<span class="Delimiter">();</span> -<span id="L218" class="LineNr">218 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L219" class="LineNr">219 </span> <span class="Delimiter">}</span> -<span id="L220" class="LineNr">220 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L221" class="LineNr">221 </span><span class="Delimiter">}</span> -<span id="L222" class="LineNr">222 </span><span class="Normal">inline</span> <span class="Normal">int32_t</span>* <a href='010---vm.cc.html#L222'>mem_addr_i32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L223" class="LineNr">223 </span> <span class="Identifier">return</span> <span class="Normal">reinterpret_cast</span><<span class="Normal">int32_t</span>*><span class="Delimiter">(</span><a href='010---vm.cc.html#L205'>mem_addr_u32</a><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> -<span id="L224" class="LineNr">224 </span><span class="Delimiter">}</span> -<span id="L225" class="LineNr">225 </span><span class="Comment">// helper for some syscalls. But read-only.</span> -<span id="L226" class="LineNr">226 </span><span class="Normal">inline</span> <span class="Normal">const</span> <span class="Normal">char</span>* <a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L227" class="LineNr">227 </span> <span class="Identifier">return</span> <span class="Normal">reinterpret_cast</span><<span class="Normal">const</span> <span class="Normal">char</span>*><span class="Delimiter">(</span><a href='010---vm.cc.html#L186'>mem_addr_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> +<span id="L214" class="LineNr">214 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L215" class="LineNr">215 </span><span class="Delimiter">}</span> +<span id="L216" class="LineNr">216 </span><span class="Normal">inline</span> <span class="Normal">int32_t</span>* <a href='010---vm.cc.html#L216'>mem_addr_i32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L217" class="LineNr">217 </span> <span class="Identifier">return</span> <span class="Normal">reinterpret_cast</span><<span class="Normal">int32_t</span>*><span class="Delimiter">(</span><a href='010---vm.cc.html#L199'>mem_addr_u32</a><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> +<span id="L218" class="LineNr">218 </span><span class="Delimiter">}</span> +<span id="L219" class="LineNr">219 </span><span class="Comment">// helper for some syscalls. But read-only.</span> +<span id="L220" class="LineNr">220 </span><span class="Normal">inline</span> <span class="Normal">const</span> <span class="Normal">char</span>* <a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L221" class="LineNr">221 </span> <span class="Identifier">return</span> <span class="Normal">reinterpret_cast</span><<span class="Normal">const</span> <span class="Normal">char</span>*><span class="Delimiter">(</span><a href='010---vm.cc.html#L180'>mem_addr_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">));</span> +<span id="L222" class="LineNr">222 </span><span class="Delimiter">}</span> +<span id="L223" class="LineNr">223 </span><span class="Normal">inline</span> string <a href='010---vm.cc.html#L223'>mem_addr_string</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> size<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L224" class="LineNr">224 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L225" class="LineNr">225 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> +<span id="L226" class="LineNr">226 </span> out << <a href='010---vm.cc.html#L165'>read_mem_u8</a><span class="Delimiter">(</span>addr+i<span class="Delimiter">);</span> +<span id="L227" class="LineNr">227 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span id="L228" class="LineNr">228 </span><span class="Delimiter">}</span> -<span id="L229" class="LineNr">229 </span><span class="Normal">inline</span> string <a href='010---vm.cc.html#L229'>mem_addr_string</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> size<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L230" class="LineNr">230 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L231" class="LineNr">231 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < size<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> -<span id="L232" class="LineNr">232 </span> out << <a href='010---vm.cc.html#L171'>read_mem_u8</a><span class="Delimiter">(</span>addr+i<span class="Delimiter">);</span> -<span id="L233" class="LineNr">233 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L229" class="LineNr">229 </span> +<span id="L230" class="LineNr">230 </span> +<span id="L231" class="LineNr">231 </span><span class="Normal">inline</span> <span class="Normal">void</span> <a href='010---vm.cc.html#L231'>write_mem_u8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">,</span> <span class="Normal">uint8_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L232" class="LineNr">232 </span> <span class="Normal">uint8_t</span>* handle = <a href='010---vm.cc.html#L180'>mem_addr_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> +<span id="L233" class="LineNr">233 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>handle != <span class="Constant">NULL</span><span class="Delimiter">)</span> *handle = val<span class="Delimiter">;</span> <span id="L234" class="LineNr">234 </span><span class="Delimiter">}</span> -<span id="L235" class="LineNr">235 </span> -<span id="L236" class="LineNr">236 </span> -<span id="L237" class="LineNr">237 </span><span class="Normal">inline</span> <span class="Normal">void</span> <a href='010---vm.cc.html#L237'>write_mem_u8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">,</span> <span class="Normal">uint8_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L238" class="LineNr">238 </span> <span class="Normal">uint8_t</span>* handle = <a href='010---vm.cc.html#L186'>mem_addr_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> -<span id="L239" class="LineNr">239 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>handle != <span class="Constant">NULL</span><span class="Delimiter">)</span> *handle = val<span class="Delimiter">;</span> -<span id="L240" class="LineNr">240 </span><span class="Delimiter">}</span> -<span id="L241" class="LineNr">241 </span><span class="Normal">inline</span> <span class="Normal">void</span> <a href='010---vm.cc.html#L241'>write_mem_i8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">,</span> <span class="Normal">int8_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L242" class="LineNr">242 </span> <span class="Normal">int8_t</span>* handle = <a href='010---vm.cc.html#L202'>mem_addr_i8</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> -<span id="L243" class="LineNr">243 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>handle != <span class="Constant">NULL</span><span class="Delimiter">)</span> *handle = val<span class="Delimiter">;</span> -<span id="L244" class="LineNr">244 </span><span class="Delimiter">}</span> -<span id="L245" class="LineNr">245 </span><span class="Normal">inline</span> <span class="Normal">void</span> <a href='010---vm.cc.html#L245'>write_mem_u32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L246" class="LineNr">246 </span> <span class="Normal">uint32_t</span>* handle = <a href='010---vm.cc.html#L205'>mem_addr_u32</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> -<span id="L247" class="LineNr">247 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>handle != <span class="Constant">NULL</span><span class="Delimiter">)</span> *handle = val<span class="Delimiter">;</span> -<span id="L248" class="LineNr">248 </span><span class="Delimiter">}</span> -<span id="L249" class="LineNr">249 </span><span class="Normal">inline</span> <span class="Normal">void</span> <a href='010---vm.cc.html#L249'>write_mem_i32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">,</span> <span class="Normal">int32_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L250" class="LineNr">250 </span> <span class="Normal">int32_t</span>* handle = <a href='010---vm.cc.html#L222'>mem_addr_i32</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> -<span id="L251" class="LineNr">251 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>handle != <span class="Constant">NULL</span><span class="Delimiter">)</span> *handle = val<span class="Delimiter">;</span> -<span id="L252" class="LineNr">252 </span><span class="Delimiter">}</span> -<span id="L253" class="LineNr">253 </span> -<span id="L254" class="LineNr">254 </span><span class="Normal">inline</span> <span class="Normal">bool</span> <a href='010---vm.cc.html#L254'>already_allocated</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L255" class="LineNr">255 </span> <span class="Normal">bool</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L256" class="LineNr">256 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L257" class="LineNr">257 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='010---vm.cc.html#L108'>match</a><span class="Delimiter">(</span>addr<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L258" class="LineNr">258 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">)</span> -<span id="L259" class="LineNr">259 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"address 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" is in two segments\n"</span> << end<span class="Delimiter">();</span> -<span id="L260" class="LineNr">260 </span> result = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L261" class="LineNr">261 </span> <span class="Delimiter">}</span> -<span id="L262" class="LineNr">262 </span> <span class="Delimiter">}</span> -<span id="L263" class="LineNr">263 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L264" class="LineNr">264 </span><span class="Delimiter">}</span> -<span id="L265" class="LineNr">265 </span> -<span id="L266" class="LineNr">266 </span><span class="SalientComment">//:: core interpreter loop</span> -<span id="L267" class="LineNr">267 </span> -<span id="L268" class="LineNr">268 </span><span class="Delimiter">:(code)</span> -<span id="L269" class="LineNr">269 </span><span class="Comment">// skeleton of how x86 instructions are decoded</span> -<span id="L270" class="LineNr">270 </span><span class="Normal">void</span> <a href='010---vm.cc.html#L270'>run_one_instruction</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L271" class="LineNr">271 </span> <span class="Normal">uint8_t</span> op=<span class="Constant">0</span><span class="Delimiter">,</span> op2=<span class="Constant">0</span><span class="Delimiter">,</span> op3=<span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L272" class="LineNr">272 </span> <span class="Comment">// Run One Instruction</span> -<span id="L273" class="LineNr">273 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L274" class="LineNr">274 </span> <a href='010---vm.cc.html#L335'>dump_registers</a><span class="Delimiter">();</span> -<span id="L275" class="LineNr">275 </span> <span class="Comment">// End Dump Info for Instruction</span> -<span id="L276" class="LineNr">276 </span> <span class="Delimiter">}</span> -<span id="L277" class="LineNr">277 </span> <span class="Normal">uint32_t</span> inst_start_address = <a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">;</span> -<span id="L278" class="LineNr">278 </span> op = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> -<span id="L279" class="LineNr">279 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << inst_start_address << <span class="Constant">" opcode: "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>op<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L280" class="LineNr">280 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>op<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L281" class="LineNr">281 </span> <span class="Normal">case</span> <span class="Constant">0xf4</span>: <span class="Comment">// hlt</span> -<span id="L282" class="LineNr">282 </span> <a href='010---vm.cc.html#L32'>EIP</a> = <span class="Special"><a href='010---vm.cc.html#L163'>End_of_program</a></span><span class="Delimiter">;</span> -<span id="L283" class="LineNr">283 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L284" class="LineNr">284 </span> <span class="Comment">// End Single-Byte Opcodes</span> -<span id="L285" class="LineNr">285 </span> <span class="Normal">case</span> <span class="Constant">0x0f</span>: -<span id="L286" class="LineNr">286 </span> <span class="Normal">switch</span><span class="Delimiter">(</span>op2 = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L287" class="LineNr">287 </span> <span class="Comment">// End Two-Byte Opcodes Starting With 0f</span> -<span id="L288" class="LineNr">288 </span> <span class="Normal">default</span>: -<span id="L289" class="LineNr">289 </span> cerr << <span class="Constant">"unrecognized second opcode after 0f: "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>op2<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L290" class="LineNr">290 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L291" class="LineNr">291 </span> <span class="Delimiter">}</span> -<span id="L292" class="LineNr">292 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L293" class="LineNr">293 </span> <span class="Normal">case</span> <span class="Constant">0xf2</span>: -<span id="L294" class="LineNr">294 </span> <span class="Normal">switch</span><span class="Delimiter">(</span>op2 = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L295" class="LineNr">295 </span> <span class="Comment">// End Two-Byte Opcodes Starting With f2</span> -<span id="L296" class="LineNr">296 </span> <span class="Normal">case</span> <span class="Constant">0x0f</span>: -<span id="L297" class="LineNr">297 </span> <span class="Normal">switch</span><span class="Delimiter">(</span>op3 = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L298" class="LineNr">298 </span> <span class="Comment">// End Three-Byte Opcodes Starting With f2 0f</span> -<span id="L299" class="LineNr">299 </span> <span class="Normal">default</span>: -<span id="L300" class="LineNr">300 </span> cerr << <span class="Constant">"unrecognized third opcode after f2 0f: "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>op3<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L301" class="LineNr">301 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L302" class="LineNr">302 </span> <span class="Delimiter">}</span> -<span id="L303" class="LineNr">303 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L304" class="LineNr">304 </span> <span class="Normal">default</span>: -<span id="L305" class="LineNr">305 </span> cerr << <span class="Constant">"unrecognized second opcode after f2: "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>op2<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L306" class="LineNr">306 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L307" class="LineNr">307 </span> <span class="Delimiter">}</span> -<span id="L308" class="LineNr">308 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L309" class="LineNr">309 </span> <span class="Normal">case</span> <span class="Constant">0xf3</span>: -<span id="L310" class="LineNr">310 </span> <span class="Normal">switch</span><span class="Delimiter">(</span>op2 = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L311" class="LineNr">311 </span> <span class="Comment">// End Two-Byte Opcodes Starting With f3</span> -<span id="L312" class="LineNr">312 </span> <span class="Normal">case</span> <span class="Constant">0x0f</span>: -<span id="L313" class="LineNr">313 </span> <span class="Normal">switch</span><span class="Delimiter">(</span>op3 = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L314" class="LineNr">314 </span> <span class="Comment">// End Three-Byte Opcodes Starting With f3 0f</span> -<span id="L315" class="LineNr">315 </span> <span class="Normal">default</span>: -<span id="L316" class="LineNr">316 </span> cerr << <span class="Constant">"unrecognized third opcode after f3 0f: "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>op3<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L317" class="LineNr">317 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L318" class="LineNr">318 </span> <span class="Delimiter">}</span> -<span id="L319" class="LineNr">319 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L320" class="LineNr">320 </span> <span class="Normal">default</span>: -<span id="L321" class="LineNr">321 </span> cerr << <span class="Constant">"unrecognized second opcode after f3: "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>op2<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L322" class="LineNr">322 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L323" class="LineNr">323 </span> <span class="Delimiter">}</span> -<span id="L324" class="LineNr">324 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L325" class="LineNr">325 </span> <span class="Normal">default</span>: -<span id="L326" class="LineNr">326 </span> cerr << <span class="Constant">"unrecognized opcode: "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>op<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L327" class="LineNr">327 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L328" class="LineNr">328 </span> <span class="Delimiter">}</span> -<span id="L329" class="LineNr">329 </span><span class="Delimiter">}</span> -<span id="L330" class="LineNr">330 </span> -<span id="L331" class="LineNr">331 </span><span class="Normal">inline</span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L332" class="LineNr">332 </span> <span class="Identifier">return</span> <a href='010---vm.cc.html#L171'>read_mem_u8</a><span class="Delimiter">(</span>EIP++<span class="Delimiter">);</span> -<span id="L333" class="LineNr">333 </span><span class="Delimiter">}</span> -<span id="L334" class="LineNr">334 </span> -<span id="L335" class="LineNr">335 </span><span class="Normal">void</span> <a href='010---vm.cc.html#L335'>dump_registers</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L336" class="LineNr">336 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L337" class="LineNr">337 </span> out << <span class="Constant">"registers before: "</span><span class="Delimiter">;</span> -<span id="L338" class="LineNr">338 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='010---vm.cc.html#L24'>NUM_INT_REGISTERS</a><span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L339" class="LineNr">339 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">"; "</span><span class="Delimiter">;</span> -<span id="L340" class="LineNr">340 </span> out << <span class="Constant">" "</span> << i << <span class="Constant">": "</span> << std::hex << std::setw<span class="Delimiter">(</span><span class="Constant">8</span><span class="Delimiter">)</span> << std::setfill<span class="Delimiter">(</span><span class="Constant">'_'</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[i]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L341" class="LineNr">341 </span> <span class="Delimiter">}</span> -<span id="L342" class="LineNr">342 </span> out << <span class="Constant">" -- SF: "</span> << SF << <span class="Constant">"; <a href='010---vm.cc.html#L86'>ZF</a>: "</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; <a href='010---vm.cc.html#L87'>CF</a>: "</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; <a href='010---vm.cc.html#L88'>OF</a>: "</span> << <a href='010---vm.cc.html#L88'>OF</a><span class="Delimiter">;</span> -<span id="L343" class="LineNr">343 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << out<span class="Delimiter">.</span>str<span class="Delimiter">()</span> << end<span class="Delimiter">();</span> -<span id="L344" class="LineNr">344 </span><span class="Delimiter">}</span> -<span id="L345" class="LineNr">345 </span> -<span id="L346" class="LineNr">346 </span><span class="Comment">//: start tracking supported opcodes</span> -<span id="L347" class="LineNr">347 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L348" class="LineNr">348 </span>map<<span class="Comment">/*</span><span class="Comment">op</span><span class="Comment">*/</span>string<span class="Delimiter">,</span> string> <span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">;</span> -<span id="L349" class="LineNr">349 </span>map<<span class="Comment">/*</span><span class="Comment">op</span><span class="Comment">*/</span>string<span class="Delimiter">,</span> string> <span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">;</span> -<span id="L350" class="LineNr">350 </span>map<<span class="Comment">/*</span><span class="Comment">op</span><span class="Comment">*/</span>string<span class="Delimiter">,</span> string> <span class="Special"><a href='010---vm.cc.html#L350'>Name_f3</a></span><span class="Delimiter">;</span> -<span id="L351" class="LineNr">351 </span>map<<span class="Comment">/*</span><span class="Comment">op</span><span class="Comment">*/</span>string<span class="Delimiter">,</span> string> <span class="Special"><a href='010---vm.cc.html#L351'>Name_f3_0f</a></span><span class="Delimiter">;</span> -<span id="L352" class="LineNr">352 </span><span class="Delimiter">:(before "End One-time Setup")</span> -<span id="L353" class="LineNr">353 </span><a href='010---vm.cc.html#L355'>init_op_names</a><span class="Delimiter">();</span> -<span id="L354" class="LineNr">354 </span><span class="Delimiter">:(code)</span> -<span id="L355" class="LineNr">355 </span><span class="Normal">void</span> <a href='010---vm.cc.html#L355'>init_op_names</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L356" class="LineNr">356 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"f4"</span><span class="Delimiter">,</span> <span class="Constant">"halt (hlt)"</span><span class="Delimiter">);</span> -<span id="L357" class="LineNr">357 </span> <span class="Comment">// End Initialize Op Names</span> -<span id="L358" class="LineNr">358 </span><span class="Delimiter">}</span> -<span id="L359" class="LineNr">359 </span> -<span id="L360" class="LineNr">360 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Special-cases(key)")</span> -<span id="L361" class="LineNr">361 </span><span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">"opcodes"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L362" class="LineNr">362 </span> cerr << <span class="Constant">"Opcodes currently supported by SubX:\n"</span><span class="Delimiter">;</span> -<span id="L363" class="LineNr">363 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> string>::iterator p = <span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> -<span id="L364" class="LineNr">364 </span> cerr << <span class="Constant">" "</span> << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L365" class="LineNr">365 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> string>::iterator p = <span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> -<span id="L366" class="LineNr">366 </span> cerr << <span class="Constant">" 0f "</span> << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L367" class="LineNr">367 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> string>::iterator p = <span class="Special"><a href='010---vm.cc.html#L350'>Name_f3</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='010---vm.cc.html#L350'>Name_f3</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> -<span id="L368" class="LineNr">368 </span> cerr << <span class="Constant">" f3 "</span> << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L369" class="LineNr">369 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> string>::iterator p = <span class="Special"><a href='010---vm.cc.html#L351'>Name_f3_0f</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='010---vm.cc.html#L351'>Name_f3_0f</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> -<span id="L370" class="LineNr">370 </span> cerr << <span class="Constant">" f3 0f "</span> << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L371" class="LineNr">371 </span> cerr << <span class="Constant">"Run `subx help instructions` for details on <a href='011run.cc.html#L123'>words</a> like 'r32' and 'disp8'.\n"</span> -<span id="L372" class="LineNr">372 </span> <span class="Constant">"For complete details on these instructions, consult the IA-32 manual (volume 2).\n"</span> -<span id="L373" class="LineNr">373 </span> <span class="Constant">"There's various versions of it online, such as <a href="https://c9x.me/x86.">https://c9x.me/x86.</a>\n"</span> -<span id="L374" class="LineNr">374 </span> <span class="Constant">"The mnemonics in brackets will help you locate each instruction.\n"</span><span class="Delimiter">;</span> -<span id="L375" class="LineNr">375 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L376" class="LineNr">376 </span><span class="Delimiter">}</span> -<span id="L377" class="LineNr">377 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Contents")</span> -<span id="L378" class="LineNr">378 </span>cerr << <span class="Constant">" opcodes\n"</span><span class="Delimiter">;</span> -<span id="L379" class="LineNr">379 </span> -<span id="L380" class="LineNr">380 </span><span class="Comment">//: Helpers for managing trace depths</span> -<span id="L381" class="LineNr">381 </span><span class="Comment">//:</span> -<span id="L382" class="LineNr">382 </span><span class="Comment">//: We're going to use trace depths primarily to segment code running at</span> -<span id="L383" class="LineNr">383 </span><span class="Comment">//: different frames of the call stack. This will make it easy for the trace</span> -<span id="L384" class="LineNr">384 </span><span class="Comment">//: browser to collapse over entire calls.</span> -<span id="L385" class="LineNr">385 </span><span class="Comment">//:</span> -<span id="L386" class="LineNr">386 </span><span class="Comment">//: Errors will be at depth 0.</span> -<span id="L387" class="LineNr">387 </span><span class="Comment">//: Warnings will be at depth 1.</span> -<span id="L388" class="LineNr">388 </span><span class="Comment">//: SubX instructions will occupy depth 2 and up to Max_depth, organized by</span> -<span id="L389" class="LineNr">389 </span><span class="Comment">//: stack frames. Each instruction's internal details will be one level deeper</span> -<span id="L390" class="LineNr">390 </span><span class="Comment">//: than its 'main' depth. So 'call' instruction details will be at the same</span> -<span id="L391" class="LineNr">391 </span><span class="Comment">//: depth as the instructions of the function it calls.</span> -<span id="L392" class="LineNr">392 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L393" class="LineNr">393 </span><span class="Normal">extern</span> <span class="Normal">const</span> <span class="Normal">int</span> <span class="Special"><a href='010---vm.cc.html#L393'>Initial_callstack_depth</a></span> = <span class="Constant">2</span><span class="Delimiter">;</span> -<span id="L394" class="LineNr">394 </span><span class="Normal">int</span> <span class="Special">Callstack_depth</span> = <span class="Special"><a href='010---vm.cc.html#L393'>Initial_callstack_depth</a></span><span class="Delimiter">;</span> -<span id="L395" class="LineNr">395 </span><span class="Delimiter">:(before "End Reset")</span> -<span id="L396" class="LineNr">396 </span><span class="Special">Callstack_depth</span> = <span class="Special"><a href='010---vm.cc.html#L393'>Initial_callstack_depth</a></span><span class="Delimiter">;</span> -<span id="L397" class="LineNr">397 </span> -<span id="L398" class="LineNr">398 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L399" class="LineNr">399 </span><span class="PreProc">#include </span><span class="Constant"><iomanip></span> -<span id="L400" class="LineNr">400 </span><span class="PreProc">#define HEXBYTE std::hex << std::setw(</span><span class="Constant">2</span><span class="PreProc">) << std::setfill(</span><span class="Constant">'0'</span><span class="PreProc">)</span> -<span id="L401" class="LineNr">401 </span><span class="PreProc">#define HEXWORD std::hex << std::setw(</span><span class="Constant">8</span><span class="PreProc">) << std::setfill(</span><span class="Constant">'0'</span><span class="PreProc">)</span> -<span id="L402" class="LineNr">402 </span><span class="Comment">// ugly that iostream doesn't print uint8_t as an integer</span> -<span id="L403" class="LineNr">403 </span><span class="PreProc">#define NUM(</span><span class="Special">X</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 id="L404" class="LineNr">404 </span><span class="PreProc">#include </span><span class="Constant"><stdint.h></span> +<span id="L235" class="LineNr">235 </span><span class="Normal">inline</span> <span class="Normal">void</span> <a href='010---vm.cc.html#L235'>write_mem_i8</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">,</span> <span class="Normal">int8_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L236" class="LineNr">236 </span> <span class="Normal">int8_t</span>* handle = <a href='010---vm.cc.html#L196'>mem_addr_i8</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> +<span id="L237" class="LineNr">237 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>handle != <span class="Constant">NULL</span><span class="Delimiter">)</span> *handle = val<span class="Delimiter">;</span> +<span id="L238" class="LineNr">238 </span><span class="Delimiter">}</span> +<span id="L239" class="LineNr">239 </span><span class="Normal">inline</span> <span class="Normal">void</span> <a href='010---vm.cc.html#L239'>write_mem_u32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L240" class="LineNr">240 </span> <span class="Normal">uint32_t</span>* handle = <a href='010---vm.cc.html#L199'>mem_addr_u32</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> +<span id="L241" class="LineNr">241 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>handle != <span class="Constant">NULL</span><span class="Delimiter">)</span> *handle = val<span class="Delimiter">;</span> +<span id="L242" class="LineNr">242 </span><span class="Delimiter">}</span> +<span id="L243" class="LineNr">243 </span><span class="Normal">inline</span> <span class="Normal">void</span> <a href='010---vm.cc.html#L243'>write_mem_i32</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">,</span> <span class="Normal">int32_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L244" class="LineNr">244 </span> <span class="Normal">int32_t</span>* handle = <a href='010---vm.cc.html#L216'>mem_addr_i32</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> +<span id="L245" class="LineNr">245 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>handle != <span class="Constant">NULL</span><span class="Delimiter">)</span> *handle = val<span class="Delimiter">;</span> +<span id="L246" class="LineNr">246 </span><span class="Delimiter">}</span> +<span id="L247" class="LineNr">247 </span> +<span id="L248" class="LineNr">248 </span><span class="Normal">inline</span> <span class="Normal">bool</span> <a href='010---vm.cc.html#L248'>already_allocated</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L249" class="LineNr">249 </span> <span class="Normal">bool</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L250" class="LineNr">250 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L251" class="LineNr">251 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='010---vm.cc.html#L102'>match</a><span class="Delimiter">(</span>addr<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L252" class="LineNr">252 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">)</span> +<span id="L253" class="LineNr">253 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"address 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" is in two segments\n"</span> << end<span class="Delimiter">();</span> +<span id="L254" class="LineNr">254 </span> result = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L255" class="LineNr">255 </span> <span class="Delimiter">}</span> +<span id="L256" class="LineNr">256 </span> <span class="Delimiter">}</span> +<span id="L257" class="LineNr">257 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L258" class="LineNr">258 </span><span class="Delimiter">}</span> +<span id="L259" class="LineNr">259 </span> +<span id="L260" class="LineNr">260 </span><span class="SalientComment">//:: core interpreter loop</span> +<span id="L261" class="LineNr">261 </span> +<span id="L262" class="LineNr">262 </span><span class="Delimiter">:(code)</span> +<span id="L263" class="LineNr">263 </span><span class="Comment">// skeleton of how x86 instructions are decoded</span> +<span id="L264" class="LineNr">264 </span><span class="Normal">void</span> <a href='010---vm.cc.html#L264'>run_one_instruction</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L265" class="LineNr">265 </span> <span class="Normal">uint8_t</span> op=<span class="Constant">0</span><span class="Delimiter">,</span> op2=<span class="Constant">0</span><span class="Delimiter">,</span> op3=<span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L266" class="LineNr">266 </span> <span class="Comment">// Run One Instruction</span> +<span id="L267" class="LineNr">267 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L268" class="LineNr">268 </span> <a href='010---vm.cc.html#L329'>dump_registers</a><span class="Delimiter">();</span> +<span id="L269" class="LineNr">269 </span> <span class="Comment">// End Dump Info for Instruction</span> +<span id="L270" class="LineNr">270 </span> <span class="Delimiter">}</span> +<span id="L271" class="LineNr">271 </span> <span class="Normal">uint32_t</span> inst_start_address = <a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">;</span> +<span id="L272" class="LineNr">272 </span> op = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> +<span id="L273" class="LineNr">273 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << inst_start_address << <span class="Constant">" opcode: "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>op<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L274" class="LineNr">274 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>op<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L275" class="LineNr">275 </span> <span class="Normal">case</span> <span class="Constant">0xf4</span>: <span class="Comment">// hlt</span> +<span id="L276" class="LineNr">276 </span> <a href='010---vm.cc.html#L26'>EIP</a> = <span class="Special"><a href='010---vm.cc.html#L157'>End_of_program</a></span><span class="Delimiter">;</span> +<span id="L277" class="LineNr">277 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L278" class="LineNr">278 </span> <span class="Comment">// End Single-Byte Opcodes</span> +<span id="L279" class="LineNr">279 </span> <span class="Normal">case</span> <span class="Constant">0x0f</span>: +<span id="L280" class="LineNr">280 </span> <span class="Normal">switch</span><span class="Delimiter">(</span>op2 = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L281" class="LineNr">281 </span> <span class="Comment">// End Two-Byte Opcodes Starting With 0f</span> +<span id="L282" class="LineNr">282 </span> <span class="Normal">default</span>: +<span id="L283" class="LineNr">283 </span> cerr << <span class="Constant">"unrecognized second opcode after 0f: "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>op2<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L284" class="LineNr">284 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L285" class="LineNr">285 </span> <span class="Delimiter">}</span> +<span id="L286" class="LineNr">286 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L287" class="LineNr">287 </span> <span class="Normal">case</span> <span class="Constant">0xf2</span>: +<span id="L288" class="LineNr">288 </span> <span class="Normal">switch</span><span class="Delimiter">(</span>op2 = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L289" class="LineNr">289 </span> <span class="Comment">// End Two-Byte Opcodes Starting With f2</span> +<span id="L290" class="LineNr">290 </span> <span class="Normal">case</span> <span class="Constant">0x0f</span>: +<span id="L291" class="LineNr">291 </span> <span class="Normal">switch</span><span class="Delimiter">(</span>op3 = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L292" class="LineNr">292 </span> <span class="Comment">// End Three-Byte Opcodes Starting With f2 0f</span> +<span id="L293" class="LineNr">293 </span> <span class="Normal">default</span>: +<span id="L294" class="LineNr">294 </span> cerr << <span class="Constant">"unrecognized third opcode after f2 0f: "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>op3<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L295" class="LineNr">295 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L296" class="LineNr">296 </span> <span class="Delimiter">}</span> +<span id="L297" class="LineNr">297 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L298" class="LineNr">298 </span> <span class="Normal">default</span>: +<span id="L299" class="LineNr">299 </span> cerr << <span class="Constant">"unrecognized second opcode after f2: "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>op2<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L300" class="LineNr">300 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L301" class="LineNr">301 </span> <span class="Delimiter">}</span> +<span id="L302" class="LineNr">302 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L303" class="LineNr">303 </span> <span class="Normal">case</span> <span class="Constant">0xf3</span>: +<span id="L304" class="LineNr">304 </span> <span class="Normal">switch</span><span class="Delimiter">(</span>op2 = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L305" class="LineNr">305 </span> <span class="Comment">// End Two-Byte Opcodes Starting With f3</span> +<span id="L306" class="LineNr">306 </span> <span class="Normal">case</span> <span class="Constant">0x0f</span>: +<span id="L307" class="LineNr">307 </span> <span class="Normal">switch</span><span class="Delimiter">(</span>op3 = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L308" class="LineNr">308 </span> <span class="Comment">// End Three-Byte Opcodes Starting With f3 0f</span> +<span id="L309" class="LineNr">309 </span> <span class="Normal">default</span>: +<span id="L310" class="LineNr">310 </span> cerr << <span class="Constant">"unrecognized third opcode after f3 0f: "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>op3<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L311" class="LineNr">311 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L312" class="LineNr">312 </span> <span class="Delimiter">}</span> +<span id="L313" class="LineNr">313 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L314" class="LineNr">314 </span> <span class="Normal">default</span>: +<span id="L315" class="LineNr">315 </span> cerr << <span class="Constant">"unrecognized second opcode after f3: "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>op2<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L316" class="LineNr">316 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L317" class="LineNr">317 </span> <span class="Delimiter">}</span> +<span id="L318" class="LineNr">318 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L319" class="LineNr">319 </span> <span class="Normal">default</span>: +<span id="L320" class="LineNr">320 </span> cerr << <span class="Constant">"unrecognized opcode: "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>op<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L321" class="LineNr">321 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L322" class="LineNr">322 </span> <span class="Delimiter">}</span> +<span id="L323" class="LineNr">323 </span><span class="Delimiter">}</span> +<span id="L324" class="LineNr">324 </span> +<span id="L325" class="LineNr">325 </span><span class="Normal">inline</span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L326" class="LineNr">326 </span> <span class="Identifier">return</span> <a href='010---vm.cc.html#L165'>read_mem_u8</a><span class="Delimiter">(</span>EIP++<span class="Delimiter">);</span> +<span id="L327" class="LineNr">327 </span><span class="Delimiter">}</span> +<span id="L328" class="LineNr">328 </span> +<span id="L329" class="LineNr">329 </span><span class="Normal">void</span> <a href='010---vm.cc.html#L329'>dump_registers</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L330" class="LineNr">330 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L331" class="LineNr">331 </span> out << <span class="Constant">"regs: "</span><span class="Delimiter">;</span> +<span id="L332" class="LineNr">332 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='010---vm.cc.html#L18'>NUM_INT_REGISTERS</a><span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L333" class="LineNr">333 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">" "</span><span class="Delimiter">;</span> +<span id="L334" class="LineNr">334 </span> out << i << <span class="Constant">": "</span> << std::hex << std::setw<span class="Delimiter">(</span><span class="Constant">8</span><span class="Delimiter">)</span> << std::setfill<span class="Delimiter">(</span><span class="Constant">'_'</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[i]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L335" class="LineNr">335 </span> <span class="Delimiter">}</span> +<span id="L336" class="LineNr">336 </span> out << <span class="Constant">" -- SF: "</span> << SF << <span class="Constant">"; <a href='010---vm.cc.html#L80'>ZF</a>: "</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; <a href='010---vm.cc.html#L81'>CF</a>: "</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; <a href='010---vm.cc.html#L82'>OF</a>: "</span> << <a href='010---vm.cc.html#L82'>OF</a><span class="Delimiter">;</span> +<span id="L337" class="LineNr">337 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << out<span class="Delimiter">.</span>str<span class="Delimiter">()</span> << end<span class="Delimiter">();</span> +<span id="L338" class="LineNr">338 </span><span class="Delimiter">}</span> +<span id="L339" class="LineNr">339 </span> +<span id="L340" class="LineNr">340 </span><span class="Comment">//: start tracking supported opcodes</span> +<span id="L341" class="LineNr">341 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L342" class="LineNr">342 </span>map<<span class="Comment">/*</span><span class="Comment">op</span><span class="Comment">*/</span>string<span class="Delimiter">,</span> string> <span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">;</span> +<span id="L343" class="LineNr">343 </span>map<<span class="Comment">/*</span><span class="Comment">op</span><span class="Comment">*/</span>string<span class="Delimiter">,</span> string> <span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">;</span> +<span id="L344" class="LineNr">344 </span>map<<span class="Comment">/*</span><span class="Comment">op</span><span class="Comment">*/</span>string<span class="Delimiter">,</span> string> <span class="Special"><a href='010---vm.cc.html#L344'>Name_f3</a></span><span class="Delimiter">;</span> +<span id="L345" class="LineNr">345 </span>map<<span class="Comment">/*</span><span class="Comment">op</span><span class="Comment">*/</span>string<span class="Delimiter">,</span> string> <span class="Special"><a href='010---vm.cc.html#L345'>Name_f3_0f</a></span><span class="Delimiter">;</span> +<span id="L346" class="LineNr">346 </span><span class="Delimiter">:(before "End One-time Setup")</span> +<span id="L347" class="LineNr">347 </span><a href='010---vm.cc.html#L349'>init_op_names</a><span class="Delimiter">();</span> +<span id="L348" class="LineNr">348 </span><span class="Delimiter">:(code)</span> +<span id="L349" class="LineNr">349 </span><span class="Normal">void</span> <a href='010---vm.cc.html#L349'>init_op_names</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L350" class="LineNr">350 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"f4"</span><span class="Delimiter">,</span> <span class="Constant">"halt (hlt)"</span><span class="Delimiter">);</span> +<span id="L351" class="LineNr">351 </span> <span class="Comment">// End Initialize Op Names</span> +<span id="L352" class="LineNr">352 </span><span class="Delimiter">}</span> +<span id="L353" class="LineNr">353 </span> +<span id="L354" class="LineNr">354 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Special-cases(key)")</span> +<span id="L355" class="LineNr">355 </span><span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">"opcodes"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L356" class="LineNr">356 </span> cerr << <span class="Constant">"Opcodes currently supported by SubX:\n"</span><span class="Delimiter">;</span> +<span id="L357" class="LineNr">357 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> string>::iterator p = <span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> +<span id="L358" class="LineNr">358 </span> cerr << <span class="Constant">" "</span> << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L359" class="LineNr">359 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> string>::iterator p = <span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> +<span id="L360" class="LineNr">360 </span> cerr << <span class="Constant">" 0f "</span> << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L361" class="LineNr">361 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> string>::iterator p = <span class="Special"><a href='010---vm.cc.html#L344'>Name_f3</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='010---vm.cc.html#L344'>Name_f3</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> +<span id="L362" class="LineNr">362 </span> cerr << <span class="Constant">" f3 "</span> << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L363" class="LineNr">363 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> string>::iterator p = <span class="Special"><a href='010---vm.cc.html#L345'>Name_f3_0f</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='010---vm.cc.html#L345'>Name_f3_0f</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> +<span id="L364" class="LineNr">364 </span> cerr << <span class="Constant">" f3 0f "</span> << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << p<span class="Delimiter">-></span>second << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L365" class="LineNr">365 </span> cerr << <span class="Constant">"Run `bootstrap help instructions` for details on <a href='011run.cc.html#L122'>words</a> like 'r32' and 'disp8'.\n"</span> +<span id="L366" class="LineNr">366 </span> <span class="Constant">"For complete details on these instructions, consult the IA-32 manual (volume 2).\n"</span> +<span id="L367" class="LineNr">367 </span> <span class="Constant">"There's various versions of it online, such as <a href="https://c9x.me/x86">https://c9x.me/x86</a>.\n"</span> +<span id="L368" class="LineNr">368 </span> <span class="Constant">"The mnemonics in brackets will help you locate each instruction.\n"</span><span class="Delimiter">;</span> +<span id="L369" class="LineNr">369 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L370" class="LineNr">370 </span><span class="Delimiter">}</span> +<span id="L371" class="LineNr">371 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Contents")</span> +<span id="L372" class="LineNr">372 </span>cerr << <span class="Constant">" opcodes\n"</span><span class="Delimiter">;</span> +<span id="L373" class="LineNr">373 </span> +<span id="L374" class="LineNr">374 </span><span class="Comment">//: Helpers for managing trace depths</span> +<span id="L375" class="LineNr">375 </span><span class="Comment">//:</span> +<span id="L376" class="LineNr">376 </span><span class="Comment">//: We're going to use trace depths primarily to segment code running at</span> +<span id="L377" class="LineNr">377 </span><span class="Comment">//: different frames of the call stack. This will make it easy for the trace</span> +<span id="L378" class="LineNr">378 </span><span class="Comment">//: browser to collapse over entire calls.</span> +<span id="L379" class="LineNr">379 </span><span class="Comment">//:</span> +<span id="L380" class="LineNr">380 </span><span class="Comment">//: Errors will be at depth 0.</span> +<span id="L381" class="LineNr">381 </span><span class="Comment">//: Warnings will be at depth 1.</span> +<span id="L382" class="LineNr">382 </span><span class="Comment">//: SubX instructions will occupy depth 2 and up to Max_depth, organized by</span> +<span id="L383" class="LineNr">383 </span><span class="Comment">//: stack frames. Each instruction's internal details will be one level deeper</span> +<span id="L384" class="LineNr">384 </span><span class="Comment">//: than its 'main' depth. So 'call' instruction details will be at the same</span> +<span id="L385" class="LineNr">385 </span><span class="Comment">//: depth as the instructions of the function it calls.</span> +<span id="L386" class="LineNr">386 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L387" class="LineNr">387 </span><span class="Normal">extern</span> <span class="Normal">const</span> <span class="Normal">int</span> <span class="Special"><a href='010---vm.cc.html#L387'>Initial_callstack_depth</a></span> = <span class="Constant">2</span><span class="Delimiter">;</span> +<span id="L388" class="LineNr">388 </span><span class="Normal">int</span> <span class="Special">Callstack_depth</span> = <span class="Special"><a href='010---vm.cc.html#L387'>Initial_callstack_depth</a></span><span class="Delimiter">;</span> +<span id="L389" class="LineNr">389 </span><span class="Delimiter">:(before "End Reset")</span> +<span id="L390" class="LineNr">390 </span><span class="Special">Callstack_depth</span> = <span class="Special"><a href='010---vm.cc.html#L387'>Initial_callstack_depth</a></span><span class="Delimiter">;</span> +<span id="L391" class="LineNr">391 </span> +<span id="L392" class="LineNr">392 </span><span class="Delimiter">:(before "End Includes")</span> +<span id="L393" class="LineNr">393 </span><span class="PreProc">#include </span><span class="Constant"><iomanip></span> +<span id="L394" class="LineNr">394 </span><span class="PreProc">#define HEXBYTE std::hex << std::setw(</span><span class="Constant">2</span><span class="PreProc">) << std::setfill(</span><span class="Constant">'0'</span><span class="PreProc">)</span> +<span id="L395" class="LineNr">395 </span><span class="PreProc">#define HEXWORD std::hex << std::setw(</span><span class="Constant">8</span><span class="PreProc">) << std::setfill(</span><span class="Constant">'0'</span><span class="PreProc">)</span> +<span id="L396" class="LineNr">396 </span><span class="Comment">// ugly that iostream doesn't print uint8_t as an integer</span> +<span id="L397" class="LineNr">397 </span><span class="PreProc">#define NUM(</span><span class="Special">X</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 id="L398" class="LineNr">398 </span><span class="PreProc">#include </span><span class="Constant"><stdint.h></span> </pre> </body> </html> diff --git a/html/011run.cc.html b/html/011run.cc.html index 26bad7d7..003e8139 100644 --- a/html/011run.cc.html +++ b/html/011run.cc.html @@ -64,22 +64,22 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="Comment">//: the VM. That comes later.)</span> <span id="L5" class="LineNr"> 5 </span> <span id="L6" class="LineNr"> 6 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Texts")</span> -<span id="L7" class="LineNr"> 7 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='001help.cc.html#L53'>Help</a></span><span class="Delimiter">,</span> <span class="Constant">"syntax"</span><span class="Delimiter">,</span> -<span id="L8" class="LineNr"> 8 </span> <span class="Constant">"SubX programs consist of <a href='011run.cc.html#L107'>segments</a>, each segment in turn consisting of lines.\n"</span> -<span id="L9" class="LineNr"> 9 </span> <span class="Constant">"Line-endings are significant; each <a href='011run.cc.html#L122'>line</a> should contain a single\n"</span> +<span id="L7" class="LineNr"> 7 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='001help.cc.html#L53'>Help</a></span><span class="Delimiter">,</span> <span class="Constant">"syntax"</span><span class="Delimiter">,</span> +<span id="L8" class="LineNr"> 8 </span> <span class="Constant">"SubX programs consist of <a href='011run.cc.html#L106'>segments</a>, each segment in turn consisting of lines.\n"</span> +<span id="L9" class="LineNr"> 9 </span> <span class="Constant">"Line-endings are significant; each <a href='011run.cc.html#L121'>line</a> should contain a single\n"</span> <span id="L10" class="LineNr"> 10 </span> <span class="Constant">"instruction, macro or directive.\n"</span> <span id="L11" class="LineNr"> 11 </span> <span class="Constant">"\n"</span> <span id="L12" class="LineNr"> 12 </span> <span class="Constant">"Comments start with the '#' character. It should be at the start of a word\n"</span> -<span id="L13" class="LineNr"> 13 </span> <span class="Constant">"(start of <a href='011run.cc.html#L122'>line</a>, or following a space).\n"</span> +<span id="L13" class="LineNr"> 13 </span> <span class="Constant">"(start of <a href='011run.cc.html#L121'>line</a>, or following a space).\n"</span> <span id="L14" class="LineNr"> 14 </span> <span class="Constant">"\n"</span> -<span id="L15" class="LineNr"> 15 </span> <span class="Constant">"Each segment starts with a header <a href='011run.cc.html#L122'>line</a>: a '==' delimiter followed by the <a href='011run.cc.html#L112'>name</a> of\n"</span> +<span id="L15" class="LineNr"> 15 </span> <span class="Constant">"Each segment starts with a header <a href='011run.cc.html#L121'>line</a>: a '==' delimiter followed by the <a href='011run.cc.html#L111'>name</a> of\n"</span> <span id="L16" class="LineNr"> 16 </span> <span class="Constant">"the segment and a (sometimes approximate) starting address in memory.\n"</span> -<span id="L17" class="LineNr"> 17 </span> <span class="Constant">"The <a href='011run.cc.html#L112'>name</a> 'code' is special; instructions to execute should always go here.\n"</span> +<span id="L17" class="LineNr"> 17 </span> <span class="Constant">"The <a href='011run.cc.html#L111'>name</a> 'code' is special; instructions to execute should always go here.\n"</span> <span id="L18" class="LineNr"> 18 </span> <span class="Constant">"\n"</span> <span id="L19" class="LineNr"> 19 </span> <span class="Constant">"The resulting binary starts running code from a label called 'Entry'\n"</span> <span id="L20" class="LineNr"> 20 </span> <span class="Constant">"in the code segment.\n"</span> <span id="L21" class="LineNr"> 21 </span> <span class="Constant">"\n"</span> -<span id="L22" class="LineNr"> 22 </span> <span class="Constant">"Segments with the same <a href='011run.cc.html#L112'>name</a> get merged together. This rule helps keep functions and\n"</span> +<span id="L22" class="LineNr"> 22 </span> <span class="Constant">"Segments with the same <a href='011run.cc.html#L111'>name</a> get merged together. This rule helps keep functions and\n"</span> <span id="L23" class="LineNr"> 23 </span> <span class="Constant">"their data close together in .subx files.\n"</span> <span id="L24" class="LineNr"> 24 </span> <span class="Constant">"You don't have to specify the starting address after the first time.\n"</span> <span id="L25" class="LineNr"> 25 </span> <span class="Constant">"\n"</span> @@ -87,7 +87,7 @@ if ('onhashchange' in window) { <span id="L27" class="LineNr"> 27 </span> <span class="Constant">"after a '/', but they can never contain whitespace. Metadata has no effect\n"</span> <span id="L28" class="LineNr"> 28 </span> <span class="Constant">"at runtime, but can be handy when rewriting macros.\n"</span> <span id="L29" class="LineNr"> 29 </span> <span class="Constant">"\n"</span> -<span id="L30" class="LineNr"> 30 </span> <span class="Constant">"Check out the examples in the examples/ directory.\n"</span> +<span id="L30" class="LineNr"> 30 </span> <span class="Constant">"Check out the example programs in the apps/ directory, particularly apps/ex*.\n"</span> <span id="L31" class="LineNr"> 31 </span><span class="Delimiter">);</span> <span id="L32" class="LineNr"> 32 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Contents")</span> <span id="L33" class="LineNr"> 33 </span>cerr << <span class="Constant">" syntax\n"</span><span class="Delimiter">;</span> @@ -96,7 +96,7 @@ if ('onhashchange' in window) { <span id="L36" class="LineNr"> 36 </span><span class="Normal">void</span> <a href='011run.cc.html#L36'>test_copy_imm32_to_EAX</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L37" class="LineNr"> 37 </span> <span class="Comment">// At the lowest level, SubX programs are a series of hex bytes, each</span> <span id="L38" class="LineNr"> 38 </span> <span class="Comment">// (variable-length) instruction on one line.</span> -<span id="L39" class="LineNr"> 39 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L39" class="LineNr"> 39 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L40" class="LineNr"> 40 </span> <span class="Comment">// Comments start with '#' and are ignored.</span> <span id="L41" class="LineNr"> 41 </span> <span class="Constant">"# comment\n"</span> <span id="L42" class="LineNr"> 42 </span> <span class="Comment">// Segment headers start with '==', a name and a starting hex address.</span> @@ -138,393 +138,379 @@ if ('onhashchange' in window) { <span id="L78" class="LineNr"> 78 </span> <span class="Delimiter">);</span> <span id="L79" class="LineNr"> 79 </span><span class="Delimiter">}</span> <span id="L80" class="LineNr"> 80 </span> -<span id="L81" class="LineNr"> 81 </span><span class="Comment">// top-level helper for scenarios: parse the input, transform any macros, load</span> -<span id="L82" class="LineNr"> 82 </span><span class="Comment">// the final hex bytes into memory, run it</span> -<span id="L83" class="LineNr"> 83 </span><span class="Normal">void</span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span><span class="Normal">const</span> string& text_bytes<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L84" class="LineNr"> 84 </span> program p<span class="Delimiter">;</span> -<span id="L85" class="LineNr"> 85 </span> istringstream in<span class="Delimiter">(</span>text_bytes<span class="Delimiter">);</span> +<span id="L81" class="LineNr"> 81 </span><span class="Comment">// top-level helper for tests: parse the input, load the hex bytes into memory, run</span> +<span id="L82" class="LineNr"> 82 </span><span class="Normal">void</span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span><span class="Normal">const</span> string& text_bytes<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L83" class="LineNr"> 83 </span> program p<span class="Delimiter">;</span> +<span id="L84" class="LineNr"> 84 </span> istringstream in<span class="Delimiter">(</span>text_bytes<span class="Delimiter">);</span> +<span id="L85" class="LineNr"> 85 </span> <span class="Comment">// Loading Test Program</span> <span id="L86" class="LineNr"> 86 </span> parse<span class="Delimiter">(</span>in<span class="Delimiter">,</span> p<span class="Delimiter">);</span> <span id="L87" class="LineNr"> 87 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// if any stage raises errors, stop immediately</span> -<span id="L88" class="LineNr"> 88 </span> transform<span class="Delimiter">(</span>p<span class="Delimiter">);</span> -<span id="L89" class="LineNr"> 89 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L90" class="LineNr"> 90 </span> <a href='011run.cc.html#L262'>load</a><span class="Delimiter">(</span>p<span class="Delimiter">);</span> -<span id="L91" class="LineNr"> 91 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L92" class="LineNr"> 92 </span> <span class="Comment">// convenience to keep tests concise: 'Entry' label need not be provided</span> -<span id="L93" class="LineNr"> 93 </span> <span class="Comment">// not allowed in real programs</span> -<span id="L94" class="LineNr"> 94 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>entry</a><span class="Delimiter">)</span> -<span id="L95" class="LineNr"> 95 </span> <a href='010---vm.cc.html#L32'>EIP</a> = p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>entry</a><span class="Delimiter">;</span> -<span id="L96" class="LineNr"> 96 </span> <span class="Normal">else</span> -<span id="L97" class="LineNr"> 97 </span> <a href='010---vm.cc.html#L32'>EIP</a> = find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">)-></span>start<span class="Delimiter">;</span> -<span id="L98" class="LineNr"> 98 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L32'>EIP</a> < <span class="Special"><a href='010---vm.cc.html#L163'>End_of_program</a></span><span class="Delimiter">)</span> -<span id="L99" class="LineNr"> 99 </span> <a href='010---vm.cc.html#L270'>run_one_instruction</a><span class="Delimiter">();</span> -<span id="L100" class="LineNr">100 </span><span class="Delimiter">}</span> -<span id="L101" class="LineNr">101 </span> -<span id="L102" class="LineNr">102 </span><span class="SalientComment">//:: core data structures</span> -<span id="L103" class="LineNr">103 </span> -<span id="L104" class="LineNr">104 </span><span class="Delimiter">:(before "End Types")</span> -<span id="L105" class="LineNr">105 </span><span class="Normal">struct</span> program <span class="Delimiter">{</span> -<span id="L106" class="LineNr">106 </span> <span class="Normal">uint32_t</span> <a href='011run.cc.html#L106'>entry</a><span class="Delimiter">;</span> -<span id="L107" class="LineNr">107 </span> vector<segment> <a href='011run.cc.html#L107'>segments</a><span class="Delimiter">;</span> -<span id="L108" class="LineNr">108 </span> program<span class="Delimiter">()</span> <span class="Delimiter">{</span> <a href='011run.cc.html#L106'>entry</a> = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span id="L109" class="LineNr">109 </span><span class="Delimiter">};</span> -<span id="L110" class="LineNr">110 </span><span class="Delimiter">:(before "struct program")</span> -<span id="L111" class="LineNr">111 </span><span class="Normal">struct</span> segment <span class="Delimiter">{</span> -<span id="L112" class="LineNr">112 </span> string <a href='011run.cc.html#L112'>name</a><span class="Delimiter">;</span> -<span id="L113" class="LineNr">113 </span> <span class="Normal">uint32_t</span> start<span class="Delimiter">;</span> -<span id="L114" class="LineNr">114 </span> vector<line> <a href='011run.cc.html#L114'>lines</a><span class="Delimiter">;</span> -<span id="L115" class="LineNr">115 </span> <span class="Comment">// End segment Fields</span> -<span id="L116" class="LineNr">116 </span> segment<span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L117" class="LineNr">117 </span> start = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L118" class="LineNr">118 </span> <span class="Comment">// End segment Constructor</span> -<span id="L119" class="LineNr">119 </span> <span class="Delimiter">}</span> -<span id="L120" class="LineNr">120 </span><span class="Delimiter">};</span> -<span id="L121" class="LineNr">121 </span><span class="Delimiter">:(before "struct segment")</span> -<span id="L122" class="LineNr">122 </span><span class="Normal">struct</span> <a href='011run.cc.html#L122'>line</a> <span class="Delimiter">{</span> -<span id="L123" class="LineNr">123 </span> vector<word> <a href='011run.cc.html#L123'>words</a><span class="Delimiter">;</span> -<span id="L124" class="LineNr">124 </span> vector<string> metadata<span class="Delimiter">;</span> -<span id="L125" class="LineNr">125 </span> string original<span class="Delimiter">;</span> -<span id="L126" class="LineNr">126 </span><span class="Delimiter">};</span> -<span id="L127" class="LineNr">127 </span><span class="Delimiter">:(before "struct line")</span> -<span id="L128" class="LineNr">128 </span><span class="Normal">struct</span> <a href='011run.cc.html#L128'>word</a> <span class="Delimiter">{</span> -<span id="L129" class="LineNr">129 </span> string original<span class="Delimiter">;</span> -<span id="L130" class="LineNr">130 </span> string data<span class="Delimiter">;</span> -<span id="L131" class="LineNr">131 </span> vector<string> metadata<span class="Delimiter">;</span> -<span id="L132" class="LineNr">132 </span><span class="Delimiter">};</span> -<span id="L133" class="LineNr">133 </span> -<span id="L134" class="LineNr">134 </span><span class="SalientComment">//:: parse</span> -<span id="L135" class="LineNr">135 </span> -<span id="L136" class="LineNr">136 </span><span class="Delimiter">:(code)</span> -<span id="L137" class="LineNr">137 </span><span class="Normal">void</span> parse<span class="Delimiter">(</span>istream& fin<span class="Delimiter">,</span> program& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L138" class="LineNr">138 </span> segment* curr_segment = <span class="Constant">NULL</span><span class="Delimiter">;</span> -<span id="L139" class="LineNr">139 </span> vector<line> l<span class="Delimiter">;</span> -<span id="L140" class="LineNr">140 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>fin<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L141" class="LineNr">141 </span> string line_data<span class="Delimiter">;</span> -<span id="L142" class="LineNr">142 </span> <a href='011run.cc.html#L122'>line</a> curr<span class="Delimiter">;</span> -<span id="L143" class="LineNr">143 </span> getline<span class="Delimiter">(</span>fin<span class="Delimiter">,</span> line_data<span class="Delimiter">);</span> -<span id="L144" class="LineNr">144 </span> curr<span class="Delimiter">.</span>original = line_data<span class="Delimiter">;</span> -<span id="L145" class="LineNr">145 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"line: "</span> << line_data << end<span class="Delimiter">();</span> -<span id="L146" class="LineNr">146 </span> <span class="Comment">// End Line Parsing Special-cases(line_data -> l)</span> -<span id="L147" class="LineNr">147 </span> istringstream lin<span class="Delimiter">(</span>line_data<span class="Delimiter">);</span> -<span id="L148" class="LineNr">148 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>lin<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L149" class="LineNr">149 </span> string word_data<span class="Delimiter">;</span> -<span id="L150" class="LineNr">150 </span> lin >> word_data<span class="Delimiter">;</span> -<span id="L151" class="LineNr">151 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>word_data<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L152" class="LineNr">152 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>word_data[<span class="Constant">0</span>] == <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// comment</span> -<span id="L153" class="LineNr">153 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>word_data == <span class="Constant">"."</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// comment token</span> -<span id="L154" class="LineNr">154 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>word_data == <span class="Constant">"=="</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L155" class="LineNr">155 </span> <a href='011run.cc.html#L199'>flush</a><span class="Delimiter">(</span>curr_segment<span class="Delimiter">,</span> l<span class="Delimiter">);</span> -<span id="L156" class="LineNr">156 </span> string segment_name<span class="Delimiter">;</span> -<span id="L157" class="LineNr">157 </span> lin >> segment_name<span class="Delimiter">;</span> -<span id="L158" class="LineNr">158 </span> curr_segment = find<span class="Delimiter">(</span>out<span class="Delimiter">,</span> segment_name<span class="Delimiter">);</span> -<span id="L159" class="LineNr">159 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_segment != <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L160" class="LineNr">160 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"appending to segment '"</span> << segment_name << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> -<span id="L161" class="LineNr">161 </span> <span class="Delimiter">}</span> -<span id="L162" class="LineNr">162 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L163" class="LineNr">163 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"new segment '"</span> << segment_name << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> -<span id="L164" class="LineNr">164 </span> <span class="Normal">uint32_t</span> seg_start = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L165" class="LineNr">165 </span> lin >> std::hex >> seg_start<span class="Delimiter">;</span> -<span id="L166" class="LineNr">166 </span> <a href='011run.cc.html#L220'>sanity_check_program_segment</a><span class="Delimiter">(</span>out<span class="Delimiter">,</span> seg_start<span class="Delimiter">);</span> -<span id="L167" class="LineNr">167 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>segment<span class="Delimiter">());</span> -<span id="L168" class="LineNr">168 </span> curr_segment = &out<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>back<span class="Delimiter">();</span> -<span id="L169" class="LineNr">169 </span> curr_segment<span class="Delimiter">-></span><a href='011run.cc.html#L112'>name</a> = segment_name<span class="Delimiter">;</span> -<span id="L170" class="LineNr">170 </span> curr_segment<span class="Delimiter">-></span>start = seg_start<span class="Delimiter">;</span> -<span id="L171" class="LineNr">171 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L172" class="LineNr">172 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"starts at address 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << curr_segment<span class="Delimiter">-></span>start << end<span class="Delimiter">();</span> -<span id="L173" class="LineNr">173 </span> <span class="Delimiter">}</span> -<span id="L174" class="LineNr">174 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// skip rest of line</span> -<span id="L175" class="LineNr">175 </span> <span class="Delimiter">}</span> -<span id="L176" class="LineNr">176 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>word_data[<span class="Constant">0</span>] == <span class="Constant">':'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L177" class="LineNr">177 </span> <span class="Comment">// todo: line metadata</span> -<span id="L178" class="LineNr">178 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L179" class="LineNr">179 </span> <span class="Delimiter">}</span> -<span id="L180" class="LineNr">180 </span> curr<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L128'>word</a><span class="Delimiter">());</span> -<span id="L181" class="LineNr">181 </span> <a href='011run.cc.html#L210'>parse_word</a><span class="Delimiter">(</span>word_data<span class="Delimiter">,</span> curr<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">());</span> -<span id="L182" class="LineNr">182 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"word: "</span> << to_string<span class="Delimiter">(</span>curr<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">());</span> -<span id="L183" class="LineNr">183 </span> <span class="Delimiter">}</span> -<span id="L184" class="LineNr">184 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!curr<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> -<span id="L185" class="LineNr">185 </span> l<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> -<span id="L186" class="LineNr">186 </span> <span class="Delimiter">}</span> -<span id="L187" class="LineNr">187 </span> <a href='011run.cc.html#L199'>flush</a><span class="Delimiter">(</span>curr_segment<span class="Delimiter">,</span> l<span class="Delimiter">);</span> -<span id="L188" class="LineNr">188 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"done"</span> << end<span class="Delimiter">();</span> -<span id="L189" class="LineNr">189 </span><span class="Delimiter">}</span> -<span id="L190" class="LineNr">190 </span> -<span id="L191" class="LineNr">191 </span>segment* find<span class="Delimiter">(</span>program& p<span class="Delimiter">,</span> <span class="Normal">const</span> string& segment_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L192" class="LineNr">192 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L193" class="LineNr">193 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L112'>name</a> == segment_name<span class="Delimiter">)</span> -<span id="L194" class="LineNr">194 </span> <span class="Identifier">return</span> &p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L195" class="LineNr">195 </span> <span class="Delimiter">}</span> -<span id="L196" class="LineNr">196 </span> <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span> -<span id="L197" class="LineNr">197 </span><span class="Delimiter">}</span> -<span id="L198" class="LineNr">198 </span> -<span id="L199" class="LineNr">199 </span><span class="Normal">void</span> <a href='011run.cc.html#L199'>flush</a><span class="Delimiter">(</span>segment* s<span class="Delimiter">,</span> vector<line>& <a href='011run.cc.html#L114'>lines</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L200" class="LineNr">200 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L201" class="LineNr">201 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L202" class="LineNr">202 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"input does not start with a '==' section header\n"</span> << end<span class="Delimiter">();</span> -<span id="L203" class="LineNr">203 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L204" class="LineNr">204 </span> <span class="Delimiter">}</span> -<span id="L205" class="LineNr">205 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"flushing segment"</span> << end<span class="Delimiter">();</span> -<span id="L206" class="LineNr">206 </span> s<span class="Delimiter">-></span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>insert<span class="Delimiter">(</span>s<span class="Delimiter">-></span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>end<span class="Delimiter">(),</span> <a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> <a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>end<span class="Delimiter">());</span> -<span id="L207" class="LineNr">207 </span> <a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>clear<span class="Delimiter">();</span> -<span id="L208" class="LineNr">208 </span><span class="Delimiter">}</span> -<span id="L209" class="LineNr">209 </span> -<span id="L210" class="LineNr">210 </span><span class="Normal">void</span> <a href='011run.cc.html#L210'>parse_word</a><span class="Delimiter">(</span><span class="Normal">const</span> string& data<span class="Delimiter">,</span> word& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L211" class="LineNr">211 </span> out<span class="Delimiter">.</span>original = data<span class="Delimiter">;</span> -<span id="L212" class="LineNr">212 </span> istringstream win<span class="Delimiter">(</span>data<span class="Delimiter">);</span> -<span id="L213" class="LineNr">213 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>getline<span class="Delimiter">(</span>win<span class="Delimiter">,</span> out<span class="Delimiter">.</span>data<span class="Delimiter">,</span> <span class="Constant">'/'</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L214" class="LineNr">214 </span> string m<span class="Delimiter">;</span> -<span id="L215" class="LineNr">215 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>getline<span class="Delimiter">(</span>win<span class="Delimiter">,</span> m<span class="Delimiter">,</span> <span class="Constant">'/'</span><span class="Delimiter">))</span> -<span id="L216" class="LineNr">216 </span> out<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>m<span class="Delimiter">);</span> -<span id="L217" class="LineNr">217 </span> <span class="Delimiter">}</span> -<span id="L218" class="LineNr">218 </span><span class="Delimiter">}</span> -<span id="L219" class="LineNr">219 </span> -<span id="L220" class="LineNr">220 </span><span class="Normal">void</span> <a href='011run.cc.html#L220'>sanity_check_program_segment</a><span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L221" class="LineNr">221 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L222" class="LineNr">222 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>start == addr<span class="Delimiter">)</span> -<span id="L223" class="LineNr">223 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"can't have multiple segments starting at address 0x"</span> << HEXWORD << addr << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> -<span id="L224" class="LineNr">224 </span> <span class="Delimiter">}</span> -<span id="L225" class="LineNr">225 </span><span class="Delimiter">}</span> -<span id="L226" class="LineNr">226 </span> -<span id="L227" class="LineNr">227 </span><span class="Comment">// helper for tests</span> -<span id="L228" class="LineNr">228 </span><span class="Normal">void</span> parse<span class="Delimiter">(</span><span class="Normal">const</span> string& text_bytes<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L229" class="LineNr">229 </span> program p<span class="Delimiter">;</span> -<span id="L230" class="LineNr">230 </span> istringstream in<span class="Delimiter">(</span>text_bytes<span class="Delimiter">);</span> -<span id="L231" class="LineNr">231 </span> parse<span class="Delimiter">(</span>in<span class="Delimiter">,</span> p<span class="Delimiter">);</span> -<span id="L232" class="LineNr">232 </span><span class="Delimiter">}</span> -<span id="L233" class="LineNr">233 </span> -<span id="L234" class="LineNr">234 </span><span class="Normal">void</span> <a href='011run.cc.html#L234'>test_detect_duplicate_segments</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L235" class="LineNr">235 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L236" class="LineNr">236 </span> parse<span class="Delimiter">(</span> -<span id="L237" class="LineNr">237 </span> <span class="Constant">"== segment1 0xee\n"</span> -<span id="L238" class="LineNr">238 </span> <span class="Constant">"ab\n"</span> -<span id="L239" class="LineNr">239 </span> <span class="Constant">"== segment2 0xee\n"</span> -<span id="L240" class="LineNr">240 </span> <span class="Constant">"cd\n"</span> -<span id="L241" class="LineNr">241 </span> <span class="Delimiter">);</span> -<span id="L242" class="LineNr">242 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L243" class="LineNr">243 </span> <span class="Constant">"error: can't have multiple segments starting at address 0x000000ee\n"</span> -<span id="L244" class="LineNr">244 </span> <span class="Delimiter">);</span> -<span id="L245" class="LineNr">245 </span><span class="Delimiter">}</span> -<span id="L246" class="LineNr">246 </span> -<span id="L247" class="LineNr">247 </span><span class="SalientComment">//:: transform</span> -<span id="L248" class="LineNr">248 </span> -<span id="L249" class="LineNr">249 </span><span class="Delimiter">:(before "End Types")</span> -<span id="L250" class="LineNr">250 </span><span class="Normal">typedef</span> <span class="Normal">void</span> <span class="Delimiter">(</span>*transform_fn<span class="Delimiter">)(</span>program&<span class="Delimiter">);</span> -<span id="L251" class="LineNr">251 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L252" class="LineNr">252 </span>vector<transform_fn> <span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">;</span> -<span id="L253" class="LineNr">253 </span> -<span id="L254" class="LineNr">254 </span><span class="Delimiter">:(code)</span> -<span id="L255" class="LineNr">255 </span><span class="Normal">void</span> transform<span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L256" class="LineNr">256 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> t = <span class="Constant">0</span><span class="Delimiter">;</span> t < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span><span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">);</span> ++t<span class="Delimiter">)</span> -<span id="L257" class="LineNr">257 </span> <span class="Delimiter">(</span>*<span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>t<span class="Delimiter">))(</span>p<span class="Delimiter">);</span> -<span id="L258" class="LineNr">258 </span><span class="Delimiter">}</span> -<span id="L259" class="LineNr">259 </span> -<span id="L260" class="LineNr">260 </span><span class="SalientComment">//:: load</span> -<span id="L261" class="LineNr">261 </span> -<span id="L262" class="LineNr">262 </span><span class="Normal">void</span> <a href='011run.cc.html#L262'>load</a><span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L263" class="LineNr">263 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">)</span> == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L264" class="LineNr">264 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"no code to run\n"</span> << end<span class="Delimiter">();</span> -<span id="L265" class="LineNr">265 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L266" class="LineNr">266 </span> <span class="Delimiter">}</span> -<span id="L267" class="LineNr">267 </span> <span class="Comment">// Ensure segments are disjoint.</span> -<span id="L268" class="LineNr">268 </span> set<<span class="Normal">uint32_t</span>> overlap<span class="Delimiter">;</span> -<span id="L269" class="LineNr">269 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L270" class="LineNr">270 </span> <span class="Normal">const</span> segment& seg = p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L271" class="LineNr">271 </span> <span class="Normal">uint32_t</span> addr = seg<span class="Delimiter">.</span>start<span class="Delimiter">;</span> -<span id="L272" class="LineNr">272 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!already_allocated<span class="Delimiter">(</span>addr<span class="Delimiter">))</span> -<span id="L273" class="LineNr">273 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span>seg<span class="Delimiter">.</span>start<span class="Delimiter">));</span> -<span id="L274" class="LineNr">274 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"load"</span><span class="Delimiter">)</span> << <span class="Constant">"loading segment "</span> << i << <span class="Constant">" from "</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << end<span class="Delimiter">();</span> -<span id="L275" class="LineNr">275 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>seg<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L276" class="LineNr">276 </span> <span class="Normal">const</span> line& l = seg<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> -<span id="L277" class="LineNr">277 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> k = <span class="Constant">0</span><span class="Delimiter">;</span> k < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>l<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++k<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L278" class="LineNr">278 </span> <span class="Normal">const</span> word& w = l<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>k<span class="Delimiter">);</span> -<span id="L279" class="LineNr">279 </span> <span class="Normal">uint8_t</span> val = <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">);</span> -<span id="L280" class="LineNr">280 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L281" class="LineNr">281 </span> assert<span class="Delimiter">(</span>overlap<span class="Delimiter">.</span>find<span class="Delimiter">(</span>addr<span class="Delimiter">)</span> == overlap<span class="Delimiter">.</span>end<span class="Delimiter">());</span> -<span id="L282" class="LineNr">282 </span> <a href='010---vm.cc.html#L237'>write_mem_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">,</span> val<span class="Delimiter">);</span> -<span id="L283" class="LineNr">283 </span> overlap<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>addr<span class="Delimiter">);</span> -<span id="L284" class="LineNr">284 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"load"</span><span class="Delimiter">)</span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" -> "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L171'>read_mem_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> -<span id="L285" class="LineNr">285 </span> ++addr<span class="Delimiter">;</span> -<span id="L286" class="LineNr">286 </span> <span class="Delimiter">}</span> -<span id="L287" class="LineNr">287 </span> <span class="Delimiter">}</span> -<span id="L288" class="LineNr">288 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>seg<span class="Delimiter">.</span><a href='011run.cc.html#L112'>name</a> == <span class="Constant">"code"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L289" class="LineNr">289 </span> <span class="Special"><a href='010---vm.cc.html#L163'>End_of_program</a></span> = addr<span class="Delimiter">;</span> -<span id="L290" class="LineNr">290 </span> <span class="Delimiter">}</span> -<span id="L291" class="LineNr">291 </span> <span class="Delimiter">}</span> -<span id="L292" class="LineNr">292 </span><span class="Delimiter">}</span> -<span id="L293" class="LineNr">293 </span> -<span id="L294" class="LineNr">294 </span><span class="Normal">const</span> segment* find<span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">,</span> <span class="Normal">const</span> string& segment_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L295" class="LineNr">295 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L296" class="LineNr">296 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L112'>name</a> == segment_name<span class="Delimiter">)</span> -<span id="L297" class="LineNr">297 </span> <span class="Identifier">return</span> &p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L298" class="LineNr">298 </span> <span class="Delimiter">}</span> -<span id="L299" class="LineNr">299 </span> <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span> -<span id="L300" class="LineNr">300 </span><span class="Delimiter">}</span> -<span id="L301" class="LineNr">301 </span> -<span id="L302" class="LineNr">302 </span><span class="Normal">uint8_t</span> <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L303" class="LineNr">303 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='011run.cc.html#L463'>contains_uppercase</a><span class="Delimiter">(</span>s<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L304" class="LineNr">304 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"uppercase hex not allowed: "</span> << s << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> -<span id="L305" class="LineNr">305 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L306" class="LineNr">306 </span> <span class="Delimiter">}</span> -<span id="L307" class="LineNr">307 </span> istringstream in<span class="Delimiter">(</span>s<span class="Delimiter">);</span> -<span id="L308" class="LineNr">308 </span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L309" class="LineNr">309 </span> in >> std::hex >> result<span class="Delimiter">;</span> -<span id="L310" class="LineNr">310 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!in || !in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L311" class="LineNr">311 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"token '"</span> << s << <span class="Constant">"' is not a hex byte\n"</span> << end<span class="Delimiter">();</span> -<span id="L312" class="LineNr">312 </span> <span class="Identifier">return</span> <span class="cSpecial">'\0'</span><span class="Delimiter">;</span> -<span id="L313" class="LineNr">313 </span> <span class="Delimiter">}</span> -<span id="L314" class="LineNr">314 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result > <span class="Constant">0xff</span> || result < -<span class="Constant">0x8f</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L315" class="LineNr">315 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"token '"</span> << s << <span class="Constant">"' is not a hex byte\n"</span> << end<span class="Delimiter">();</span> -<span id="L316" class="LineNr">316 </span> <span class="Identifier">return</span> <span class="cSpecial">'\0'</span><span class="Delimiter">;</span> -<span id="L317" class="LineNr">317 </span> <span class="Delimiter">}</span> -<span id="L318" class="LineNr">318 </span> <span class="Identifier">return</span> <span class="Normal">static_cast</span><<span class="Normal">uint8_t</span>><span class="Delimiter">(</span>result<span class="Delimiter">);</span> -<span id="L319" class="LineNr">319 </span><span class="Delimiter">}</span> -<span id="L320" class="LineNr">320 </span> -<span id="L321" class="LineNr">321 </span><span class="Normal">void</span> <a href='011run.cc.html#L321'>test_number_too_large</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L322" class="LineNr">322 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L323" class="LineNr">323 </span> <a href='011run.cc.html#L411'>parse_and_load</a><span class="Delimiter">(</span> -<span id="L324" class="LineNr">324 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L325" class="LineNr">325 </span> <span class="Constant">"01 cab\n"</span> +<span id="L88" class="LineNr"> 88 </span> <span class="Comment">// Running Test Program</span> +<span id="L89" class="LineNr"> 89 </span> <a href='011run.cc.html#L248'>load</a><span class="Delimiter">(</span>p<span class="Delimiter">);</span> +<span id="L90" class="LineNr"> 90 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L91" class="LineNr"> 91 </span> <span class="Comment">// convenience to keep tests concise: 'Entry' label need not be provided</span> +<span id="L92" class="LineNr"> 92 </span> <span class="Comment">// not allowed in real programs</span> +<span id="L93" class="LineNr"> 93 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L105'>entry</a><span class="Delimiter">)</span> +<span id="L94" class="LineNr"> 94 </span> <a href='010---vm.cc.html#L26'>EIP</a> = p<span class="Delimiter">.</span><a href='011run.cc.html#L105'>entry</a><span class="Delimiter">;</span> +<span id="L95" class="LineNr"> 95 </span> <span class="Normal">else</span> +<span id="L96" class="LineNr"> 96 </span> <a href='010---vm.cc.html#L26'>EIP</a> = find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">)-></span>start<span class="Delimiter">;</span> +<span id="L97" class="LineNr"> 97 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L26'>EIP</a> < <span class="Special"><a href='010---vm.cc.html#L157'>End_of_program</a></span><span class="Delimiter">)</span> +<span id="L98" class="LineNr"> 98 </span> <a href='010---vm.cc.html#L264'>run_one_instruction</a><span class="Delimiter">();</span> +<span id="L99" class="LineNr"> 99 </span><span class="Delimiter">}</span> +<span id="L100" class="LineNr">100 </span> +<span id="L101" class="LineNr">101 </span><span class="SalientComment">//:: core data structures</span> +<span id="L102" class="LineNr">102 </span> +<span id="L103" class="LineNr">103 </span><span class="Delimiter">:(before "End Types")</span> +<span id="L104" class="LineNr">104 </span><span class="Normal">struct</span> program <span class="Delimiter">{</span> +<span id="L105" class="LineNr">105 </span> <span class="Normal">uint32_t</span> <a href='011run.cc.html#L105'>entry</a><span class="Delimiter">;</span> +<span id="L106" class="LineNr">106 </span> vector<segment> <a href='011run.cc.html#L106'>segments</a><span class="Delimiter">;</span> +<span id="L107" class="LineNr">107 </span> program<span class="Delimiter">()</span> <span class="Delimiter">{</span> <a href='011run.cc.html#L105'>entry</a> = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span id="L108" class="LineNr">108 </span><span class="Delimiter">};</span> +<span id="L109" class="LineNr">109 </span><span class="Delimiter">:(before "struct program")</span> +<span id="L110" class="LineNr">110 </span><span class="Normal">struct</span> segment <span class="Delimiter">{</span> +<span id="L111" class="LineNr">111 </span> string <a href='011run.cc.html#L111'>name</a><span class="Delimiter">;</span> +<span id="L112" class="LineNr">112 </span> <span class="Normal">uint32_t</span> start<span class="Delimiter">;</span> +<span id="L113" class="LineNr">113 </span> vector<line> <a href='011run.cc.html#L113'>lines</a><span class="Delimiter">;</span> +<span id="L114" class="LineNr">114 </span> <span class="Comment">// End segment Fields</span> +<span id="L115" class="LineNr">115 </span> segment<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L116" class="LineNr">116 </span> start = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L117" class="LineNr">117 </span> <span class="Comment">// End segment Constructor</span> +<span id="L118" class="LineNr">118 </span> <span class="Delimiter">}</span> +<span id="L119" class="LineNr">119 </span><span class="Delimiter">};</span> +<span id="L120" class="LineNr">120 </span><span class="Delimiter">:(before "struct segment")</span> +<span id="L121" class="LineNr">121 </span><span class="Normal">struct</span> <a href='011run.cc.html#L121'>line</a> <span class="Delimiter">{</span> +<span id="L122" class="LineNr">122 </span> vector<word> <a href='011run.cc.html#L122'>words</a><span class="Delimiter">;</span> +<span id="L123" class="LineNr">123 </span> vector<string> metadata<span class="Delimiter">;</span> +<span id="L124" class="LineNr">124 </span> string original<span class="Delimiter">;</span> +<span id="L125" class="LineNr">125 </span><span class="Delimiter">};</span> +<span id="L126" class="LineNr">126 </span><span class="Delimiter">:(before "struct line")</span> +<span id="L127" class="LineNr">127 </span><span class="Normal">struct</span> <a href='011run.cc.html#L127'>word</a> <span class="Delimiter">{</span> +<span id="L128" class="LineNr">128 </span> string original<span class="Delimiter">;</span> +<span id="L129" class="LineNr">129 </span> string data<span class="Delimiter">;</span> +<span id="L130" class="LineNr">130 </span> vector<string> metadata<span class="Delimiter">;</span> +<span id="L131" class="LineNr">131 </span><span class="Delimiter">};</span> +<span id="L132" class="LineNr">132 </span> +<span id="L133" class="LineNr">133 </span><span class="SalientComment">//:: parse</span> +<span id="L134" class="LineNr">134 </span> +<span id="L135" class="LineNr">135 </span><span class="Delimiter">:(code)</span> +<span id="L136" class="LineNr">136 </span><span class="Normal">void</span> parse<span class="Delimiter">(</span>istream& fin<span class="Delimiter">,</span> program& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L137" class="LineNr">137 </span> segment* curr_segment = <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L138" class="LineNr">138 </span> vector<line> l<span class="Delimiter">;</span> +<span id="L139" class="LineNr">139 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>fin<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L140" class="LineNr">140 </span> string line_data<span class="Delimiter">;</span> +<span id="L141" class="LineNr">141 </span> <a href='011run.cc.html#L121'>line</a> curr<span class="Delimiter">;</span> +<span id="L142" class="LineNr">142 </span> getline<span class="Delimiter">(</span>fin<span class="Delimiter">,</span> line_data<span class="Delimiter">);</span> +<span id="L143" class="LineNr">143 </span> curr<span class="Delimiter">.</span>original = line_data<span class="Delimiter">;</span> +<span id="L144" class="LineNr">144 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"line: "</span> << line_data << end<span class="Delimiter">();</span> +<span id="L145" class="LineNr">145 </span> <span class="Comment">// End Line Parsing Special-cases(line_data -> l)</span> +<span id="L146" class="LineNr">146 </span> istringstream lin<span class="Delimiter">(</span>line_data<span class="Delimiter">);</span> +<span id="L147" class="LineNr">147 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>lin<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L148" class="LineNr">148 </span> string word_data<span class="Delimiter">;</span> +<span id="L149" class="LineNr">149 </span> lin >> word_data<span class="Delimiter">;</span> +<span id="L150" class="LineNr">150 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>word_data<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L151" class="LineNr">151 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>word_data[<span class="Constant">0</span>] == <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// comment</span> +<span id="L152" class="LineNr">152 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>word_data == <span class="Constant">"."</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// comment token</span> +<span id="L153" class="LineNr">153 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>word_data == <span class="Constant">"=="</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L154" class="LineNr">154 </span> <a href='011run.cc.html#L198'>flush</a><span class="Delimiter">(</span>curr_segment<span class="Delimiter">,</span> l<span class="Delimiter">);</span> +<span id="L155" class="LineNr">155 </span> string segment_name<span class="Delimiter">;</span> +<span id="L156" class="LineNr">156 </span> lin >> segment_name<span class="Delimiter">;</span> +<span id="L157" class="LineNr">157 </span> curr_segment = find<span class="Delimiter">(</span>out<span class="Delimiter">,</span> segment_name<span class="Delimiter">);</span> +<span id="L158" class="LineNr">158 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_segment != <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L159" class="LineNr">159 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"appending to segment '"</span> << segment_name << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> +<span id="L160" class="LineNr">160 </span> <span class="Delimiter">}</span> +<span id="L161" class="LineNr">161 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> +<span id="L162" class="LineNr">162 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"new segment '"</span> << segment_name << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> +<span id="L163" class="LineNr">163 </span> <span class="Normal">uint32_t</span> seg_start = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L164" class="LineNr">164 </span> lin >> std::hex >> seg_start<span class="Delimiter">;</span> +<span id="L165" class="LineNr">165 </span> <a href='011run.cc.html#L219'>sanity_check_program_segment</a><span class="Delimiter">(</span>out<span class="Delimiter">,</span> seg_start<span class="Delimiter">);</span> +<span id="L166" class="LineNr">166 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>segment<span class="Delimiter">());</span> +<span id="L167" class="LineNr">167 </span> curr_segment = &out<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>back<span class="Delimiter">();</span> +<span id="L168" class="LineNr">168 </span> curr_segment<span class="Delimiter">-></span><a href='011run.cc.html#L111'>name</a> = segment_name<span class="Delimiter">;</span> +<span id="L169" class="LineNr">169 </span> curr_segment<span class="Delimiter">-></span>start = seg_start<span class="Delimiter">;</span> +<span id="L170" class="LineNr">170 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L171" class="LineNr">171 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"starts at address 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << curr_segment<span class="Delimiter">-></span>start << end<span class="Delimiter">();</span> +<span id="L172" class="LineNr">172 </span> <span class="Delimiter">}</span> +<span id="L173" class="LineNr">173 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// skip rest of line</span> +<span id="L174" class="LineNr">174 </span> <span class="Delimiter">}</span> +<span id="L175" class="LineNr">175 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>word_data[<span class="Constant">0</span>] == <span class="Constant">':'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L176" class="LineNr">176 </span> <span class="Comment">// todo: line metadata</span> +<span id="L177" class="LineNr">177 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L178" class="LineNr">178 </span> <span class="Delimiter">}</span> +<span id="L179" class="LineNr">179 </span> curr<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L127'>word</a><span class="Delimiter">());</span> +<span id="L180" class="LineNr">180 </span> <a href='011run.cc.html#L209'>parse_word</a><span class="Delimiter">(</span>word_data<span class="Delimiter">,</span> curr<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">());</span> +<span id="L181" class="LineNr">181 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"word: "</span> << to_string<span class="Delimiter">(</span>curr<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">());</span> +<span id="L182" class="LineNr">182 </span> <span class="Delimiter">}</span> +<span id="L183" class="LineNr">183 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!curr<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> +<span id="L184" class="LineNr">184 </span> l<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> +<span id="L185" class="LineNr">185 </span> <span class="Delimiter">}</span> +<span id="L186" class="LineNr">186 </span> <a href='011run.cc.html#L198'>flush</a><span class="Delimiter">(</span>curr_segment<span class="Delimiter">,</span> l<span class="Delimiter">);</span> +<span id="L187" class="LineNr">187 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"done"</span> << end<span class="Delimiter">();</span> +<span id="L188" class="LineNr">188 </span><span class="Delimiter">}</span> +<span id="L189" class="LineNr">189 </span> +<span id="L190" class="LineNr">190 </span>segment* find<span class="Delimiter">(</span>program& p<span class="Delimiter">,</span> <span class="Normal">const</span> string& segment_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L191" class="LineNr">191 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L192" class="LineNr">192 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L111'>name</a> == segment_name<span class="Delimiter">)</span> +<span id="L193" class="LineNr">193 </span> <span class="Identifier">return</span> &p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L194" class="LineNr">194 </span> <span class="Delimiter">}</span> +<span id="L195" class="LineNr">195 </span> <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L196" class="LineNr">196 </span><span class="Delimiter">}</span> +<span id="L197" class="LineNr">197 </span> +<span id="L198" class="LineNr">198 </span><span class="Normal">void</span> <a href='011run.cc.html#L198'>flush</a><span class="Delimiter">(</span>segment* s<span class="Delimiter">,</span> vector<line>& <a href='011run.cc.html#L113'>lines</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L199" class="LineNr">199 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L200" class="LineNr">200 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L201" class="LineNr">201 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"input does not start with a '==' section header\n"</span> << end<span class="Delimiter">();</span> +<span id="L202" class="LineNr">202 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L203" class="LineNr">203 </span> <span class="Delimiter">}</span> +<span id="L204" class="LineNr">204 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << <span class="Constant">"flushing segment"</span> << end<span class="Delimiter">();</span> +<span id="L205" class="LineNr">205 </span> s<span class="Delimiter">-></span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>insert<span class="Delimiter">(</span>s<span class="Delimiter">-></span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>end<span class="Delimiter">(),</span> <a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> <a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>end<span class="Delimiter">());</span> +<span id="L206" class="LineNr">206 </span> <a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>clear<span class="Delimiter">();</span> +<span id="L207" class="LineNr">207 </span><span class="Delimiter">}</span> +<span id="L208" class="LineNr">208 </span> +<span id="L209" class="LineNr">209 </span><span class="Normal">void</span> <a href='011run.cc.html#L209'>parse_word</a><span class="Delimiter">(</span><span class="Normal">const</span> string& data<span class="Delimiter">,</span> word& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L210" class="LineNr">210 </span> out<span class="Delimiter">.</span>original = data<span class="Delimiter">;</span> +<span id="L211" class="LineNr">211 </span> istringstream win<span class="Delimiter">(</span>data<span class="Delimiter">);</span> +<span id="L212" class="LineNr">212 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>getline<span class="Delimiter">(</span>win<span class="Delimiter">,</span> out<span class="Delimiter">.</span>data<span class="Delimiter">,</span> <span class="Constant">'/'</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L213" class="LineNr">213 </span> string m<span class="Delimiter">;</span> +<span id="L214" class="LineNr">214 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>getline<span class="Delimiter">(</span>win<span class="Delimiter">,</span> m<span class="Delimiter">,</span> <span class="Constant">'/'</span><span class="Delimiter">))</span> +<span id="L215" class="LineNr">215 </span> out<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>m<span class="Delimiter">);</span> +<span id="L216" class="LineNr">216 </span> <span class="Delimiter">}</span> +<span id="L217" class="LineNr">217 </span><span class="Delimiter">}</span> +<span id="L218" class="LineNr">218 </span> +<span id="L219" class="LineNr">219 </span><span class="Normal">void</span> <a href='011run.cc.html#L219'>sanity_check_program_segment</a><span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L220" class="LineNr">220 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L221" class="LineNr">221 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>start == addr<span class="Delimiter">)</span> +<span id="L222" class="LineNr">222 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"can't have multiple segments starting at address 0x"</span> << HEXWORD << addr << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L223" class="LineNr">223 </span> <span class="Delimiter">}</span> +<span id="L224" class="LineNr">224 </span><span class="Delimiter">}</span> +<span id="L225" class="LineNr">225 </span> +<span id="L226" class="LineNr">226 </span><span class="Comment">// helper for tests</span> +<span id="L227" class="LineNr">227 </span><span class="Normal">void</span> parse<span class="Delimiter">(</span><span class="Normal">const</span> string& text_bytes<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L228" class="LineNr">228 </span> program p<span class="Delimiter">;</span> +<span id="L229" class="LineNr">229 </span> istringstream in<span class="Delimiter">(</span>text_bytes<span class="Delimiter">);</span> +<span id="L230" class="LineNr">230 </span> parse<span class="Delimiter">(</span>in<span class="Delimiter">,</span> p<span class="Delimiter">);</span> +<span id="L231" class="LineNr">231 </span><span class="Delimiter">}</span> +<span id="L232" class="LineNr">232 </span> +<span id="L233" class="LineNr">233 </span><span class="Normal">void</span> <a href='011run.cc.html#L233'>test_detect_duplicate_segments</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L234" class="LineNr">234 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L235" class="LineNr">235 </span> parse<span class="Delimiter">(</span> +<span id="L236" class="LineNr">236 </span> <span class="Constant">"== segment1 0xee\n"</span> +<span id="L237" class="LineNr">237 </span> <span class="Constant">"ab\n"</span> +<span id="L238" class="LineNr">238 </span> <span class="Constant">"== segment2 0xee\n"</span> +<span id="L239" class="LineNr">239 </span> <span class="Constant">"cd\n"</span> +<span id="L240" class="LineNr">240 </span> <span class="Delimiter">);</span> +<span id="L241" class="LineNr">241 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L242" class="LineNr">242 </span> <span class="Constant">"error: can't have multiple segments starting at address 0x000000ee\n"</span> +<span id="L243" class="LineNr">243 </span> <span class="Delimiter">);</span> +<span id="L244" class="LineNr">244 </span><span class="Delimiter">}</span> +<span id="L245" class="LineNr">245 </span> +<span id="L246" class="LineNr">246 </span><span class="SalientComment">//:: load</span> +<span id="L247" class="LineNr">247 </span> +<span id="L248" class="LineNr">248 </span><span class="Normal">void</span> <a href='011run.cc.html#L248'>load</a><span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L249" class="LineNr">249 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">)</span> == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L250" class="LineNr">250 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"no code to run\n"</span> << end<span class="Delimiter">();</span> +<span id="L251" class="LineNr">251 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L252" class="LineNr">252 </span> <span class="Delimiter">}</span> +<span id="L253" class="LineNr">253 </span> <span class="Comment">// Ensure segments are disjoint.</span> +<span id="L254" class="LineNr">254 </span> set<<span class="Normal">uint32_t</span>> overlap<span class="Delimiter">;</span> +<span id="L255" class="LineNr">255 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L256" class="LineNr">256 </span> <span class="Normal">const</span> segment& seg = p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L257" class="LineNr">257 </span> <span class="Normal">uint32_t</span> addr = seg<span class="Delimiter">.</span>start<span class="Delimiter">;</span> +<span id="L258" class="LineNr">258 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!already_allocated<span class="Delimiter">(</span>addr<span class="Delimiter">))</span> +<span id="L259" class="LineNr">259 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span>seg<span class="Delimiter">.</span>start<span class="Delimiter">));</span> +<span id="L260" class="LineNr">260 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"load"</span><span class="Delimiter">)</span> << <span class="Constant">"loading segment "</span> << i << <span class="Constant">" from "</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << end<span class="Delimiter">();</span> +<span id="L261" class="LineNr">261 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>seg<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L262" class="LineNr">262 </span> <span class="Normal">const</span> line& l = seg<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L263" class="LineNr">263 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> k = <span class="Constant">0</span><span class="Delimiter">;</span> k < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>l<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++k<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L264" class="LineNr">264 </span> <span class="Normal">const</span> word& w = l<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>k<span class="Delimiter">);</span> +<span id="L265" class="LineNr">265 </span> <span class="Normal">uint8_t</span> val = <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L266" class="LineNr">266 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L267" class="LineNr">267 </span> assert<span class="Delimiter">(</span>overlap<span class="Delimiter">.</span>find<span class="Delimiter">(</span>addr<span class="Delimiter">)</span> == overlap<span class="Delimiter">.</span>end<span class="Delimiter">());</span> +<span id="L268" class="LineNr">268 </span> <a href='010---vm.cc.html#L231'>write_mem_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">,</span> val<span class="Delimiter">);</span> +<span id="L269" class="LineNr">269 </span> overlap<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>addr<span class="Delimiter">);</span> +<span id="L270" class="LineNr">270 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"load"</span><span class="Delimiter">)</span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" -> "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L165'>read_mem_u8</a><span class="Delimiter">(</span>addr<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> +<span id="L271" class="LineNr">271 </span> ++addr<span class="Delimiter">;</span> +<span id="L272" class="LineNr">272 </span> <span class="Delimiter">}</span> +<span id="L273" class="LineNr">273 </span> <span class="Delimiter">}</span> +<span id="L274" class="LineNr">274 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>seg<span class="Delimiter">.</span><a href='011run.cc.html#L111'>name</a> == <span class="Constant">"code"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L275" class="LineNr">275 </span> <span class="Special"><a href='010---vm.cc.html#L157'>End_of_program</a></span> = addr<span class="Delimiter">;</span> +<span id="L276" class="LineNr">276 </span> <span class="Delimiter">}</span> +<span id="L277" class="LineNr">277 </span> <span class="Delimiter">}</span> +<span id="L278" class="LineNr">278 </span><span class="Delimiter">}</span> +<span id="L279" class="LineNr">279 </span> +<span id="L280" class="LineNr">280 </span><span class="Normal">const</span> segment* find<span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">,</span> <span class="Normal">const</span> string& segment_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L281" class="LineNr">281 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L282" class="LineNr">282 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L111'>name</a> == segment_name<span class="Delimiter">)</span> +<span id="L283" class="LineNr">283 </span> <span class="Identifier">return</span> &p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L284" class="LineNr">284 </span> <span class="Delimiter">}</span> +<span id="L285" class="LineNr">285 </span> <span class="Identifier">return</span> <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span id="L286" class="LineNr">286 </span><span class="Delimiter">}</span> +<span id="L287" class="LineNr">287 </span> +<span id="L288" class="LineNr">288 </span><span class="Normal">uint8_t</span> <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L289" class="LineNr">289 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='011run.cc.html#L449'>contains_uppercase</a><span class="Delimiter">(</span>s<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L290" class="LineNr">290 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"uppercase hex not allowed: "</span> << s << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L291" class="LineNr">291 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L292" class="LineNr">292 </span> <span class="Delimiter">}</span> +<span id="L293" class="LineNr">293 </span> istringstream in<span class="Delimiter">(</span>s<span class="Delimiter">);</span> +<span id="L294" class="LineNr">294 </span> <span class="Normal">int</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L295" class="LineNr">295 </span> in >> std::hex >> result<span class="Delimiter">;</span> +<span id="L296" class="LineNr">296 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!in || !in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L297" class="LineNr">297 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"token '"</span> << s << <span class="Constant">"' is not a hex byte\n"</span> << end<span class="Delimiter">();</span> +<span id="L298" class="LineNr">298 </span> <span class="Identifier">return</span> <span class="cSpecial">'\0'</span><span class="Delimiter">;</span> +<span id="L299" class="LineNr">299 </span> <span class="Delimiter">}</span> +<span id="L300" class="LineNr">300 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result > <span class="Constant">0xff</span> || result < -<span class="Constant">0x8f</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L301" class="LineNr">301 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"token '"</span> << s << <span class="Constant">"' is not a hex byte\n"</span> << end<span class="Delimiter">();</span> +<span id="L302" class="LineNr">302 </span> <span class="Identifier">return</span> <span class="cSpecial">'\0'</span><span class="Delimiter">;</span> +<span id="L303" class="LineNr">303 </span> <span class="Delimiter">}</span> +<span id="L304" class="LineNr">304 </span> <span class="Identifier">return</span> <span class="Normal">static_cast</span><<span class="Normal">uint8_t</span>><span class="Delimiter">(</span>result<span class="Delimiter">);</span> +<span id="L305" class="LineNr">305 </span><span class="Delimiter">}</span> +<span id="L306" class="LineNr">306 </span> +<span id="L307" class="LineNr">307 </span><span class="Normal">void</span> <a href='011run.cc.html#L307'>test_number_too_large</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L308" class="LineNr">308 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L309" class="LineNr">309 </span> <a href='011run.cc.html#L397'>parse_and_load</a><span class="Delimiter">(</span> +<span id="L310" class="LineNr">310 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L311" class="LineNr">311 </span> <span class="Constant">"01 cab\n"</span> +<span id="L312" class="LineNr">312 </span> <span class="Delimiter">);</span> +<span id="L313" class="LineNr">313 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L314" class="LineNr">314 </span> <span class="Constant">"error: token 'cab' is not a hex byte\n"</span> +<span id="L315" class="LineNr">315 </span> <span class="Delimiter">);</span> +<span id="L316" class="LineNr">316 </span><span class="Delimiter">}</span> +<span id="L317" class="LineNr">317 </span> +<span id="L318" class="LineNr">318 </span><span class="Normal">void</span> <a href='011run.cc.html#L318'>test_invalid_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L319" class="LineNr">319 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L320" class="LineNr">320 </span> <a href='011run.cc.html#L397'>parse_and_load</a><span class="Delimiter">(</span> +<span id="L321" class="LineNr">321 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L322" class="LineNr">322 </span> <span class="Constant">"01 cx\n"</span> +<span id="L323" class="LineNr">323 </span> <span class="Delimiter">);</span> +<span id="L324" class="LineNr">324 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L325" class="LineNr">325 </span> <span class="Constant">"error: token 'cx' is not a hex byte\n"</span> <span id="L326" class="LineNr">326 </span> <span class="Delimiter">);</span> -<span id="L327" class="LineNr">327 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L328" class="LineNr">328 </span> <span class="Constant">"error: token 'cab' is not a hex byte\n"</span> -<span id="L329" class="LineNr">329 </span> <span class="Delimiter">);</span> -<span id="L330" class="LineNr">330 </span><span class="Delimiter">}</span> -<span id="L331" class="LineNr">331 </span> -<span id="L332" class="LineNr">332 </span><span class="Normal">void</span> <a href='011run.cc.html#L332'>test_invalid_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L333" class="LineNr">333 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L334" class="LineNr">334 </span> <a href='011run.cc.html#L411'>parse_and_load</a><span class="Delimiter">(</span> -<span id="L335" class="LineNr">335 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L336" class="LineNr">336 </span> <span class="Constant">"01 cx\n"</span> -<span id="L337" class="LineNr">337 </span> <span class="Delimiter">);</span> -<span id="L338" class="LineNr">338 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L339" class="LineNr">339 </span> <span class="Constant">"error: token 'cx' is not a hex byte\n"</span> -<span id="L340" class="LineNr">340 </span> <span class="Delimiter">);</span> -<span id="L341" class="LineNr">341 </span><span class="Delimiter">}</span> -<span id="L342" class="LineNr">342 </span> -<span id="L343" class="LineNr">343 </span><span class="Normal">void</span> <a href='011run.cc.html#L343'>test_negative_number</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L344" class="LineNr">344 </span> <a href='011run.cc.html#L411'>parse_and_load</a><span class="Delimiter">(</span> -<span id="L345" class="LineNr">345 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L346" class="LineNr">346 </span> <span class="Constant">"01 -02\n"</span> -<span id="L347" class="LineNr">347 </span> <span class="Delimiter">);</span> -<span id="L348" class="LineNr">348 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"error"</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L349" class="LineNr">349 </span><span class="Delimiter">}</span> -<span id="L350" class="LineNr">350 </span> -<span id="L351" class="LineNr">351 </span><span class="Normal">void</span> <a href='011run.cc.html#L351'>test_negative_number_too_small</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L352" class="LineNr">352 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L353" class="LineNr">353 </span> <a href='011run.cc.html#L411'>parse_and_load</a><span class="Delimiter">(</span> -<span id="L354" class="LineNr">354 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L355" class="LineNr">355 </span> <span class="Constant">"01 -12345\n"</span> -<span id="L356" class="LineNr">356 </span> <span class="Delimiter">);</span> -<span id="L357" class="LineNr">357 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L358" class="LineNr">358 </span> <span class="Constant">"error: token '-12345' is not a hex byte\n"</span> -<span id="L359" class="LineNr">359 </span> <span class="Delimiter">);</span> -<span id="L360" class="LineNr">360 </span><span class="Delimiter">}</span> -<span id="L361" class="LineNr">361 </span> -<span id="L362" class="LineNr">362 </span><span class="Normal">void</span> <a href='011run.cc.html#L362'>test_hex_prefix</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L363" class="LineNr">363 </span> <a href='011run.cc.html#L411'>parse_and_load</a><span class="Delimiter">(</span> -<span id="L364" class="LineNr">364 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L365" class="LineNr">365 </span> <span class="Constant">"0x01 -0x02\n"</span> -<span id="L366" class="LineNr">366 </span> <span class="Delimiter">);</span> -<span id="L367" class="LineNr">367 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"error"</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L368" class="LineNr">368 </span><span class="Delimiter">}</span> -<span id="L369" class="LineNr">369 </span> -<span id="L370" class="LineNr">370 </span><span class="Normal">void</span> <a href='011run.cc.html#L370'>test_repeated_segment_merges_data</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L371" class="LineNr">371 </span> <a href='011run.cc.html#L411'>parse_and_load</a><span class="Delimiter">(</span> -<span id="L372" class="LineNr">372 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L373" class="LineNr">373 </span> <span class="Constant">"11 22\n"</span> -<span id="L374" class="LineNr">374 </span> <span class="Constant">"== code\n"</span> <span class="Comment">// again</span> -<span id="L375" class="LineNr">375 </span> <span class="Constant">"33 44\n"</span> -<span id="L376" class="LineNr">376 </span> <span class="Delimiter">);</span> -<span id="L377" class="LineNr">377 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L378" class="LineNr">378 </span> <span class="Constant">"parse: new segment 'code'\n"</span> -<span id="L379" class="LineNr">379 </span> <span class="Constant">"parse: appending to segment 'code'\n"</span> -<span id="L380" class="LineNr">380 </span> <span class="Comment">// first segment</span> -<span id="L381" class="LineNr">381 </span> <span class="Constant">"load: 0x00000001 -> 11\n"</span> -<span id="L382" class="LineNr">382 </span> <span class="Constant">"load: 0x00000002 -> 22\n"</span> -<span id="L383" class="LineNr">383 </span> <span class="Comment">// second segment</span> -<span id="L384" class="LineNr">384 </span> <span class="Constant">"load: 0x00000003 -> 33\n"</span> -<span id="L385" class="LineNr">385 </span> <span class="Constant">"load: 0x00000004 -> 44\n"</span> -<span id="L386" class="LineNr">386 </span> <span class="Delimiter">);</span> -<span id="L387" class="LineNr">387 </span><span class="Delimiter">}</span> -<span id="L388" class="LineNr">388 </span> -<span id="L389" class="LineNr">389 </span><span class="Normal">void</span> <a href='011run.cc.html#L389'>test_error_on_missing_segment_header</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L390" class="LineNr">390 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L391" class="LineNr">391 </span> <a href='011run.cc.html#L411'>parse_and_load</a><span class="Delimiter">(</span> -<span id="L392" class="LineNr">392 </span> <span class="Constant">"01 02\n"</span> +<span id="L327" class="LineNr">327 </span><span class="Delimiter">}</span> +<span id="L328" class="LineNr">328 </span> +<span id="L329" class="LineNr">329 </span><span class="Normal">void</span> <a href='011run.cc.html#L329'>test_negative_number</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L330" class="LineNr">330 </span> <a href='011run.cc.html#L397'>parse_and_load</a><span class="Delimiter">(</span> +<span id="L331" class="LineNr">331 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L332" class="LineNr">332 </span> <span class="Constant">"01 -02\n"</span> +<span id="L333" class="LineNr">333 </span> <span class="Delimiter">);</span> +<span id="L334" class="LineNr">334 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"error"</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L335" class="LineNr">335 </span><span class="Delimiter">}</span> +<span id="L336" class="LineNr">336 </span> +<span id="L337" class="LineNr">337 </span><span class="Normal">void</span> <a href='011run.cc.html#L337'>test_negative_number_too_small</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L338" class="LineNr">338 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L339" class="LineNr">339 </span> <a href='011run.cc.html#L397'>parse_and_load</a><span class="Delimiter">(</span> +<span id="L340" class="LineNr">340 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L341" class="LineNr">341 </span> <span class="Constant">"01 -12345\n"</span> +<span id="L342" class="LineNr">342 </span> <span class="Delimiter">);</span> +<span id="L343" class="LineNr">343 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L344" class="LineNr">344 </span> <span class="Constant">"error: token '-12345' is not a hex byte\n"</span> +<span id="L345" class="LineNr">345 </span> <span class="Delimiter">);</span> +<span id="L346" class="LineNr">346 </span><span class="Delimiter">}</span> +<span id="L347" class="LineNr">347 </span> +<span id="L348" class="LineNr">348 </span><span class="Normal">void</span> <a href='011run.cc.html#L348'>test_hex_prefix</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L349" class="LineNr">349 </span> <a href='011run.cc.html#L397'>parse_and_load</a><span class="Delimiter">(</span> +<span id="L350" class="LineNr">350 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L351" class="LineNr">351 </span> <span class="Constant">"0x01 -0x02\n"</span> +<span id="L352" class="LineNr">352 </span> <span class="Delimiter">);</span> +<span id="L353" class="LineNr">353 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"error"</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L354" class="LineNr">354 </span><span class="Delimiter">}</span> +<span id="L355" class="LineNr">355 </span> +<span id="L356" class="LineNr">356 </span><span class="Normal">void</span> <a href='011run.cc.html#L356'>test_repeated_segment_merges_data</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L357" class="LineNr">357 </span> <a href='011run.cc.html#L397'>parse_and_load</a><span class="Delimiter">(</span> +<span id="L358" class="LineNr">358 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L359" class="LineNr">359 </span> <span class="Constant">"11 22\n"</span> +<span id="L360" class="LineNr">360 </span> <span class="Constant">"== code\n"</span> <span class="Comment">// again</span> +<span id="L361" class="LineNr">361 </span> <span class="Constant">"33 44\n"</span> +<span id="L362" class="LineNr">362 </span> <span class="Delimiter">);</span> +<span id="L363" class="LineNr">363 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L364" class="LineNr">364 </span> <span class="Constant">"parse: new segment 'code'\n"</span> +<span id="L365" class="LineNr">365 </span> <span class="Constant">"parse: appending to segment 'code'\n"</span> +<span id="L366" class="LineNr">366 </span> <span class="Comment">// first segment</span> +<span id="L367" class="LineNr">367 </span> <span class="Constant">"load: 0x00000001 -> 11\n"</span> +<span id="L368" class="LineNr">368 </span> <span class="Constant">"load: 0x00000002 -> 22\n"</span> +<span id="L369" class="LineNr">369 </span> <span class="Comment">// second segment</span> +<span id="L370" class="LineNr">370 </span> <span class="Constant">"load: 0x00000003 -> 33\n"</span> +<span id="L371" class="LineNr">371 </span> <span class="Constant">"load: 0x00000004 -> 44\n"</span> +<span id="L372" class="LineNr">372 </span> <span class="Delimiter">);</span> +<span id="L373" class="LineNr">373 </span><span class="Delimiter">}</span> +<span id="L374" class="LineNr">374 </span> +<span id="L375" class="LineNr">375 </span><span class="Normal">void</span> <a href='011run.cc.html#L375'>test_error_on_missing_segment_header</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L376" class="LineNr">376 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L377" class="LineNr">377 </span> <a href='011run.cc.html#L397'>parse_and_load</a><span class="Delimiter">(</span> +<span id="L378" class="LineNr">378 </span> <span class="Constant">"01 02\n"</span> +<span id="L379" class="LineNr">379 </span> <span class="Delimiter">);</span> +<span id="L380" class="LineNr">380 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L381" class="LineNr">381 </span> <span class="Constant">"error: input does not start with a '==' section header\n"</span> +<span id="L382" class="LineNr">382 </span> <span class="Delimiter">);</span> +<span id="L383" class="LineNr">383 </span><span class="Delimiter">}</span> +<span id="L384" class="LineNr">384 </span> +<span id="L385" class="LineNr">385 </span><span class="Normal">void</span> <a href='011run.cc.html#L385'>test_error_on_uppercase_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L386" class="LineNr">386 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L387" class="LineNr">387 </span> <a href='011run.cc.html#L397'>parse_and_load</a><span class="Delimiter">(</span> +<span id="L388" class="LineNr">388 </span> <span class="Constant">"== code\n"</span> +<span id="L389" class="LineNr">389 </span> <span class="Constant">"01 Ab\n"</span> +<span id="L390" class="LineNr">390 </span> <span class="Delimiter">);</span> +<span id="L391" class="LineNr">391 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L392" class="LineNr">392 </span> <span class="Constant">"error: uppercase hex not allowed: Ab\n"</span> <span id="L393" class="LineNr">393 </span> <span class="Delimiter">);</span> -<span id="L394" class="LineNr">394 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L395" class="LineNr">395 </span> <span class="Constant">"error: input does not start with a '==' section header\n"</span> -<span id="L396" class="LineNr">396 </span> <span class="Delimiter">);</span> -<span id="L397" class="LineNr">397 </span><span class="Delimiter">}</span> -<span id="L398" class="LineNr">398 </span> -<span id="L399" class="LineNr">399 </span><span class="Normal">void</span> <a href='011run.cc.html#L399'>test_error_on_uppercase_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L400" class="LineNr">400 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L401" class="LineNr">401 </span> <a href='011run.cc.html#L411'>parse_and_load</a><span class="Delimiter">(</span> -<span id="L402" class="LineNr">402 </span> <span class="Constant">"== code\n"</span> -<span id="L403" class="LineNr">403 </span> <span class="Constant">"01 Ab\n"</span> -<span id="L404" class="LineNr">404 </span> <span class="Delimiter">);</span> -<span id="L405" class="LineNr">405 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L406" class="LineNr">406 </span> <span class="Constant">"error: uppercase hex not allowed: Ab\n"</span> -<span id="L407" class="LineNr">407 </span> <span class="Delimiter">);</span> -<span id="L408" class="LineNr">408 </span><span class="Delimiter">}</span> +<span id="L394" class="LineNr">394 </span><span class="Delimiter">}</span> +<span id="L395" class="LineNr">395 </span> +<span id="L396" class="LineNr">396 </span><span class="Comment">//: helper for tests</span> +<span id="L397" class="LineNr">397 </span><span class="Normal">void</span> <a href='011run.cc.html#L397'>parse_and_load</a><span class="Delimiter">(</span><span class="Normal">const</span> string& text_bytes<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L398" class="LineNr">398 </span> program p<span class="Delimiter">;</span> +<span id="L399" class="LineNr">399 </span> istringstream in<span class="Delimiter">(</span>text_bytes<span class="Delimiter">);</span> +<span id="L400" class="LineNr">400 </span> parse<span class="Delimiter">(</span>in<span class="Delimiter">,</span> p<span class="Delimiter">);</span> +<span id="L401" class="LineNr">401 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// if any stage raises errors, stop immediately</span> +<span id="L402" class="LineNr">402 </span> <a href='011run.cc.html#L248'>load</a><span class="Delimiter">(</span>p<span class="Delimiter">);</span> +<span id="L403" class="LineNr">403 </span><span class="Delimiter">}</span> +<span id="L404" class="LineNr">404 </span> +<span id="L405" class="LineNr">405 </span><span class="SalientComment">//:: run</span> +<span id="L406" class="LineNr">406 </span> +<span id="L407" class="LineNr">407 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> +<span id="L408" class="LineNr">408 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"b8"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L10'>EAX</a> (mov)"</span><span class="Delimiter">);</span> <span id="L409" class="LineNr">409 </span> -<span id="L410" class="LineNr">410 </span><span class="Comment">//: helper for tests</span> -<span id="L411" class="LineNr">411 </span><span class="Normal">void</span> <a href='011run.cc.html#L411'>parse_and_load</a><span class="Delimiter">(</span><span class="Normal">const</span> string& text_bytes<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L412" class="LineNr">412 </span> program p<span class="Delimiter">;</span> -<span id="L413" class="LineNr">413 </span> istringstream in<span class="Delimiter">(</span>text_bytes<span class="Delimiter">);</span> -<span id="L414" class="LineNr">414 </span> parse<span class="Delimiter">(</span>in<span class="Delimiter">,</span> p<span class="Delimiter">);</span> -<span id="L415" class="LineNr">415 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// if any stage raises errors, stop immediately</span> -<span id="L416" class="LineNr">416 </span> <a href='011run.cc.html#L262'>load</a><span class="Delimiter">(</span>p<span class="Delimiter">);</span> -<span id="L417" class="LineNr">417 </span><span class="Delimiter">}</span> -<span id="L418" class="LineNr">418 </span> -<span id="L419" class="LineNr">419 </span><span class="SalientComment">//:: run</span> -<span id="L420" class="LineNr">420 </span> -<span id="L421" class="LineNr">421 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L422" class="LineNr">422 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"b8"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L16'>EAX</a> (mov)"</span><span class="Delimiter">);</span> -<span id="L423" class="LineNr">423 </span> -<span id="L424" class="LineNr">424 </span><span class="Comment">//: our first opcode</span> -<span id="L425" class="LineNr">425 </span> -<span id="L426" class="LineNr">426 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> -<span id="L427" class="LineNr">427 </span><span class="Normal">case</span> <span class="Constant">0xb8</span>: <span class="Delimiter">{</span> <span class="Comment">// copy imm32 to EAX</span> -<span id="L428" class="LineNr">428 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> src = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L429" class="LineNr">429 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy imm32 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << src << <span class="Constant">" to EAX"</span> << end<span class="Delimiter">();</span> -<span id="L430" class="LineNr">430 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = src<span class="Delimiter">;</span> -<span id="L431" class="LineNr">431 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L432" class="LineNr">432 </span><span class="Delimiter">}</span> -<span id="L433" class="LineNr">433 </span> -<span id="L434" class="LineNr">434 </span><span class="Delimiter">:(code)</span> -<span id="L435" class="LineNr">435 </span><span class="Normal">void</span> <a href='011run.cc.html#L435'>test_copy_imm32_to_EAX_again</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L436" class="LineNr">436 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> -<span id="L437" class="LineNr">437 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> -<span id="L438" class="LineNr">438 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> -<span id="L439" class="LineNr">439 </span> <span class="Constant">" b8 0a 0b 0c 0d \n"</span> <span class="Comment">// copy 0x0d0c0b0a to EAX</span> -<span id="L440" class="LineNr">440 </span> <span class="Delimiter">);</span> -<span id="L441" class="LineNr">441 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L442" class="LineNr">442 </span> <span class="Constant">"run: copy imm32 0x0d0c0b0a to EAX\n"</span> -<span id="L443" class="LineNr">443 </span> <span class="Delimiter">);</span> -<span id="L444" class="LineNr">444 </span><span class="Delimiter">}</span> -<span id="L445" class="LineNr">445 </span> -<span id="L446" class="LineNr">446 </span><span class="Comment">// read a 32-bit int in little-endian order from the instruction stream</span> -<span id="L447" class="LineNr">447 </span><span class="Normal">int32_t</span> <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L448" class="LineNr">448 </span> <span class="Normal">int32_t</span> result = <a href='010---vm.cc.html#L182'>read_mem_i32</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">);</span> -<span id="L449" class="LineNr">449 </span> EIP+=<span class="Constant">4</span><span class="Delimiter">;</span> -<span id="L450" class="LineNr">450 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L451" class="LineNr">451 </span><span class="Delimiter">}</span> -<span id="L452" class="LineNr">452 </span> -<span id="L453" class="LineNr">453 </span><span class="SalientComment">//:: helpers</span> -<span id="L454" class="LineNr">454 </span> -<span id="L455" class="LineNr">455 </span>string to_string<span class="Delimiter">(</span><span class="Normal">const</span> word& w<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L456" class="LineNr">456 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L457" class="LineNr">457 </span> out << w<span class="Delimiter">.</span>data<span class="Delimiter">;</span> -<span id="L458" class="LineNr">458 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L459" class="LineNr">459 </span> out << <span class="Constant">" /"</span> << w<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L460" class="LineNr">460 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L461" class="LineNr">461 </span><span class="Delimiter">}</span> -<span id="L462" class="LineNr">462 </span> -<span id="L463" class="LineNr">463 </span><span class="Normal">bool</span> <a href='011run.cc.html#L463'>contains_uppercase</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L464" class="LineNr">464 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L465" class="LineNr">465 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>isupper<span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L466" class="LineNr">466 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L467" class="LineNr">467 </span><span class="Delimiter">}</span> +<span id="L410" class="LineNr">410 </span><span class="Comment">//: our first opcode</span> +<span id="L411" class="LineNr">411 </span> +<span id="L412" class="LineNr">412 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> +<span id="L413" class="LineNr">413 </span><span class="Normal">case</span> <span class="Constant">0xb8</span>: <span class="Delimiter">{</span> <span class="Comment">// copy imm32 to EAX</span> +<span id="L414" class="LineNr">414 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> src = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L415" class="LineNr">415 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy imm32 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << src << <span class="Constant">" to EAX"</span> << end<span class="Delimiter">();</span> +<span id="L416" class="LineNr">416 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = src<span class="Delimiter">;</span> +<span id="L417" class="LineNr">417 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L418" class="LineNr">418 </span><span class="Delimiter">}</span> +<span id="L419" class="LineNr">419 </span> +<span id="L420" class="LineNr">420 </span><span class="Delimiter">:(code)</span> +<span id="L421" class="LineNr">421 </span><span class="Normal">void</span> <a href='011run.cc.html#L421'>test_copy_imm32_to_EAX_again</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L422" class="LineNr">422 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> +<span id="L423" class="LineNr">423 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> +<span id="L424" class="LineNr">424 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> +<span id="L425" class="LineNr">425 </span> <span class="Constant">" b8 0a 0b 0c 0d \n"</span> <span class="Comment">// copy 0x0d0c0b0a to EAX</span> +<span id="L426" class="LineNr">426 </span> <span class="Delimiter">);</span> +<span id="L427" class="LineNr">427 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L428" class="LineNr">428 </span> <span class="Constant">"run: copy imm32 0x0d0c0b0a to EAX\n"</span> +<span id="L429" class="LineNr">429 </span> <span class="Delimiter">);</span> +<span id="L430" class="LineNr">430 </span><span class="Delimiter">}</span> +<span id="L431" class="LineNr">431 </span> +<span id="L432" class="LineNr">432 </span><span class="Comment">// read a 32-bit int in little-endian order from the instruction stream</span> +<span id="L433" class="LineNr">433 </span><span class="Normal">int32_t</span> <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L434" class="LineNr">434 </span> <span class="Normal">int32_t</span> result = <a href='010---vm.cc.html#L176'>read_mem_i32</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">);</span> +<span id="L435" class="LineNr">435 </span> EIP+=<span class="Constant">4</span><span class="Delimiter">;</span> +<span id="L436" class="LineNr">436 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L437" class="LineNr">437 </span><span class="Delimiter">}</span> +<span id="L438" class="LineNr">438 </span> +<span id="L439" class="LineNr">439 </span><span class="SalientComment">//:: helpers</span> +<span id="L440" class="LineNr">440 </span> +<span id="L441" class="LineNr">441 </span>string to_string<span class="Delimiter">(</span><span class="Normal">const</span> word& w<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L442" class="LineNr">442 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L443" class="LineNr">443 </span> out << w<span class="Delimiter">.</span>data<span class="Delimiter">;</span> +<span id="L444" class="LineNr">444 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L445" class="LineNr">445 </span> out << <span class="Constant">" /"</span> << w<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L446" class="LineNr">446 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L447" class="LineNr">447 </span><span class="Delimiter">}</span> +<span id="L448" class="LineNr">448 </span> +<span id="L449" class="LineNr">449 </span><span class="Normal">bool</span> <a href='011run.cc.html#L449'>contains_uppercase</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L450" class="LineNr">450 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L451" class="LineNr">451 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>isupper<span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L452" class="LineNr">452 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L453" class="LineNr">453 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/012elf.cc.html b/html/012elf.cc.html index 2aaa61ab..2b8d8236 100644 --- a/html/012elf.cc.html +++ b/html/012elf.cc.html @@ -65,7 +65,7 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span> <span id="L5" class="LineNr"> 5 </span><span class="Delimiter">:(before "End Main")</span> <span id="L6" class="LineNr"> 6 </span>assert<span class="Delimiter">(</span>argc > <span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L7" class="LineNr"> 7 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L101'>is_equal</a><span class="Delimiter">(</span>argv[<span class="Constant">1</span>]<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L7" class="LineNr"> 7 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L102'>is_equal</a><span class="Delimiter">(</span>argv[<span class="Constant">1</span>]<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L8" class="LineNr"> 8 </span> <span class="Comment">// Outside of tests, traces must be explicitly requested.</span> <span id="L9" class="LineNr"> 9 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">.</span>is_open<span class="Delimiter">())</span> <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span> = <span class="Normal">new</span> trace_stream<span class="Delimiter">;</span> <span id="L10" class="LineNr"> 10 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"=== Starting to run"</span> << end<span class="Delimiter">();</span> @@ -75,9 +75,9 @@ if ('onhashchange' in window) { <span id="L14" class="LineNr"> 14 </span> <a href='000organization.cc.html#L150'>reset</a><span class="Delimiter">();</span> <span id="L15" class="LineNr"> 15 </span> cerr << std::hex<span class="Delimiter">;</span> <span id="L16" class="LineNr"> 16 </span> <a href='012elf.cc.html#L24'>load_elf</a><span class="Delimiter">(</span>argv[<span class="Constant">2</span>]<span class="Delimiter">,</span> argc<span class="Delimiter">,</span> argv<span class="Delimiter">);</span> -<span id="L17" class="LineNr"> 17 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L32'>EIP</a> < <span class="Special"><a href='010---vm.cc.html#L163'>End_of_program</a></span><span class="Delimiter">)</span> <span class="Comment">// weak final-gasp termination check</span> -<span id="L18" class="LineNr"> 18 </span> <a href='010---vm.cc.html#L270'>run_one_instruction</a><span class="Delimiter">();</span> -<span id="L19" class="LineNr"> 19 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"executed past end of the world: "</span> << <a href='010---vm.cc.html#L32'>EIP</a> << <span class="Constant">" vs "</span> << <span class="Special"><a href='010---vm.cc.html#L163'>End_of_program</a></span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L17" class="LineNr"> 17 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L26'>EIP</a> < <span class="Special"><a href='010---vm.cc.html#L157'>End_of_program</a></span><span class="Delimiter">)</span> <span class="Comment">// weak final-gasp termination check</span> +<span id="L18" class="LineNr"> 18 </span> <a href='010---vm.cc.html#L264'>run_one_instruction</a><span class="Delimiter">();</span> +<span id="L19" class="LineNr"> 19 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"executed past end of the world: "</span> << <a href='010---vm.cc.html#L26'>EIP</a> << <span class="Constant">" vs "</span> << <span class="Special"><a href='010---vm.cc.html#L157'>End_of_program</a></span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L20" class="LineNr"> 20 </span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> <span id="L21" class="LineNr"> 21 </span><span class="Delimiter">}</span> <span id="L22" class="LineNr"> 22 </span> @@ -107,7 +107,7 @@ if ('onhashchange' in window) { <span id="L46" class="LineNr"> 46 </span> <span class="Comment">// unused: remaining 10 bytes of e_ident</span> <span id="L47" class="LineNr"> 47 </span> <span class="Normal">uint32_t</span> e_machine_type = <a href='012elf.cc.html#L170'>u32_in</a><span class="Delimiter">(</span>&elf_contents[<span class="Constant">16</span>]<span class="Delimiter">);</span> <span id="L48" class="LineNr"> 48 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>e_machine_type != <span class="Constant">0x00030002</span><span class="Delimiter">)</span> -<span id="L49" class="LineNr"> 49 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"ELF type/machine 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << e_machine_type << <span class="Constant">" isn't i386 executable\n"</span> << die<span class="Delimiter">();</span> +<span id="L49" class="LineNr"> 49 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"ELF type/machine 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << e_machine_type << <span class="Constant">" isn't i386 executable\n"</span> << die<span class="Delimiter">();</span> <span id="L50" class="LineNr"> 50 </span> <span class="Comment">// unused: e_version. We only support version 1, and later versions will be backwards compatible.</span> <span id="L51" class="LineNr"> 51 </span> <span class="Normal">uint32_t</span> e_entry = <a href='012elf.cc.html#L170'>u32_in</a><span class="Delimiter">(</span>&elf_contents[<span class="Constant">24</span>]<span class="Delimiter">);</span> <span id="L52" class="LineNr"> 52 </span> <span class="Normal">uint32_t</span> e_phoff = <a href='012elf.cc.html#L170'>u32_in</a><span class="Delimiter">(</span>&elf_contents[<span class="Constant">28</span>]<span class="Delimiter">);</span> @@ -128,41 +128,41 @@ if ('onhashchange' in window) { <span id="L67" class="LineNr"> 67 </span> <span id="L68" class="LineNr"> 68 </span> <span class="Comment">// initialize code and stack</span> <span id="L69" class="LineNr"> 69 </span> assert<span class="Delimiter">(</span>overlap<span class="Delimiter">.</span>find<span class="Delimiter">(</span><a href='012elf.cc.html#L152'>STACK_SEGMENT</a><span class="Delimiter">)</span> == overlap<span class="Delimiter">.</span>end<span class="Delimiter">());</span> -<span id="L70" class="LineNr"> 70 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><a href='012elf.cc.html#L152'>STACK_SEGMENT</a><span class="Delimiter">));</span> +<span id="L70" class="LineNr"> 70 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><a href='012elf.cc.html#L152'>STACK_SEGMENT</a><span class="Delimiter">));</span> <span id="L71" class="LineNr"> 71 </span> assert<span class="Delimiter">(</span>overlap<span class="Delimiter">.</span>find<span class="Delimiter">(</span><a href='012elf.cc.html#L153'>AFTER_STACK</a><span class="Delimiter">)</span> == overlap<span class="Delimiter">.</span>end<span class="Delimiter">());</span> <span id="L72" class="LineNr"> 72 </span> <span class="Comment">// The stack grows downward.</span> -<span id="L73" class="LineNr"> 73 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <a href='012elf.cc.html#L153'>AFTER_STACK</a><span class="Delimiter">;</span> -<span id="L74" class="LineNr"> 74 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBP]<span class="Delimiter">.</span>u = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L75" class="LineNr"> 75 </span> <a href='010---vm.cc.html#L32'>EIP</a> = e_entry<span class="Delimiter">;</span> +<span id="L73" class="LineNr"> 73 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <a href='012elf.cc.html#L153'>AFTER_STACK</a><span class="Delimiter">;</span> +<span id="L74" class="LineNr"> 74 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBP]<span class="Delimiter">.</span>u = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L75" class="LineNr"> 75 </span> <a href='010---vm.cc.html#L26'>EIP</a> = e_entry<span class="Delimiter">;</span> <span id="L76" class="LineNr"> 76 </span> <span id="L77" class="LineNr"> 77 </span> <span class="Comment">// initialize args on stack</span> <span id="L78" class="LineNr"> 78 </span> <span class="Comment">// no envp for now</span> <span id="L79" class="LineNr"> 79 </span> <span class="Comment">// we wastefully use a separate page of memory for argv</span> -<span id="L80" class="LineNr"> 80 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><a href='012elf.cc.html#L154'>ARGV_DATA_SEGMENT</a><span class="Delimiter">));</span> +<span id="L80" class="LineNr"> 80 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><a href='012elf.cc.html#L154'>ARGV_DATA_SEGMENT</a><span class="Delimiter">));</span> <span id="L81" class="LineNr"> 81 </span> <span class="Normal">uint32_t</span> argv_data = <a href='012elf.cc.html#L154'>ARGV_DATA_SEGMENT</a><span class="Delimiter">;</span> <span id="L82" class="LineNr"> 82 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = argc-<span class="Constant">1</span><span class="Delimiter">;</span> i >= <span class="Comment">/*</span><span class="Comment">skip 'subx_bin' and 'run'</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">;</span> --i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L83" class="LineNr"> 83 </span> <a href='012elf.cc.html#L94'>push</a><span class="Delimiter">(</span>argv_data<span class="Delimiter">);</span> <span id="L84" class="LineNr"> 84 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j <= strlen<span class="Delimiter">(</span>argv[i]<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L85" class="LineNr"> 85 </span> assert<span class="Delimiter">(</span>overlap<span class="Delimiter">.</span>find<span class="Delimiter">(</span>argv_data<span class="Delimiter">)</span> == overlap<span class="Delimiter">.</span>end<span class="Delimiter">());</span> <span class="Comment">// don't bother comparing ARGV and STACK</span> -<span id="L86" class="LineNr"> 86 </span> <a href='010---vm.cc.html#L237'>write_mem_u8</a><span class="Delimiter">(</span>argv_data<span class="Delimiter">,</span> argv[i][j]<span class="Delimiter">);</span> +<span id="L86" class="LineNr"> 86 </span> <a href='010---vm.cc.html#L231'>write_mem_u8</a><span class="Delimiter">(</span>argv_data<span class="Delimiter">,</span> argv[i][j]<span class="Delimiter">);</span> <span id="L87" class="LineNr"> 87 </span> argv_data += <span class="Normal">sizeof</span><span class="Delimiter">(</span><span class="Normal">char</span><span class="Delimiter">);</span> -<span id="L88" class="LineNr"> 88 </span> assert<span class="Delimiter">(</span>argv_data < <a href='012elf.cc.html#L154'>ARGV_DATA_SEGMENT</a> + <a href='010---vm.cc.html#L95'>SEGMENT_ALIGNMENT</a><span class="Delimiter">);</span> +<span id="L88" class="LineNr"> 88 </span> assert<span class="Delimiter">(</span>argv_data < <a href='012elf.cc.html#L154'>ARGV_DATA_SEGMENT</a> + <a href='010---vm.cc.html#L89'>SEGMENT_ALIGNMENT</a><span class="Delimiter">);</span> <span id="L89" class="LineNr"> 89 </span> <span class="Delimiter">}</span> <span id="L90" class="LineNr"> 90 </span> <span class="Delimiter">}</span> <span id="L91" class="LineNr"> 91 </span> <a href='012elf.cc.html#L94'>push</a><span class="Delimiter">(</span>argc-<span class="Comment">/*</span><span class="Comment">skip 'subx_bin' and 'run'</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">);</span> <span id="L92" class="LineNr"> 92 </span><span class="Delimiter">}</span> <span id="L93" class="LineNr"> 93 </span> <span id="L94" class="LineNr"> 94 </span><span class="Normal">void</span> <a href='012elf.cc.html#L94'>push</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L95" class="LineNr"> 95 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u -= <span class="Constant">4</span><span class="Delimiter">;</span> -<span id="L96" class="LineNr"> 96 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u < <a href='012elf.cc.html#L152'>STACK_SEGMENT</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L95" class="LineNr"> 95 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u -= <span class="Constant">4</span><span class="Delimiter">;</span> +<span id="L96" class="LineNr"> 96 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u < <a href='012elf.cc.html#L152'>STACK_SEGMENT</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L97" class="LineNr"> 97 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"The stack overflowed its segment. "</span> <span id="L98" class="LineNr"> 98 </span> << <span class="Constant">"Maybe SPACE_FOR_SEGMENT should be larger? "</span> <span id="L99" class="LineNr"> 99 </span> << <span class="Constant">"Or you need to carve out an exception for the stack segment "</span> <span id="L100" class="LineNr">100 </span> << <span class="Constant">"to be larger.\n"</span> << <a href='003trace.cc.html#L173'>die</a><span class="Delimiter">();</span> <span id="L101" class="LineNr">101 </span> <span class="Delimiter">}</span> -<span id="L102" class="LineNr">102 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"decrementing <a href='010---vm.cc.html#L20'>ESP</a> to 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> -<span id="L103" class="LineNr">103 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pushing value 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << val << end<span class="Delimiter">();</span> -<span id="L104" class="LineNr">104 </span> <a href='010---vm.cc.html#L245'>write_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> val<span class="Delimiter">);</span> +<span id="L102" class="LineNr">102 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"decrementing <a href='010---vm.cc.html#L14'>ESP</a> to 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L103" class="LineNr">103 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pushing value 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << val << end<span class="Delimiter">();</span> +<span id="L104" class="LineNr">104 </span> <a href='010---vm.cc.html#L239'>write_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> val<span class="Delimiter">);</span> <span id="L105" class="LineNr">105 </span><span class="Delimiter">}</span> <span id="L106" class="LineNr">106 </span> <span id="L107" class="LineNr">107 </span><span class="Normal">void</span> <a href='012elf.cc.html#L107'>load_segment_from_program_header</a><span class="Delimiter">(</span><span class="Normal">uint8_t</span>* elf_contents<span class="Delimiter">,</span> <span class="Normal">int</span> segment_index<span class="Delimiter">,</span> <span class="Normal">size_t</span> size<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> offset<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> e_ehsize<span class="Delimiter">,</span> set<<span class="Normal">uint32_t</span>>& overlap<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -183,20 +183,20 @@ if ('onhashchange' in window) { <span id="L122" class="LineNr">122 </span> <span id="L123" class="LineNr">123 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p_offset + p_filesz > size<span class="Delimiter">)</span> <span id="L124" class="LineNr">124 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"Invalid binary; segment at offset "</span> << offset << <span class="Constant">" is too large: wants to end at "</span> << p_offset+p_filesz << <span class="Constant">" but the file ends at "</span> << size << <span class="cSpecial">'\n'</span> << <a href='003trace.cc.html#L173'>die</a><span class="Delimiter">();</span> -<span id="L125" class="LineNr">125 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p_memsz >= <a href='010---vm.cc.html#L95'>SEGMENT_ALIGNMENT</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L125" class="LineNr">125 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p_memsz >= <a href='010---vm.cc.html#L89'>SEGMENT_ALIGNMENT</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L126" class="LineNr">126 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"Code segment too small for SubX; for now please manually increase SEGMENT_ALIGNMENT.\n"</span> << end<span class="Delimiter">();</span> <span id="L127" class="LineNr">127 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L128" class="LineNr">128 </span> <span class="Delimiter">}</span> <span id="L129" class="LineNr">129 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">90</span><span class="Delimiter">,</span> <span class="Constant">"load"</span><span class="Delimiter">)</span> << <span class="Constant">"blitting file offsets ("</span> << p_offset << <span class="Constant">", "</span> << <span class="Delimiter">(</span>p_offset+p_filesz<span class="Delimiter">)</span> << <span class="Constant">") to addresses ("</span> << p_vaddr << <span class="Constant">", "</span> << <span class="Delimiter">(</span>p_vaddr+p_memsz<span class="Delimiter">)</span> << <span class="Constant">')'</span> << end<span class="Delimiter">();</span> <span id="L130" class="LineNr">130 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>size > p_memsz<span class="Delimiter">)</span> size = p_memsz<span class="Delimiter">;</span> -<span id="L131" class="LineNr">131 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span>p_vaddr<span class="Delimiter">));</span> +<span id="L131" class="LineNr">131 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span>p_vaddr<span class="Delimiter">));</span> <span id="L132" class="LineNr">132 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < p_filesz<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L133" class="LineNr">133 </span> assert<span class="Delimiter">(</span>overlap<span class="Delimiter">.</span>find<span class="Delimiter">(</span>p_vaddr+i<span class="Delimiter">)</span> == overlap<span class="Delimiter">.</span>end<span class="Delimiter">());</span> -<span id="L134" class="LineNr">134 </span> <a href='010---vm.cc.html#L237'>write_mem_u8</a><span class="Delimiter">(</span>p_vaddr+i<span class="Delimiter">,</span> elf_contents[p_offset+i]<span class="Delimiter">);</span> +<span id="L134" class="LineNr">134 </span> <a href='010---vm.cc.html#L231'>write_mem_u8</a><span class="Delimiter">(</span>p_vaddr+i<span class="Delimiter">,</span> elf_contents[p_offset+i]<span class="Delimiter">);</span> <span id="L135" class="LineNr">135 </span> overlap<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>p_vaddr+i<span class="Delimiter">);</span> <span id="L136" class="LineNr">136 </span> <span class="Delimiter">}</span> -<span id="L137" class="LineNr">137 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>segment_index == <span class="Constant">0</span> && <span class="Special"><a href='010---vm.cc.html#L163'>End_of_program</a></span> < p_vaddr+p_memsz<span class="Delimiter">)</span> -<span id="L138" class="LineNr">138 </span> <span class="Special"><a href='010---vm.cc.html#L163'>End_of_program</a></span> = p_vaddr+p_memsz<span class="Delimiter">;</span> +<span id="L137" class="LineNr">137 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>segment_index == <span class="Constant">0</span> && <span class="Special"><a href='010---vm.cc.html#L157'>End_of_program</a></span> < p_vaddr+p_memsz<span class="Delimiter">)</span> +<span id="L138" class="LineNr">138 </span> <span class="Special"><a href='010---vm.cc.html#L157'>End_of_program</a></span> = p_vaddr+p_memsz<span class="Delimiter">;</span> <span id="L139" class="LineNr">139 </span><span class="Delimiter">}</span> <span id="L140" class="LineNr">140 </span> <span id="L141" class="LineNr">141 </span><span class="Delimiter">:(before "End Includes")</span> @@ -221,11 +221,11 @@ if ('onhashchange' in window) { <span id="L160" class="LineNr">160 </span><span class="Normal">void</span> <a href='012elf.cc.html#L160'>dump_stack</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L161" class="LineNr">161 </span> ostringstream out<span class="Delimiter">;</span> <span id="L162" class="LineNr">162 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"stack:"</span> << end<span class="Delimiter">();</span> -<span id="L163" class="LineNr">163 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">uint32_t</span> a = AFTER_STACK-<span class="Constant">4</span><span class="Delimiter">;</span> a > <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> a -= <span class="Constant">4</span><span class="Delimiter">)</span> -<span id="L164" class="LineNr">164 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">" 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << a << <span class="Constant">" => 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span>a<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L165" class="LineNr">165 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">" 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u << <span class="Constant">" => 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << <span class="Constant">" <=== ESP"</span> << end<span class="Delimiter">();</span> -<span id="L166" class="LineNr">166 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">uint32_t</span> a = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u-<span class="Constant">4</span><span class="Delimiter">;</span> a > <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u-<span class="Constant">40</span><span class="Delimiter">;</span> a -= <span class="Constant">4</span><span class="Delimiter">)</span> -<span id="L167" class="LineNr">167 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">" 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << a << <span class="Constant">" => 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span>a<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L163" class="LineNr">163 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">uint32_t</span> a = AFTER_STACK-<span class="Constant">4</span><span class="Delimiter">;</span> a > <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> a -= <span class="Constant">4</span><span class="Delimiter">)</span> +<span id="L164" class="LineNr">164 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">" 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << a << <span class="Constant">" => 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span>a<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L165" class="LineNr">165 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">" 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u << <span class="Constant">" => 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << <span class="Constant">" <=== ESP"</span> << end<span class="Delimiter">();</span> +<span id="L166" class="LineNr">166 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">uint32_t</span> a = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u-<span class="Constant">4</span><span class="Delimiter">;</span> a > <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u-<span class="Constant">40</span><span class="Delimiter">;</span> a -= <span class="Constant">4</span><span class="Delimiter">)</span> +<span id="L167" class="LineNr">167 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">" 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << a << <span class="Constant">" => 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span>a<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L168" class="LineNr">168 </span><span class="Delimiter">}</span> <span id="L169" class="LineNr">169 </span> <span id="L170" class="LineNr">170 </span><span class="Normal">inline</span> <span class="Normal">uint32_t</span> <a href='012elf.cc.html#L170'>u32_in</a><span class="Delimiter">(</span><span class="Normal">uint8_t</span>* p<span class="Delimiter">)</span> <span class="Delimiter">{</span> diff --git a/html/013direct_addressing.cc.html b/html/013direct_addressing.cc.html index 26ca42a5..8256bc5b 100644 --- a/html/013direct_addressing.cc.html +++ b/html/013direct_addressing.cc.html @@ -62,20 +62,20 @@ if ('onhashchange' in window) { <span id="L1" class="LineNr"> 1 </span><span class="Comment">//: operating directly on a register</span> <span id="L2" class="LineNr"> 2 </span> <span id="L3" class="LineNr"> 3 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L4" class="LineNr"> 4 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"01"</span><span class="Delimiter">,</span> <span class="Constant">"add r32 to rm32 (add)"</span><span class="Delimiter">);</span> +<span id="L4" class="LineNr"> 4 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"01"</span><span class="Delimiter">,</span> <span class="Constant">"add r32 to rm32 (add)"</span><span class="Delimiter">);</span> <span id="L5" class="LineNr"> 5 </span> <span id="L6" class="LineNr"> 6 </span><span class="Delimiter">:(code)</span> <span id="L7" class="LineNr"> 7 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L7'>test_add_r32_to_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L8" class="LineNr"> 8 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> -<span id="L9" class="LineNr"> 9 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L10" class="LineNr"> 10 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L8" class="LineNr"> 8 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> +<span id="L9" class="LineNr"> 9 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L10" class="LineNr"> 10 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L11" class="LineNr"> 11 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L12" class="LineNr"> 12 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L13" class="LineNr"> 13 </span> <span class="Constant">" 01 d8 \n"</span> <span class="Comment">// add EBX to EAX</span> <span id="L14" class="LineNr"> 14 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L15" class="LineNr"> 15 </span> <span class="Delimiter">);</span> <span id="L16" class="LineNr"> 16 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L17" class="LineNr"> 17 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> +<span id="L17" class="LineNr"> 17 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> <span id="L18" class="LineNr"> 18 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L19" class="LineNr"> 19 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L20" class="LineNr"> 20 </span> <span class="Delimiter">);</span> @@ -83,38 +83,38 @@ if ('onhashchange' in window) { <span id="L22" class="LineNr"> 22 </span> <span id="L23" class="LineNr"> 23 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L24" class="LineNr"> 24 </span><span class="Normal">case</span> <span class="Constant">0x01</span>: <span class="Delimiter">{</span> <span class="Comment">// add r32 to r/m32</span> -<span id="L25" class="LineNr"> 25 </span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L25" class="LineNr"> 25 </span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L26" class="LineNr"> 26 </span> <span class="Normal">uint8_t</span> arg2 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L27" class="LineNr"> 27 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"add "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg2<span class="Delimiter">)</span> << <span class="Constant">" to r/m32"</span> << end<span class="Delimiter">();</span> <span id="L28" class="LineNr"> 28 </span> <span class="Normal">int32_t</span>* signed_arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L29" class="LineNr"> 29 </span> <span class="Normal">int32_t</span> signed_result = *signed_arg1 + <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L29" class="LineNr"> 29 </span> <span class="Normal">int32_t</span> signed_result = *signed_arg1 + <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> <span id="L30" class="LineNr"> 30 </span> SF = <span class="Delimiter">(</span>signed_result < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L31" class="LineNr"> 31 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L32" class="LineNr"> 32 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">)</span> + <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> -<span id="L33" class="LineNr"> 33 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> +<span id="L31" class="LineNr"> 31 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L32" class="LineNr"> 32 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">)</span> + <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L33" class="LineNr"> 33 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> <span id="L34" class="LineNr"> 34 </span> <span class="Comment">// set CF</span> <span id="L35" class="LineNr"> 35 </span> <span class="Normal">uint32_t</span> unsigned_arg1 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">);</span> -<span id="L36" class="LineNr"> 36 </span> <span class="Normal">uint32_t</span> unsigned_result = unsigned_arg1 + <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L37" class="LineNr"> 37 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span>unsigned_arg1<span class="Delimiter">)</span> + <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L38" class="LineNr"> 38 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> -<span id="L39" class="LineNr"> 39 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L36" class="LineNr"> 36 </span> <span class="Normal">uint32_t</span> unsigned_result = unsigned_arg1 + <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L37" class="LineNr"> 37 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span>unsigned_arg1<span class="Delimiter">)</span> + <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L38" class="LineNr"> 38 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> +<span id="L39" class="LineNr"> 39 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L40" class="LineNr"> 40 </span> *signed_arg1 = signed_result<span class="Delimiter">;</span> -<span id="L41" class="LineNr"> 41 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> +<span id="L41" class="LineNr"> 41 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> <span id="L42" class="LineNr"> 42 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L43" class="LineNr"> 43 </span><span class="Delimiter">}</span> <span id="L44" class="LineNr"> 44 </span> <span id="L45" class="LineNr"> 45 </span><span class="Delimiter">:(code)</span> <span id="L46" class="LineNr"> 46 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L46'>test_add_r32_to_r32_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L47" class="LineNr"> 47 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> -<span id="L48" class="LineNr"> 48 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L49" class="LineNr"> 49 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L47" class="LineNr"> 47 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> +<span id="L48" class="LineNr"> 48 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L49" class="LineNr"> 49 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L50" class="LineNr"> 50 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L51" class="LineNr"> 51 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L52" class="LineNr"> 52 </span> <span class="Constant">" 01 d8 \n"</span> <span class="Comment">// add EBX to EAX</span> <span id="L53" class="LineNr"> 53 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L54" class="LineNr"> 54 </span> <span class="Delimiter">);</span> <span id="L55" class="LineNr"> 55 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L56" class="LineNr"> 56 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> +<span id="L56" class="LineNr"> 56 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> <span id="L57" class="LineNr"> 57 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L58" class="LineNr"> 58 </span> <span class="Constant">"run: SF=1; ZF=0; CF=0; OF=1\n"</span> <span id="L59" class="LineNr"> 59 </span> <span class="Constant">"run: storing 0x80000000\n"</span> @@ -122,16 +122,16 @@ if ('onhashchange' in window) { <span id="L61" class="LineNr"> 61 </span><span class="Delimiter">}</span> <span id="L62" class="LineNr"> 62 </span> <span id="L63" class="LineNr"> 63 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L63'>test_add_r32_to_r32_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L64" class="LineNr"> 64 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest unsigned number</span> -<span id="L65" class="LineNr"> 65 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L66" class="LineNr"> 66 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L64" class="LineNr"> 64 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest unsigned number</span> +<span id="L65" class="LineNr"> 65 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L66" class="LineNr"> 66 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L67" class="LineNr"> 67 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L68" class="LineNr"> 68 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L69" class="LineNr"> 69 </span> <span class="Constant">" 01 d8 \n"</span> <span class="Comment">// add EBX to EAX</span> <span id="L70" class="LineNr"> 70 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L71" class="LineNr"> 71 </span> <span class="Delimiter">);</span> <span id="L72" class="LineNr"> 72 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L73" class="LineNr"> 73 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> +<span id="L73" class="LineNr"> 73 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> <span id="L74" class="LineNr"> 74 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L75" class="LineNr"> 75 </span> <span class="Constant">"run: SF=0; ZF=1; CF=1; OF=0\n"</span> <span id="L76" class="LineNr"> 76 </span> <span class="Constant">"run: storing 0x00000000\n"</span> @@ -139,15 +139,15 @@ if ('onhashchange' in window) { <span id="L78" class="LineNr"> 78 </span><span class="Delimiter">}</span> <span id="L79" class="LineNr"> 79 </span> <span id="L80" class="LineNr"> 80 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L80'>test_add_r32_to_r32_unsigned_and_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L81" class="LineNr"> 81 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> -<span id="L82" class="LineNr"> 82 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L81" class="LineNr"> 81 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> +<span id="L82" class="LineNr"> 82 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L83" class="LineNr"> 83 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L84" class="LineNr"> 84 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L85" class="LineNr"> 85 </span> <span class="Constant">" 01 d8 \n"</span> <span class="Comment">// add EBX to EAX</span> <span id="L86" class="LineNr"> 86 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L87" class="LineNr"> 87 </span> <span class="Delimiter">);</span> <span id="L88" class="LineNr"> 88 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L89" class="LineNr"> 89 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> +<span id="L89" class="LineNr"> 89 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> <span id="L90" class="LineNr"> 90 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L91" class="LineNr"> 91 </span> <span class="Constant">"run: SF=0; ZF=1; CF=1; OF=1\n"</span> <span id="L92" class="LineNr"> 92 </span> <span class="Constant">"run: storing 0x00000000\n"</span> @@ -166,11 +166,11 @@ if ('onhashchange' in window) { <span id="L105" class="LineNr"> 105 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>mod == <span class="Constant">3</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L106" class="LineNr"> 106 </span> <span class="Comment">// mod 3 is just register direct addressing</span> <span id="L107" class="LineNr"> 107 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"r/m32 is "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rm<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L108" class="LineNr"> 108 </span> <span class="Identifier">return</span> &<span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[rm]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L108" class="LineNr"> 108 </span> <span class="Identifier">return</span> &<span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[rm]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> <span id="L109" class="LineNr"> 109 </span> <span class="Delimiter">}</span> <span id="L110" class="LineNr"> 110 </span> <span class="Normal">uint32_t</span> addr = <a href='013direct_addressing.cc.html#L116'>effective_address_number</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L111" class="LineNr"> 111 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address contains "</span> << <a href='010---vm.cc.html#L182'>read_mem_i32</a><span class="Delimiter">(</span>addr<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L112" class="LineNr"> 112 </span> <span class="Identifier">return</span> <a href='010---vm.cc.html#L222'>mem_addr_i32</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> +<span id="L111" class="LineNr"> 111 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address contains 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L176'>read_mem_i32</a><span class="Delimiter">(</span>addr<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L112" class="LineNr"> 112 </span> <span class="Identifier">return</span> <a href='010---vm.cc.html#L216'>mem_addr_i32</a><span class="Delimiter">(</span>addr<span class="Delimiter">);</span> <span id="L113" class="LineNr"> 113 </span><span class="Delimiter">}</span> <span id="L114" class="LineNr"> 114 </span> <span id="L115" class="LineNr"> 115 </span><span class="Comment">// beware: will eventually have side-effects</span> @@ -186,7 +186,7 @@ if ('onhashchange' in window) { <span id="L125" class="LineNr"> 125 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> <span id="L126" class="LineNr"> 126 </span> <span class="Comment">// End Mod Special-cases(addr)</span> <span id="L127" class="LineNr"> 127 </span> <span class="Normal">default</span>: -<span id="L128" class="LineNr"> 128 </span> cerr << <span class="Constant">"unrecognized mod bits: "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>mod<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L128" class="LineNr"> 128 </span> cerr << <span class="Constant">"unrecognized mod bits: "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>mod<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span id="L129" class="LineNr"> 129 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L130" class="LineNr"> 130 </span> <span class="Delimiter">}</span> <span id="L131" class="LineNr"> 131 </span> <span class="Comment">//: other mods are indirect, and they'll set addr appropriately</span> @@ -211,20 +211,20 @@ if ('onhashchange' in window) { <span id="L150" class="LineNr"> 150 </span><span class="SalientComment">//:: subtract</span> <span id="L151" class="LineNr"> 151 </span> <span id="L152" class="LineNr"> 152 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L153" class="LineNr"> 153 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"29"</span><span class="Delimiter">,</span> <span class="Constant">"subtract r32 from rm32 (sub)"</span><span class="Delimiter">);</span> +<span id="L153" class="LineNr"> 153 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"29"</span><span class="Delimiter">,</span> <span class="Constant">"subtract r32 from rm32 (sub)"</span><span class="Delimiter">);</span> <span id="L154" class="LineNr"> 154 </span> <span id="L155" class="LineNr"> 155 </span><span class="Delimiter">:(code)</span> <span id="L156" class="LineNr"> 156 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L156'>test_subtract_r32_from_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L157" class="LineNr"> 157 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">10</span><span class="Delimiter">;</span> -<span id="L158" class="LineNr"> 158 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L159" class="LineNr"> 159 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L157" class="LineNr"> 157 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">10</span><span class="Delimiter">;</span> +<span id="L158" class="LineNr"> 158 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L159" class="LineNr"> 159 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L160" class="LineNr"> 160 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L161" class="LineNr"> 161 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L162" class="LineNr"> 162 </span> <span class="Constant">" 29 d8 \n"</span> <span class="Comment">// subtract EBX from EAX</span> <span id="L163" class="LineNr"> 163 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L164" class="LineNr"> 164 </span> <span class="Delimiter">);</span> <span id="L165" class="LineNr"> 165 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L166" class="LineNr"> 166 </span> <span class="Constant">"run: subtract <a href='010---vm.cc.html#L19'>EBX</a> from r/m32\n"</span> +<span id="L166" class="LineNr"> 166 </span> <span class="Constant">"run: subtract <a href='010---vm.cc.html#L13'>EBX</a> from r/m32\n"</span> <span id="L167" class="LineNr"> 167 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L168" class="LineNr"> 168 </span> <span class="Constant">"run: storing 0x00000009\n"</span> <span id="L169" class="LineNr"> 169 </span> <span class="Delimiter">);</span> @@ -232,38 +232,38 @@ if ('onhashchange' in window) { <span id="L171" class="LineNr"> 171 </span> <span id="L172" class="LineNr"> 172 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L173" class="LineNr"> 173 </span><span class="Normal">case</span> <span class="Constant">0x29</span>: <span class="Delimiter">{</span> <span class="Comment">// subtract r32 from r/m32</span> -<span id="L174" class="LineNr"> 174 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L174" class="LineNr"> 174 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L175" class="LineNr"> 175 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg2 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L176" class="LineNr"> 176 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subtract "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg2<span class="Delimiter">)</span> << <span class="Constant">" from r/m32"</span> << end<span class="Delimiter">();</span> <span id="L177" class="LineNr"> 177 </span> <span class="Normal">int32_t</span>* signed_arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L178" class="LineNr"> 178 </span> <span class="Normal">int32_t</span> signed_result = *signed_arg1 - <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L178" class="LineNr"> 178 </span> <span class="Normal">int32_t</span> signed_result = *signed_arg1 - <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> <span id="L179" class="LineNr"> 179 </span> SF = <span class="Delimiter">(</span>signed_result < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L180" class="LineNr"> 180 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L181" class="LineNr"> 181 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">)</span> - <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> -<span id="L182" class="LineNr"> 182 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> +<span id="L180" class="LineNr"> 180 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L181" class="LineNr"> 181 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">)</span> - <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L182" class="LineNr"> 182 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> <span id="L183" class="LineNr"> 183 </span> <span class="Comment">// set CF</span> <span id="L184" class="LineNr"> 184 </span> <span class="Normal">uint32_t</span> unsigned_arg1 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">);</span> -<span id="L185" class="LineNr"> 185 </span> <span class="Normal">uint32_t</span> unsigned_result = unsigned_arg1 - <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L186" class="LineNr"> 186 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span>unsigned_arg1<span class="Delimiter">)</span> - <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L187" class="LineNr"> 187 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> -<span id="L188" class="LineNr"> 188 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L185" class="LineNr"> 185 </span> <span class="Normal">uint32_t</span> unsigned_result = unsigned_arg1 - <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L186" class="LineNr"> 186 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span>unsigned_arg1<span class="Delimiter">)</span> - <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L187" class="LineNr"> 187 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> +<span id="L188" class="LineNr"> 188 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L189" class="LineNr"> 189 </span> *signed_arg1 = signed_result<span class="Delimiter">;</span> -<span id="L190" class="LineNr"> 190 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> +<span id="L190" class="LineNr"> 190 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> <span id="L191" class="LineNr"> 191 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L192" class="LineNr"> 192 </span><span class="Delimiter">}</span> <span id="L193" class="LineNr"> 193 </span> <span id="L194" class="LineNr"> 194 </span><span class="Delimiter">:(code)</span> <span id="L195" class="LineNr"> 195 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L195'>test_subtract_r32_from_r32_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L196" class="LineNr"> 196 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> -<span id="L197" class="LineNr"> 197 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> -<span id="L198" class="LineNr"> 198 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L196" class="LineNr"> 196 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> +<span id="L197" class="LineNr"> 197 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> +<span id="L198" class="LineNr"> 198 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L199" class="LineNr"> 199 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L200" class="LineNr"> 200 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L201" class="LineNr"> 201 </span> <span class="Constant">" 29 d8 \n"</span> <span class="Comment">// subtract EBX from EAX</span> <span id="L202" class="LineNr"> 202 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L203" class="LineNr"> 203 </span> <span class="Delimiter">);</span> <span id="L204" class="LineNr"> 204 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L205" class="LineNr"> 205 </span> <span class="Constant">"run: subtract <a href='010---vm.cc.html#L19'>EBX</a> from r/m32\n"</span> +<span id="L205" class="LineNr"> 205 </span> <span class="Constant">"run: subtract <a href='010---vm.cc.html#L13'>EBX</a> from r/m32\n"</span> <span id="L206" class="LineNr"> 206 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L207" class="LineNr"> 207 </span> <span class="Constant">"run: SF=0; ZF=0; CF=0; OF=1\n"</span> <span id="L208" class="LineNr"> 208 </span> <span class="Constant">"run: storing 0x00000001\n"</span> @@ -271,16 +271,16 @@ if ('onhashchange' in window) { <span id="L210" class="LineNr"> 210 </span><span class="Delimiter">}</span> <span id="L211" class="LineNr"> 211 </span> <span id="L212" class="LineNr"> 212 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L212'>test_subtract_r32_from_r32_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L213" class="LineNr"> 213 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L214" class="LineNr"> 214 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L215" class="LineNr"> 215 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L213" class="LineNr"> 213 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L214" class="LineNr"> 214 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L215" class="LineNr"> 215 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L216" class="LineNr"> 216 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L217" class="LineNr"> 217 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L218" class="LineNr"> 218 </span> <span class="Constant">" 29 d8 \n"</span> <span class="Comment">// subtract EBX from EAX</span> <span id="L219" class="LineNr"> 219 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L220" class="LineNr"> 220 </span> <span class="Delimiter">);</span> <span id="L221" class="LineNr"> 221 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L222" class="LineNr"> 222 </span> <span class="Constant">"run: subtract <a href='010---vm.cc.html#L19'>EBX</a> from r/m32\n"</span> +<span id="L222" class="LineNr"> 222 </span> <span class="Constant">"run: subtract <a href='010---vm.cc.html#L13'>EBX</a> from r/m32\n"</span> <span id="L223" class="LineNr"> 223 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L224" class="LineNr"> 224 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=0\n"</span> <span id="L225" class="LineNr"> 225 </span> <span class="Constant">"run: storing 0xffffffff\n"</span> @@ -288,16 +288,16 @@ if ('onhashchange' in window) { <span id="L227" class="LineNr"> 227 </span><span class="Delimiter">}</span> <span id="L228" class="LineNr"> 228 </span> <span id="L229" class="LineNr"> 229 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L229'>test_subtract_r32_from_r32_signed_and_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L230" class="LineNr"> 230 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L231" class="LineNr"> 231 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> -<span id="L232" class="LineNr"> 232 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L230" class="LineNr"> 230 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L231" class="LineNr"> 231 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> +<span id="L232" class="LineNr"> 232 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L233" class="LineNr"> 233 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L234" class="LineNr"> 234 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L235" class="LineNr"> 235 </span> <span class="Constant">" 29 d8 \n"</span> <span class="Comment">// subtract EBX from EAX</span> <span id="L236" class="LineNr"> 236 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L237" class="LineNr"> 237 </span> <span class="Delimiter">);</span> <span id="L238" class="LineNr"> 238 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L239" class="LineNr"> 239 </span> <span class="Constant">"run: subtract <a href='010---vm.cc.html#L19'>EBX</a> from r/m32\n"</span> +<span id="L239" class="LineNr"> 239 </span> <span class="Constant">"run: subtract <a href='010---vm.cc.html#L13'>EBX</a> from r/m32\n"</span> <span id="L240" class="LineNr"> 240 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L241" class="LineNr"> 241 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=1\n"</span> <span id="L242" class="LineNr"> 242 </span> <span class="Constant">"run: storing 0x80000000\n"</span> @@ -307,13 +307,13 @@ if ('onhashchange' in window) { <span id="L246" class="LineNr"> 246 </span><span class="SalientComment">//:: multiply</span> <span id="L247" class="LineNr"> 247 </span> <span id="L248" class="LineNr"> 248 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L249" class="LineNr"> 249 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"f7"</span><span class="Delimiter">,</span> <span class="Constant">"negate/multiply/divide rm32 (with <a href='010---vm.cc.html#L16'>EAX</a> and <a href='010---vm.cc.html#L18'>EDX</a> if necessary) depending on subop (neg/mul/idiv)"</span><span class="Delimiter">);</span> +<span id="L249" class="LineNr"> 249 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"f7"</span><span class="Delimiter">,</span> <span class="Constant">"negate/multiply/divide rm32 (with <a href='010---vm.cc.html#L10'>EAX</a> and <a href='010---vm.cc.html#L12'>EDX</a> if necessary) depending on subop (neg/mul/idiv)"</span><span class="Delimiter">);</span> <span id="L250" class="LineNr"> 250 </span> <span id="L251" class="LineNr"> 251 </span><span class="Delimiter">:(code)</span> <span id="L252" class="LineNr"> 252 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L252'>test_multiply_EAX_by_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L253" class="LineNr"> 253 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">4</span><span class="Delimiter">;</span> -<span id="L254" class="LineNr"> 254 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">3</span><span class="Delimiter">;</span> -<span id="L255" class="LineNr"> 255 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L253" class="LineNr"> 253 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">4</span><span class="Delimiter">;</span> +<span id="L254" class="LineNr"> 254 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">3</span><span class="Delimiter">;</span> +<span id="L255" class="LineNr"> 255 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L256" class="LineNr"> 256 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L257" class="LineNr"> 257 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L258" class="LineNr"> 258 </span> <span class="Constant">" f7 e1 \n"</span> <span class="Comment">// multiply EAX by ECX</span> @@ -322,32 +322,32 @@ if ('onhashchange' in window) { <span id="L261" class="LineNr"> 261 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L262" class="LineNr"> 262 </span> <span class="Constant">"run: operate on r/m32\n"</span> <span id="L263" class="LineNr"> 263 </span> <span class="Constant">"run: r/m32 is ECX\n"</span> -<span id="L264" class="LineNr"> 264 </span> <span class="Constant">"run: subop: multiply <a href='010---vm.cc.html#L16'>EAX</a> by r/m32\n"</span> +<span id="L264" class="LineNr"> 264 </span> <span class="Constant">"run: subop: multiply <a href='010---vm.cc.html#L10'>EAX</a> by r/m32\n"</span> <span id="L265" class="LineNr"> 265 </span> <span class="Constant">"run: storing 0x0000000c\n"</span> <span id="L266" class="LineNr"> 266 </span> <span class="Delimiter">);</span> <span id="L267" class="LineNr"> 267 </span><span class="Delimiter">}</span> <span id="L268" class="LineNr"> 268 </span> <span id="L269" class="LineNr"> 269 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L270" class="LineNr"> 270 </span><span class="Normal">case</span> <span class="Constant">0xf7</span>: <span class="Delimiter">{</span> -<span id="L271" class="LineNr"> 271 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L271" class="LineNr"> 271 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L272" class="LineNr"> 272 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"operate on r/m32"</span> << end<span class="Delimiter">();</span> <span id="L273" class="LineNr"> 273 </span> <span class="Normal">int32_t</span>* arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> <span id="L274" class="LineNr"> 274 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> subop = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span class="Comment">// middle 3 'reg opcode' bits</span> <span id="L275" class="LineNr"> 275 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>subop<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L276" class="LineNr"> 276 </span> <span class="Normal">case</span> <span class="Constant">4</span>: <span class="Delimiter">{</span> <span class="Comment">// mul unsigned EAX by r/m32</span> -<span id="L277" class="LineNr"> 277 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: multiply <a href='010---vm.cc.html#L16'>EAX</a> by r/m32"</span> << end<span class="Delimiter">();</span> -<span id="L278" class="LineNr"> 278 </span> <span class="Normal">const</span> <span class="Normal">uint64_t</span> result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> * <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*arg1<span class="Delimiter">);</span> -<span id="L279" class="LineNr"> 279 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = result & <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> -<span id="L280" class="LineNr"> 280 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u = result >> <span class="Constant">32</span><span class="Delimiter">;</span> -<span id="L281" class="LineNr"> 281 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u != <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L282" class="LineNr"> 282 </span> <a href='010---vm.cc.html#L87'>CF</a> = <a href='010---vm.cc.html#L88'>OF</a><span class="Delimiter">;</span> -<span id="L283" class="LineNr"> 283 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> -<span id="L284" class="LineNr"> 284 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L277" class="LineNr"> 277 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: multiply <a href='010---vm.cc.html#L10'>EAX</a> by r/m32"</span> << end<span class="Delimiter">();</span> +<span id="L278" class="LineNr"> 278 </span> <span class="Normal">const</span> <span class="Normal">uint64_t</span> result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> * <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*arg1<span class="Delimiter">);</span> +<span id="L279" class="LineNr"> 279 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = result & <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> +<span id="L280" class="LineNr"> 280 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u = result >> <span class="Constant">32</span><span class="Delimiter">;</span> +<span id="L281" class="LineNr"> 281 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u != <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L282" class="LineNr"> 282 </span> <a href='010---vm.cc.html#L81'>CF</a> = <a href='010---vm.cc.html#L82'>OF</a><span class="Delimiter">;</span> +<span id="L283" class="LineNr"> 283 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> +<span id="L284" class="LineNr"> 284 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> <span id="L285" class="LineNr"> 285 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L286" class="LineNr"> 286 </span> <span class="Delimiter">}</span> <span id="L287" class="LineNr"> 287 </span> <span class="Comment">// End Op f7 Subops</span> <span id="L288" class="LineNr"> 288 </span> <span class="Normal">default</span>: -<span id="L289" class="LineNr"> 289 </span> cerr << <span class="Constant">"unrecognized subop for opcode f7: "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L289" class="LineNr"> 289 </span> cerr << <span class="Constant">"unrecognized subop for opcode f7: "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span id="L290" class="LineNr"> 290 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L291" class="LineNr"> 291 </span> <span class="Delimiter">}</span> <span id="L292" class="LineNr"> 292 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -356,20 +356,20 @@ if ('onhashchange' in window) { <span id="L295" class="LineNr"> 295 </span><span class="Comment">//:</span> <span id="L296" class="LineNr"> 296 </span> <span id="L297" class="LineNr"> 297 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L298" class="LineNr"> 298 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"af"</span><span class="Delimiter">,</span> <span class="Constant">"multiply rm32 into r32 (imul)"</span><span class="Delimiter">);</span> +<span id="L298" class="LineNr"> 298 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"af"</span><span class="Delimiter">,</span> <span class="Constant">"multiply rm32 into r32 (imul)"</span><span class="Delimiter">);</span> <span id="L299" class="LineNr"> 299 </span> <span id="L300" class="LineNr"> 300 </span><span class="Delimiter">:(code)</span> <span id="L301" class="LineNr"> 301 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L301'>test_multiply_r32_into_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L302" class="LineNr"> 302 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">4</span><span class="Delimiter">;</span> -<span id="L303" class="LineNr"> 303 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">2</span><span class="Delimiter">;</span> -<span id="L304" class="LineNr"> 304 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L302" class="LineNr"> 302 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">4</span><span class="Delimiter">;</span> +<span id="L303" class="LineNr"> 303 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">2</span><span class="Delimiter">;</span> +<span id="L304" class="LineNr"> 304 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L305" class="LineNr"> 305 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L306" class="LineNr"> 306 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L307" class="LineNr"> 307 </span> <span class="Constant">" 0f af d8 \n"</span> <span class="Comment">// subtract EBX into EAX</span> <span id="L308" class="LineNr"> 308 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L309" class="LineNr"> 309 </span> <span class="Delimiter">);</span> <span id="L310" class="LineNr"> 310 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L311" class="LineNr"> 311 </span> <span class="Constant">"run: multiply <a href='010---vm.cc.html#L19'>EBX</a> by r/m32\n"</span> +<span id="L311" class="LineNr"> 311 </span> <span class="Constant">"run: multiply <a href='010---vm.cc.html#L13'>EBX</a> by r/m32\n"</span> <span id="L312" class="LineNr"> 312 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L313" class="LineNr"> 313 </span> <span class="Constant">"run: storing 0x00000008\n"</span> <span id="L314" class="LineNr"> 314 </span> <span class="Delimiter">);</span> @@ -377,19 +377,19 @@ if ('onhashchange' in window) { <span id="L316" class="LineNr"> 316 </span> <span id="L317" class="LineNr"> 317 </span><span class="Delimiter">:(before "End Two-Byte Opcodes Starting With 0f")</span> <span id="L318" class="LineNr"> 318 </span><span class="Normal">case</span> <span class="Constant">0xaf</span>: <span class="Delimiter">{</span> <span class="Comment">// multiply r32 by r/m32</span> -<span id="L319" class="LineNr"> 319 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L319" class="LineNr"> 319 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L320" class="LineNr"> 320 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg1 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L321" class="LineNr"> 321 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"multiply "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg1<span class="Delimiter">)</span> << <span class="Constant">" by r/m32"</span> << end<span class="Delimiter">();</span> <span id="L322" class="LineNr"> 322 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* arg2 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L323" class="LineNr"> 323 </span> <span class="Normal">int32_t</span> result = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i * <span class="Delimiter">(</span>*arg2<span class="Delimiter">);</span> -<span id="L324" class="LineNr"> 324 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L325" class="LineNr"> 325 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L326" class="LineNr"> 326 </span> <span class="Normal">int64_t</span> full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> * <span class="Delimiter">(</span>*arg2<span class="Delimiter">);</span> -<span id="L327" class="LineNr"> 327 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i != full_result<span class="Delimiter">);</span> -<span id="L328" class="LineNr"> 328 </span> <a href='010---vm.cc.html#L87'>CF</a> = <a href='010---vm.cc.html#L88'>OF</a><span class="Delimiter">;</span> -<span id="L329" class="LineNr"> 329 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> -<span id="L330" class="LineNr"> 330 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i = result<span class="Delimiter">;</span> -<span id="L331" class="LineNr"> 331 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L323" class="LineNr"> 323 </span> <span class="Normal">int32_t</span> result = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i * <span class="Delimiter">(</span>*arg2<span class="Delimiter">);</span> +<span id="L324" class="LineNr"> 324 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i < <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L325" class="LineNr"> 325 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L326" class="LineNr"> 326 </span> <span class="Normal">int64_t</span> full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> * <span class="Delimiter">(</span>*arg2<span class="Delimiter">);</span> +<span id="L327" class="LineNr"> 327 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i != full_result<span class="Delimiter">);</span> +<span id="L328" class="LineNr"> 328 </span> <a href='010---vm.cc.html#L81'>CF</a> = <a href='010---vm.cc.html#L82'>OF</a><span class="Delimiter">;</span> +<span id="L329" class="LineNr"> 329 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> +<span id="L330" class="LineNr"> 330 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i = result<span class="Delimiter">;</span> +<span id="L331" class="LineNr"> 331 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> <span id="L332" class="LineNr"> 332 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L333" class="LineNr"> 333 </span><span class="Delimiter">}</span> <span id="L334" class="LineNr"> 334 </span> @@ -397,8 +397,8 @@ if ('onhashchange' in window) { <span id="L336" class="LineNr"> 336 </span> <span id="L337" class="LineNr"> 337 </span><span class="Delimiter">:(code)</span> <span id="L338" class="LineNr"> 338 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L338'>test_negate_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L339" class="LineNr"> 339 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L340" class="LineNr"> 340 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L339" class="LineNr"> 339 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L340" class="LineNr"> 340 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L341" class="LineNr"> 341 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L342" class="LineNr"> 342 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L343" class="LineNr"> 343 </span> <span class="Constant">" f7 db \n"</span> <span class="Comment">// negate EBX</span> @@ -419,26 +419,26 @@ if ('onhashchange' in window) { <span id="L358" class="LineNr"> 358 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*arg1<span class="Delimiter">)</span> == <span class="Constant">0x80000000</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L359" class="LineNr"> 359 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"overflow"</span> << end<span class="Delimiter">();</span> <span id="L360" class="LineNr"> 360 </span> SF = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L361" class="LineNr"> 361 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L362" class="LineNr"> 362 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L361" class="LineNr"> 361 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L362" class="LineNr"> 362 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L363" class="LineNr"> 363 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L364" class="LineNr"> 364 </span> <span class="Delimiter">}</span> <span id="L365" class="LineNr"> 365 </span> <span class="Normal">int32_t</span> result = -<span class="Delimiter">(</span>*arg1<span class="Delimiter">);</span> <span id="L366" class="LineNr"> 366 </span> SF = <span class="Delimiter">(</span>result >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L367" class="LineNr"> 367 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>result == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L368" class="LineNr"> 368 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L369" class="LineNr"> 369 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>*arg1 != <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L370" class="LineNr"> 370 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L367" class="LineNr"> 367 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>result == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L368" class="LineNr"> 368 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L369" class="LineNr"> 369 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>*arg1 != <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L370" class="LineNr"> 370 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L371" class="LineNr"> 371 </span> *arg1 = result<span class="Delimiter">;</span> -<span id="L372" class="LineNr"> 372 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> +<span id="L372" class="LineNr"> 372 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> <span id="L373" class="LineNr"> 373 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L374" class="LineNr"> 374 </span><span class="Delimiter">}</span> <span id="L375" class="LineNr"> 375 </span> <span id="L376" class="LineNr"> 376 </span><span class="Delimiter">:(code)</span> <span id="L377" class="LineNr"> 377 </span><span class="Comment">// negate can overflow in exactly one situation</span> <span id="L378" class="LineNr"> 378 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L378'>test_negate_can_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L379" class="LineNr"> 379 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// INT_MIN</span> -<span id="L380" class="LineNr"> 380 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L379" class="LineNr"> 379 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// INT_MIN</span> +<span id="L380" class="LineNr"> 380 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L381" class="LineNr"> 381 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L382" class="LineNr"> 382 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L383" class="LineNr"> 383 </span> <span class="Constant">" f7 db \n"</span> <span class="Comment">// negate EBX</span> @@ -455,10 +455,10 @@ if ('onhashchange' in window) { <span id="L394" class="LineNr"> 394 </span><span class="SalientComment">//:: divide with remainder</span> <span id="L395" class="LineNr"> 395 </span> <span id="L396" class="LineNr"> 396 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L396'>test_divide_EAX_by_rm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L397" class="LineNr"> 397 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">7</span><span class="Delimiter">;</span> -<span id="L398" class="LineNr"> 398 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L399" class="LineNr"> 399 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">3</span><span class="Delimiter">;</span> -<span id="L400" class="LineNr"> 400 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L397" class="LineNr"> 397 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">7</span><span class="Delimiter">;</span> +<span id="L398" class="LineNr"> 398 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L399" class="LineNr"> 399 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">3</span><span class="Delimiter">;</span> +<span id="L400" class="LineNr"> 400 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L401" class="LineNr"> 401 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L402" class="LineNr"> 402 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L403" class="LineNr"> 403 </span> <span class="Constant">" f7 f9 \n"</span> <span class="Comment">// multiply EAX by ECX</span> @@ -467,7 +467,7 @@ if ('onhashchange' in window) { <span id="L406" class="LineNr"> 406 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L407" class="LineNr"> 407 </span> <span class="Constant">"run: operate on r/m32\n"</span> <span id="L408" class="LineNr"> 408 </span> <span class="Constant">"run: r/m32 is ECX\n"</span> -<span id="L409" class="LineNr"> 409 </span> <span class="Constant">"run: subop: divide <a href='010---vm.cc.html#L18'>EDX</a>:<a href='010---vm.cc.html#L16'>EAX</a> by r/m32, storing quotient in <a href='010---vm.cc.html#L16'>EAX</a> and remainder in EDX\n"</span> +<span id="L409" class="LineNr"> 409 </span> <span class="Constant">"run: subop: divide <a href='010---vm.cc.html#L12'>EDX</a>:<a href='010---vm.cc.html#L10'>EAX</a> by r/m32, storing quotient in <a href='010---vm.cc.html#L10'>EAX</a> and remainder in EDX\n"</span> <span id="L410" class="LineNr"> 410 </span> <span class="Constant">"run: quotient: 0x00000002\n"</span> <span id="L411" class="LineNr"> 411 </span> <span class="Constant">"run: remainder: 0x00000001\n"</span> <span id="L412" class="LineNr"> 412 </span> <span class="Delimiter">);</span> @@ -475,24 +475,24 @@ if ('onhashchange' in window) { <span id="L414" class="LineNr"> 414 </span> <span id="L415" class="LineNr"> 415 </span><span class="Delimiter">:(before "End Op f7 Subops")</span> <span id="L416" class="LineNr"> 416 </span><span class="Normal">case</span> <span class="Constant">7</span>: <span class="Delimiter">{</span> <span class="Comment">// divide EDX:EAX by r/m32, storing quotient in EAX and remainder in EDX</span> -<span id="L417" class="LineNr"> 417 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: divide <a href='010---vm.cc.html#L18'>EDX</a>:<a href='010---vm.cc.html#L16'>EAX</a> by r/m32, storing quotient in <a href='010---vm.cc.html#L16'>EAX</a> and remainder in EDX"</span> << end<span class="Delimiter">();</span> -<span id="L418" class="LineNr"> 418 </span> <span class="Normal">int64_t</span> dividend = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">((</span><span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << <span class="Constant">32</span><span class="Delimiter">)</span> | <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> +<span id="L417" class="LineNr"> 417 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: divide <a href='010---vm.cc.html#L12'>EDX</a>:<a href='010---vm.cc.html#L10'>EAX</a> by r/m32, storing quotient in <a href='010---vm.cc.html#L10'>EAX</a> and remainder in EDX"</span> << end<span class="Delimiter">();</span> +<span id="L418" class="LineNr"> 418 </span> <span class="Normal">int64_t</span> dividend = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">((</span><span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << <span class="Constant">32</span><span class="Delimiter">)</span> | <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> <span id="L419" class="LineNr"> 419 </span> <span class="Normal">int32_t</span> divisor = *arg1<span class="Delimiter">;</span> <span id="L420" class="LineNr"> 420 </span> assert<span class="Delimiter">(</span>divisor != <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L421" class="LineNr"> 421 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = dividend/divisor<span class="Delimiter">;</span> <span class="Comment">// quotient</span> -<span id="L422" class="LineNr"> 422 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>i = dividend%divisor<span class="Delimiter">;</span> <span class="Comment">// remainder</span> +<span id="L421" class="LineNr"> 421 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = dividend/divisor<span class="Delimiter">;</span> <span class="Comment">// quotient</span> +<span id="L422" class="LineNr"> 422 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>i = dividend%divisor<span class="Delimiter">;</span> <span class="Comment">// remainder</span> <span id="L423" class="LineNr"> 423 </span> <span class="Comment">// flag state undefined</span> -<span id="L424" class="LineNr"> 424 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"quotient: 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L425" class="LineNr"> 425 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"remainder: 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L424" class="LineNr"> 424 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"quotient: 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L425" class="LineNr"> 425 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"remainder: 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> <span id="L426" class="LineNr"> 426 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L427" class="LineNr"> 427 </span><span class="Delimiter">}</span> <span id="L428" class="LineNr"> 428 </span> <span id="L429" class="LineNr"> 429 </span><span class="Delimiter">:(code)</span> <span id="L430" class="LineNr"> 430 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L430'>test_divide_EAX_by_negative_rm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L431" class="LineNr"> 431 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">7</span><span class="Delimiter">;</span> -<span id="L432" class="LineNr"> 432 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L433" class="LineNr"> 433 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = -<span class="Constant">3</span><span class="Delimiter">;</span> -<span id="L434" class="LineNr"> 434 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L431" class="LineNr"> 431 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">7</span><span class="Delimiter">;</span> +<span id="L432" class="LineNr"> 432 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L433" class="LineNr"> 433 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = -<span class="Constant">3</span><span class="Delimiter">;</span> +<span id="L434" class="LineNr"> 434 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L435" class="LineNr"> 435 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L436" class="LineNr"> 436 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L437" class="LineNr"> 437 </span> <span class="Constant">" f7 f9 \n"</span> <span class="Comment">// multiply EAX by ECX</span> @@ -501,17 +501,17 @@ if ('onhashchange' in window) { <span id="L440" class="LineNr"> 440 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L441" class="LineNr"> 441 </span> <span class="Constant">"run: operate on r/m32\n"</span> <span id="L442" class="LineNr"> 442 </span> <span class="Constant">"run: r/m32 is ECX\n"</span> -<span id="L443" class="LineNr"> 443 </span> <span class="Constant">"run: subop: divide <a href='010---vm.cc.html#L18'>EDX</a>:<a href='010---vm.cc.html#L16'>EAX</a> by r/m32, storing quotient in <a href='010---vm.cc.html#L16'>EAX</a> and remainder in EDX\n"</span> +<span id="L443" class="LineNr"> 443 </span> <span class="Constant">"run: subop: divide <a href='010---vm.cc.html#L12'>EDX</a>:<a href='010---vm.cc.html#L10'>EAX</a> by r/m32, storing quotient in <a href='010---vm.cc.html#L10'>EAX</a> and remainder in EDX\n"</span> <span id="L444" class="LineNr"> 444 </span> <span class="Constant">"run: quotient: 0xfffffffe\n"</span> <span class="Comment">// -2</span> <span id="L445" class="LineNr"> 445 </span> <span class="Constant">"run: remainder: 0x00000001\n"</span> <span id="L446" class="LineNr"> 446 </span> <span class="Delimiter">);</span> <span id="L447" class="LineNr"> 447 </span><span class="Delimiter">}</span> <span id="L448" class="LineNr"> 448 </span> <span id="L449" class="LineNr"> 449 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L449'>test_divide_negative_EAX_by_rm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L450" class="LineNr"> 450 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = -<span class="Constant">7</span><span class="Delimiter">;</span> -<span id="L451" class="LineNr"> 451 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>i = -<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// sign extend</span> -<span id="L452" class="LineNr"> 452 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">3</span><span class="Delimiter">;</span> -<span id="L453" class="LineNr"> 453 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L450" class="LineNr"> 450 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = -<span class="Constant">7</span><span class="Delimiter">;</span> +<span id="L451" class="LineNr"> 451 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>i = -<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// sign extend</span> +<span id="L452" class="LineNr"> 452 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">3</span><span class="Delimiter">;</span> +<span id="L453" class="LineNr"> 453 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L454" class="LineNr"> 454 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L455" class="LineNr"> 455 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L456" class="LineNr"> 456 </span> <span class="Constant">" f7 f9 \n"</span> <span class="Comment">// multiply EAX by ECX</span> @@ -520,17 +520,17 @@ if ('onhashchange' in window) { <span id="L459" class="LineNr"> 459 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L460" class="LineNr"> 460 </span> <span class="Constant">"run: operate on r/m32\n"</span> <span id="L461" class="LineNr"> 461 </span> <span class="Constant">"run: r/m32 is ECX\n"</span> -<span id="L462" class="LineNr"> 462 </span> <span class="Constant">"run: subop: divide <a href='010---vm.cc.html#L18'>EDX</a>:<a href='010---vm.cc.html#L16'>EAX</a> by r/m32, storing quotient in <a href='010---vm.cc.html#L16'>EAX</a> and remainder in EDX\n"</span> +<span id="L462" class="LineNr"> 462 </span> <span class="Constant">"run: subop: divide <a href='010---vm.cc.html#L12'>EDX</a>:<a href='010---vm.cc.html#L10'>EAX</a> by r/m32, storing quotient in <a href='010---vm.cc.html#L10'>EAX</a> and remainder in EDX\n"</span> <span id="L463" class="LineNr"> 463 </span> <span class="Constant">"run: quotient: 0xfffffffe\n"</span> <span class="Comment">// -2</span> <span id="L464" class="LineNr"> 464 </span> <span class="Constant">"run: remainder: 0xffffffff\n"</span> <span class="Comment">// -1, same sign as divident (EDX:EAX)</span> <span id="L465" class="LineNr"> 465 </span> <span class="Delimiter">);</span> <span id="L466" class="LineNr"> 466 </span><span class="Delimiter">}</span> <span id="L467" class="LineNr"> 467 </span> <span id="L468" class="LineNr"> 468 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L468'>test_divide_negative_EDX_EAX_by_rm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L469" class="LineNr"> 469 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// lower 32 bits are clear</span> -<span id="L470" class="LineNr"> 470 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>i = -<span class="Constant">7</span><span class="Delimiter">;</span> -<span id="L471" class="LineNr"> 471 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">0x40000000</span><span class="Delimiter">;</span> <span class="Comment">// 2^30 (largest positive power of 2)</span> -<span id="L472" class="LineNr"> 472 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L469" class="LineNr"> 469 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// lower 32 bits are clear</span> +<span id="L470" class="LineNr"> 470 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>i = -<span class="Constant">7</span><span class="Delimiter">;</span> +<span id="L471" class="LineNr"> 471 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">0x40000000</span><span class="Delimiter">;</span> <span class="Comment">// 2^30 (largest positive power of 2)</span> +<span id="L472" class="LineNr"> 472 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L473" class="LineNr"> 473 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L474" class="LineNr"> 474 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L475" class="LineNr"> 475 </span> <span class="Constant">" f7 f9 \n"</span> <span class="Comment">// multiply EAX by ECX</span> @@ -539,7 +539,7 @@ if ('onhashchange' in window) { <span id="L478" class="LineNr"> 478 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L479" class="LineNr"> 479 </span> <span class="Constant">"run: operate on r/m32\n"</span> <span id="L480" class="LineNr"> 480 </span> <span class="Constant">"run: r/m32 is ECX\n"</span> -<span id="L481" class="LineNr"> 481 </span> <span class="Constant">"run: subop: divide <a href='010---vm.cc.html#L18'>EDX</a>:<a href='010---vm.cc.html#L16'>EAX</a> by r/m32, storing quotient in <a href='010---vm.cc.html#L16'>EAX</a> and remainder in EDX\n"</span> +<span id="L481" class="LineNr"> 481 </span> <span class="Constant">"run: subop: divide <a href='010---vm.cc.html#L12'>EDX</a>:<a href='010---vm.cc.html#L10'>EAX</a> by r/m32, storing quotient in <a href='010---vm.cc.html#L10'>EAX</a> and remainder in EDX\n"</span> <span id="L482" class="LineNr"> 482 </span> <span class="Constant">"run: quotient: 0xffffffe4\n"</span> <span class="Comment">// (-7 << 32) / (1 << 30) = -7 << 2 = -28</span> <span id="L483" class="LineNr"> 483 </span> <span class="Constant">"run: remainder: 0x00000000\n"</span> <span id="L484" class="LineNr"> 484 </span> <span class="Delimiter">);</span> @@ -548,13 +548,13 @@ if ('onhashchange' in window) { <span id="L487" class="LineNr"> 487 </span><span class="SalientComment">//:: shift left</span> <span id="L488" class="LineNr"> 488 </span> <span id="L489" class="LineNr"> 489 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L490" class="LineNr"> 490 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"d3"</span><span class="Delimiter">,</span> <span class="Constant">"shift rm32 by CL bits depending on subop (sal/sar/shl/shr)"</span><span class="Delimiter">);</span> +<span id="L490" class="LineNr"> 490 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"d3"</span><span class="Delimiter">,</span> <span class="Constant">"shift rm32 by CL bits depending on subop (sal/sar/shl/shr)"</span><span class="Delimiter">);</span> <span id="L491" class="LineNr"> 491 </span> <span id="L492" class="LineNr"> 492 </span><span class="Delimiter">:(code)</span> <span id="L493" class="LineNr"> 493 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L493'>test_shift_left_r32_with_cl</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L494" class="LineNr"> 494 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">13</span><span class="Delimiter">;</span> -<span id="L495" class="LineNr"> 495 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L496" class="LineNr"> 496 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L494" class="LineNr"> 494 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">13</span><span class="Delimiter">;</span> +<span id="L495" class="LineNr"> 495 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L496" class="LineNr"> 496 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L497" class="LineNr"> 497 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L498" class="LineNr"> 498 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L499" class="LineNr"> 499 </span> <span class="Constant">" d3 e3 \n"</span> <span class="Comment">// shift EBX left by CL bits</span> @@ -570,32 +570,32 @@ if ('onhashchange' in window) { <span id="L509" class="LineNr"> 509 </span> <span id="L510" class="LineNr"> 510 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L511" class="LineNr"> 511 </span><span class="Normal">case</span> <span class="Constant">0xd3</span>: <span class="Delimiter">{</span> -<span id="L512" class="LineNr"> 512 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L512" class="LineNr"> 512 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L513" class="LineNr"> 513 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"operate on r/m32"</span> << end<span class="Delimiter">();</span> <span id="L514" class="LineNr"> 514 </span> <span class="Normal">int32_t</span>* arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> <span id="L515" class="LineNr"> 515 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> subop = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span class="Comment">// middle 3 'reg opcode' bits</span> <span id="L516" class="LineNr"> 516 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>subop<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L517" class="LineNr"> 517 </span> <span class="Normal">case</span> <span class="Constant">4</span>: <span class="Delimiter">{</span> <span class="Comment">// shift left r/m32 by CL</span> <span id="L518" class="LineNr"> 518 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: shift left by CL bits"</span> << end<span class="Delimiter">();</span> -<span id="L519" class="LineNr"> 519 </span> <span class="Normal">uint8_t</span> count = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u & <span class="Constant">0x1f</span><span class="Delimiter">;</span> +<span id="L519" class="LineNr"> 519 </span> <span class="Normal">uint8_t</span> count = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u & <span class="Constant">0x1f</span><span class="Delimiter">;</span> <span id="L520" class="LineNr"> 520 </span> <span class="Comment">// OF is only defined if count is 1</span> <span id="L521" class="LineNr"> 521 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>count == <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L522" class="LineNr"> 522 </span> <span class="Normal">bool</span> msb = <span class="Delimiter">(</span>*arg1 & <span class="Constant">0x80000000</span><span class="Delimiter">)</span> >> <span class="Constant">1</span><span class="Delimiter">;</span> <span id="L523" class="LineNr"> 523 </span> <span class="Normal">bool</span> pnsb = <span class="Delimiter">(</span>*arg1 & <span class="Constant">0x40000000</span><span class="Delimiter">);</span> -<span id="L524" class="LineNr"> 524 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>msb != pnsb<span class="Delimiter">);</span> +<span id="L524" class="LineNr"> 524 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>msb != pnsb<span class="Delimiter">);</span> <span id="L525" class="LineNr"> 525 </span> <span class="Delimiter">}</span> <span id="L526" class="LineNr"> 526 </span> <span class="Normal">int32_t</span> result = <span class="Delimiter">(</span>*arg1 << count<span class="Delimiter">);</span> -<span id="L527" class="LineNr"> 527 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>result == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L527" class="LineNr"> 527 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>result == <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L528" class="LineNr"> 528 </span> SF = <span class="Delimiter">(</span>result < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L529" class="LineNr"> 529 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>*arg1 << <span class="Delimiter">(</span>count-<span class="Constant">1</span><span class="Delimiter">))</span> & <span class="Constant">0x80000000</span><span class="Delimiter">;</span> -<span id="L530" class="LineNr"> 530 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L529" class="LineNr"> 529 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>*arg1 << <span class="Delimiter">(</span>count-<span class="Constant">1</span><span class="Delimiter">))</span> & <span class="Constant">0x80000000</span><span class="Delimiter">;</span> +<span id="L530" class="LineNr"> 530 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L531" class="LineNr"> 531 </span> *arg1 = result<span class="Delimiter">;</span> -<span id="L532" class="LineNr"> 532 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> +<span id="L532" class="LineNr"> 532 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> <span id="L533" class="LineNr"> 533 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L534" class="LineNr"> 534 </span> <span class="Delimiter">}</span> <span id="L535" class="LineNr"> 535 </span> <span class="Comment">// End Op d3 Subops</span> <span id="L536" class="LineNr"> 536 </span> <span class="Normal">default</span>: -<span id="L537" class="LineNr"> 537 </span> cerr << <span class="Constant">"unrecognized subop for opcode d3: "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L537" class="LineNr"> 537 </span> cerr << <span class="Constant">"unrecognized subop for opcode d3: "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span id="L538" class="LineNr"> 538 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L539" class="LineNr"> 539 </span> <span class="Delimiter">}</span> <span id="L540" class="LineNr"> 540 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -605,9 +605,9 @@ if ('onhashchange' in window) { <span id="L544" class="LineNr"> 544 </span> <span id="L545" class="LineNr"> 545 </span><span class="Delimiter">:(code)</span> <span id="L546" class="LineNr"> 546 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L546'>test_shift_right_arithmetic_r32_with_cl</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L547" class="LineNr"> 547 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">26</span><span class="Delimiter">;</span> -<span id="L548" class="LineNr"> 548 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L549" class="LineNr"> 549 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L547" class="LineNr"> 547 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">26</span><span class="Delimiter">;</span> +<span id="L548" class="LineNr"> 548 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L549" class="LineNr"> 549 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L550" class="LineNr"> 550 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L551" class="LineNr"> 551 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L552" class="LineNr"> 552 </span> <span class="Constant">" d3 fb \n"</span> <span class="Comment">// shift EBX right by CL bits, while preserving sign</span> @@ -624,22 +624,22 @@ if ('onhashchange' in window) { <span id="L563" class="LineNr"> 563 </span><span class="Delimiter">:(before "End Op d3 Subops")</span> <span id="L564" class="LineNr"> 564 </span><span class="Normal">case</span> <span class="Constant">7</span>: <span class="Delimiter">{</span> <span class="Comment">// shift right r/m32 by CL, preserving sign</span> <span id="L565" class="LineNr"> 565 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: shift right by CL bits, while preserving sign"</span> << end<span class="Delimiter">();</span> -<span id="L566" class="LineNr"> 566 </span> <span class="Normal">uint8_t</span> count = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u & <span class="Constant">0x1f</span><span class="Delimiter">;</span> +<span id="L566" class="LineNr"> 566 </span> <span class="Normal">uint8_t</span> count = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u & <span class="Constant">0x1f</span><span class="Delimiter">;</span> <span id="L567" class="LineNr"> 567 </span> *arg1 = <span class="Delimiter">(</span>*arg1 >> count<span class="Delimiter">);</span> -<span id="L568" class="LineNr"> 568 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L568" class="LineNr"> 568 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L569" class="LineNr"> 569 </span> SF = <span class="Delimiter">(</span>*arg1 < <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L570" class="LineNr"> 570 </span> <span class="Comment">// OF is only defined if count is 1</span> -<span id="L571" class="LineNr"> 571 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>count == <span class="Constant">1</span><span class="Delimiter">)</span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L571" class="LineNr"> 571 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>count == <span class="Constant">1</span><span class="Delimiter">)</span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L572" class="LineNr"> 572 </span> <span class="Comment">// CF undefined</span> -<span id="L573" class="LineNr"> 573 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> +<span id="L573" class="LineNr"> 573 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> <span id="L574" class="LineNr"> 574 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L575" class="LineNr"> 575 </span><span class="Delimiter">}</span> <span id="L576" class="LineNr"> 576 </span> <span id="L577" class="LineNr"> 577 </span><span class="Delimiter">:(code)</span> <span id="L578" class="LineNr"> 578 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L578'>test_shift_right_arithmetic_odd_r32_with_cl</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L579" class="LineNr"> 579 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">27</span><span class="Delimiter">;</span> -<span id="L580" class="LineNr"> 580 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L581" class="LineNr"> 581 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L579" class="LineNr"> 579 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">27</span><span class="Delimiter">;</span> +<span id="L580" class="LineNr"> 580 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L581" class="LineNr"> 581 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L582" class="LineNr"> 582 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L583" class="LineNr"> 583 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L584" class="LineNr"> 584 </span> <span class="Constant">" d3 fb \n"</span> <span class="Comment">// shift EBX right by CL bits, while preserving sign</span> @@ -655,9 +655,9 @@ if ('onhashchange' in window) { <span id="L594" class="LineNr"> 594 </span><span class="Delimiter">}</span> <span id="L595" class="LineNr"> 595 </span> <span id="L596" class="LineNr"> 596 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L596'>test_shift_right_arithmetic_negative_r32_with_cl</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L597" class="LineNr"> 597 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xfffffffd</span><span class="Delimiter">;</span> <span class="Comment">// -3</span> -<span id="L598" class="LineNr"> 598 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L599" class="LineNr"> 599 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L597" class="LineNr"> 597 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xfffffffd</span><span class="Delimiter">;</span> <span class="Comment">// -3</span> +<span id="L598" class="LineNr"> 598 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L599" class="LineNr"> 599 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L600" class="LineNr"> 600 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L601" class="LineNr"> 601 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L602" class="LineNr"> 602 </span> <span class="Constant">" d3 fb \n"</span> <span class="Comment">// shift EBX right by CL bits, while preserving sign</span> @@ -676,9 +676,9 @@ if ('onhashchange' in window) { <span id="L615" class="LineNr"> 615 </span> <span id="L616" class="LineNr"> 616 </span><span class="Delimiter">:(code)</span> <span id="L617" class="LineNr"> 617 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L617'>test_shift_right_logical_r32_with_cl</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L618" class="LineNr"> 618 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">26</span><span class="Delimiter">;</span> -<span id="L619" class="LineNr"> 619 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L620" class="LineNr"> 620 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L618" class="LineNr"> 618 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">26</span><span class="Delimiter">;</span> +<span id="L619" class="LineNr"> 619 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L620" class="LineNr"> 620 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L621" class="LineNr"> 621 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L622" class="LineNr"> 622 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L623" class="LineNr"> 623 </span> <span class="Constant">" d3 eb \n"</span> <span class="Comment">// shift EBX right by CL bits, while padding zeroes</span> @@ -696,28 +696,28 @@ if ('onhashchange' in window) { <span id="L635" class="LineNr"> 635 </span><span class="Delimiter">:(before "End Op d3 Subops")</span> <span id="L636" class="LineNr"> 636 </span><span class="Normal">case</span> <span class="Constant">5</span>: <span class="Delimiter">{</span> <span class="Comment">// shift right r/m32 by CL, padding zeroes</span> <span id="L637" class="LineNr"> 637 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: shift right by CL bits, while padding zeroes"</span> << end<span class="Delimiter">();</span> -<span id="L638" class="LineNr"> 638 </span> <span class="Normal">uint8_t</span> count = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u & <span class="Constant">0x1f</span><span class="Delimiter">;</span> +<span id="L638" class="LineNr"> 638 </span> <span class="Normal">uint8_t</span> count = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u & <span class="Constant">0x1f</span><span class="Delimiter">;</span> <span id="L639" class="LineNr"> 639 </span> <span class="Comment">// OF is only defined if count is 1</span> <span id="L640" class="LineNr"> 640 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>count == <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L641" class="LineNr"> 641 </span> <span class="Normal">bool</span> msb = <span class="Delimiter">(</span>*arg1 & <span class="Constant">0x80000000</span><span class="Delimiter">)</span> >> <span class="Constant">1</span><span class="Delimiter">;</span> <span id="L642" class="LineNr"> 642 </span> <span class="Normal">bool</span> pnsb = <span class="Delimiter">(</span>*arg1 & <span class="Constant">0x40000000</span><span class="Delimiter">);</span> -<span id="L643" class="LineNr"> 643 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>msb != pnsb<span class="Delimiter">);</span> +<span id="L643" class="LineNr"> 643 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>msb != pnsb<span class="Delimiter">);</span> <span id="L644" class="LineNr"> 644 </span> <span class="Delimiter">}</span> <span id="L645" class="LineNr"> 645 </span> <span class="Normal">uint32_t</span>* uarg1 = <span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>arg1<span class="Delimiter">);</span> <span id="L646" class="LineNr"> 646 </span> *uarg1 = <span class="Delimiter">(</span>*uarg1 >> count<span class="Delimiter">);</span> -<span id="L647" class="LineNr"> 647 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*uarg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L647" class="LineNr"> 647 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*uarg1 == <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L648" class="LineNr"> 648 </span> <span class="Comment">// result is always positive by definition</span> <span id="L649" class="LineNr"> 649 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L650" class="LineNr"> 650 </span> <span class="Comment">// CF undefined</span> -<span id="L651" class="LineNr"> 651 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> +<span id="L651" class="LineNr"> 651 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> <span id="L652" class="LineNr"> 652 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L653" class="LineNr"> 653 </span><span class="Delimiter">}</span> <span id="L654" class="LineNr"> 654 </span> <span id="L655" class="LineNr"> 655 </span><span class="Delimiter">:(code)</span> <span id="L656" class="LineNr"> 656 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L656'>test_shift_right_logical_odd_r32_with_cl</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L657" class="LineNr"> 657 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">27</span><span class="Delimiter">;</span> -<span id="L658" class="LineNr"> 658 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L659" class="LineNr"> 659 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L657" class="LineNr"> 657 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">27</span><span class="Delimiter">;</span> +<span id="L658" class="LineNr"> 658 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L659" class="LineNr"> 659 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L660" class="LineNr"> 660 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L661" class="LineNr"> 661 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L662" class="LineNr"> 662 </span> <span class="Constant">" d3 eb \n"</span> <span class="Comment">// shift EBX right by CL bits, while padding zeroes</span> @@ -733,9 +733,9 @@ if ('onhashchange' in window) { <span id="L672" class="LineNr"> 672 </span><span class="Delimiter">}</span> <span id="L673" class="LineNr"> 673 </span> <span id="L674" class="LineNr"> 674 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L674'>test_shift_right_logical_negative_r32_with_cl</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L675" class="LineNr"> 675 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xfffffffd</span><span class="Delimiter">;</span> -<span id="L676" class="LineNr"> 676 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L677" class="LineNr"> 677 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L675" class="LineNr"> 675 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xfffffffd</span><span class="Delimiter">;</span> +<span id="L676" class="LineNr"> 676 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L677" class="LineNr"> 677 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L678" class="LineNr"> 678 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L679" class="LineNr"> 679 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L680" class="LineNr"> 680 </span> <span class="Constant">" d3 eb \n"</span> <span class="Comment">// shift EBX right by CL bits, while padding zeroes</span> @@ -752,20 +752,20 @@ if ('onhashchange' in window) { <span id="L691" class="LineNr"> 691 </span><span class="SalientComment">//:: and</span> <span id="L692" class="LineNr"> 692 </span> <span id="L693" class="LineNr"> 693 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L694" class="LineNr"> 694 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"21"</span><span class="Delimiter">,</span> <span class="Constant">"rm32 = bitwise AND of r32 with rm32 (and)"</span><span class="Delimiter">);</span> +<span id="L694" class="LineNr"> 694 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"21"</span><span class="Delimiter">,</span> <span class="Constant">"rm32 = bitwise AND of r32 with rm32 (and)"</span><span class="Delimiter">);</span> <span id="L695" class="LineNr"> 695 </span> <span id="L696" class="LineNr"> 696 </span><span class="Delimiter">:(code)</span> <span id="L697" class="LineNr"> 697 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L697'>test_and_r32_with_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L698" class="LineNr"> 698 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L699" class="LineNr"> 699 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x000000ff</span><span class="Delimiter">;</span> -<span id="L700" class="LineNr"> 700 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L698" class="LineNr"> 698 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L699" class="LineNr"> 699 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x000000ff</span><span class="Delimiter">;</span> +<span id="L700" class="LineNr"> 700 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L701" class="LineNr"> 701 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L702" class="LineNr"> 702 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L703" class="LineNr"> 703 </span> <span class="Constant">" 21 d8 \n"</span> <span class="Comment">// and EBX with destination EAX</span> <span id="L704" class="LineNr"> 704 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L705" class="LineNr"> 705 </span> <span class="Delimiter">);</span> <span id="L706" class="LineNr"> 706 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L707" class="LineNr"> 707 </span> <span class="Constant">"run: and <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> +<span id="L707" class="LineNr"> 707 </span> <span class="Constant">"run: and <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> <span id="L708" class="LineNr"> 708 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L709" class="LineNr"> 709 </span> <span class="Constant">"run: storing 0x0000000d\n"</span> <span id="L710" class="LineNr"> 710 </span> <span class="Delimiter">);</span> @@ -773,39 +773,39 @@ if ('onhashchange' in window) { <span id="L712" class="LineNr"> 712 </span> <span id="L713" class="LineNr"> 713 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L714" class="LineNr"> 714 </span><span class="Normal">case</span> <span class="Constant">0x21</span>: <span class="Delimiter">{</span> <span class="Comment">// and r32 with r/m32</span> -<span id="L715" class="LineNr"> 715 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L715" class="LineNr"> 715 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L716" class="LineNr"> 716 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg2 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L717" class="LineNr"> 717 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"and "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg2<span class="Delimiter">)</span> << <span class="Constant">" with r/m32"</span> << end<span class="Delimiter">();</span> <span id="L718" class="LineNr"> 718 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L719" class="LineNr"> 719 </span> <span class="Comment">// difference</span> <span id="L720" class="LineNr"> 720 </span> <span class="Normal">int32_t</span>* signed_arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L721" class="LineNr"> 721 </span> *signed_arg1 &= <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> -<span id="L722" class="LineNr"> 722 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> +<span id="L721" class="LineNr"> 721 </span> *signed_arg1 &= <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L722" class="LineNr"> 722 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> <span id="L723" class="LineNr"> 723 </span> SF = <span class="Delimiter">(</span>*signed_arg1 >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L724" class="LineNr"> 724 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L725" class="LineNr"> 725 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L726" class="LineNr"> 726 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L727" class="LineNr"> 727 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L724" class="LineNr"> 724 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L725" class="LineNr"> 725 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L726" class="LineNr"> 726 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L727" class="LineNr"> 727 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L728" class="LineNr"> 728 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L729" class="LineNr"> 729 </span><span class="Delimiter">}</span> <span id="L730" class="LineNr"> 730 </span> <span id="L731" class="LineNr"> 731 </span><span class="SalientComment">//:: or</span> <span id="L732" class="LineNr"> 732 </span> <span id="L733" class="LineNr"> 733 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L734" class="LineNr"> 734 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"09"</span><span class="Delimiter">,</span> <span class="Constant">"rm32 = bitwise OR of r32 with rm32 (or)"</span><span class="Delimiter">);</span> +<span id="L734" class="LineNr"> 734 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"09"</span><span class="Delimiter">,</span> <span class="Constant">"rm32 = bitwise OR of r32 with rm32 (or)"</span><span class="Delimiter">);</span> <span id="L735" class="LineNr"> 735 </span> <span id="L736" class="LineNr"> 736 </span><span class="Delimiter">:(code)</span> <span id="L737" class="LineNr"> 737 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L737'>test_or_r32_with_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L738" class="LineNr"> 738 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L739" class="LineNr"> 739 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xa0b0c0d0</span><span class="Delimiter">;</span> -<span id="L740" class="LineNr"> 740 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L738" class="LineNr"> 738 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L739" class="LineNr"> 739 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xa0b0c0d0</span><span class="Delimiter">;</span> +<span id="L740" class="LineNr"> 740 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L741" class="LineNr"> 741 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L742" class="LineNr"> 742 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L743" class="LineNr"> 743 </span> <span class="Constant">" 09 d8 \n"</span> <span class="Comment">// or EBX with destination EAX</span> <span id="L744" class="LineNr"> 744 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L745" class="LineNr"> 745 </span> <span class="Delimiter">);</span> <span id="L746" class="LineNr"> 746 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L747" class="LineNr"> 747 </span> <span class="Constant">"run: or <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> +<span id="L747" class="LineNr"> 747 </span> <span class="Constant">"run: or <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> <span id="L748" class="LineNr"> 748 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L749" class="LineNr"> 749 </span> <span class="Constant">"run: storing 0xaabbccdd\n"</span> <span id="L750" class="LineNr"> 750 </span> <span class="Delimiter">);</span> @@ -813,39 +813,39 @@ if ('onhashchange' in window) { <span id="L752" class="LineNr"> 752 </span> <span id="L753" class="LineNr"> 753 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L754" class="LineNr"> 754 </span><span class="Normal">case</span> <span class="Constant">0x09</span>: <span class="Delimiter">{</span> <span class="Comment">// or r32 with r/m32</span> -<span id="L755" class="LineNr"> 755 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L755" class="LineNr"> 755 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L756" class="LineNr"> 756 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg2 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L757" class="LineNr"> 757 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"or "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg2<span class="Delimiter">)</span> << <span class="Constant">" with r/m32"</span> << end<span class="Delimiter">();</span> <span id="L758" class="LineNr"> 758 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L759" class="LineNr"> 759 </span> <span class="Comment">// difference</span> <span id="L760" class="LineNr"> 760 </span> <span class="Normal">int32_t</span>* signed_arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L761" class="LineNr"> 761 </span> *signed_arg1 |= <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> -<span id="L762" class="LineNr"> 762 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> +<span id="L761" class="LineNr"> 761 </span> *signed_arg1 |= <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L762" class="LineNr"> 762 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> <span id="L763" class="LineNr"> 763 </span> SF = <span class="Delimiter">(</span>*signed_arg1 >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L764" class="LineNr"> 764 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L765" class="LineNr"> 765 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L766" class="LineNr"> 766 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L767" class="LineNr"> 767 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L764" class="LineNr"> 764 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L765" class="LineNr"> 765 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L766" class="LineNr"> 766 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L767" class="LineNr"> 767 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L768" class="LineNr"> 768 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L769" class="LineNr"> 769 </span><span class="Delimiter">}</span> <span id="L770" class="LineNr"> 770 </span> <span id="L771" class="LineNr"> 771 </span><span class="SalientComment">//:: xor</span> <span id="L772" class="LineNr"> 772 </span> <span id="L773" class="LineNr"> 773 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L774" class="LineNr"> 774 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"31"</span><span class="Delimiter">,</span> <span class="Constant">"rm32 = bitwise XOR of r32 with rm32 (xor)"</span><span class="Delimiter">);</span> +<span id="L774" class="LineNr"> 774 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"31"</span><span class="Delimiter">,</span> <span class="Constant">"rm32 = bitwise XOR of r32 with rm32 (xor)"</span><span class="Delimiter">);</span> <span id="L775" class="LineNr"> 775 </span> <span id="L776" class="LineNr"> 776 </span><span class="Delimiter">:(code)</span> <span id="L777" class="LineNr"> 777 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L777'>test_xor_r32_with_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L778" class="LineNr"> 778 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L779" class="LineNr"> 779 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xaabbc0d0</span><span class="Delimiter">;</span> -<span id="L780" class="LineNr"> 780 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L778" class="LineNr"> 778 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L779" class="LineNr"> 779 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xaabbc0d0</span><span class="Delimiter">;</span> +<span id="L780" class="LineNr"> 780 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L781" class="LineNr"> 781 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L782" class="LineNr"> 782 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L783" class="LineNr"> 783 </span> <span class="Constant">" 31 d8 \n"</span> <span class="Comment">// xor EBX with destination EAX</span> <span id="L784" class="LineNr"> 784 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L785" class="LineNr"> 785 </span> <span class="Delimiter">);</span> <span id="L786" class="LineNr"> 786 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L787" class="LineNr"> 787 </span> <span class="Constant">"run: xor <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> +<span id="L787" class="LineNr"> 787 </span> <span class="Constant">"run: xor <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> <span id="L788" class="LineNr"> 788 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L789" class="LineNr"> 789 </span> <span class="Constant">"run: storing 0xa0b0ccdd\n"</span> <span id="L790" class="LineNr"> 790 </span> <span class="Delimiter">);</span> @@ -853,19 +853,19 @@ if ('onhashchange' in window) { <span id="L792" class="LineNr"> 792 </span> <span id="L793" class="LineNr"> 793 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L794" class="LineNr"> 794 </span><span class="Normal">case</span> <span class="Constant">0x31</span>: <span class="Delimiter">{</span> <span class="Comment">// xor r32 with r/m32</span> -<span id="L795" class="LineNr"> 795 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L795" class="LineNr"> 795 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L796" class="LineNr"> 796 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg2 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L797" class="LineNr"> 797 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"xor "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg2<span class="Delimiter">)</span> << <span class="Constant">" with r/m32"</span> << end<span class="Delimiter">();</span> <span id="L798" class="LineNr"> 798 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L799" class="LineNr"> 799 </span> <span class="Comment">// difference</span> <span id="L800" class="LineNr"> 800 </span> <span class="Normal">int32_t</span>* signed_arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L801" class="LineNr"> 801 </span> *signed_arg1 ^= <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> -<span id="L802" class="LineNr"> 802 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> +<span id="L801" class="LineNr"> 801 </span> *signed_arg1 ^= <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L802" class="LineNr"> 802 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> <span id="L803" class="LineNr"> 803 </span> SF = <span class="Delimiter">(</span>*signed_arg1 >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L804" class="LineNr"> 804 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L805" class="LineNr"> 805 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L806" class="LineNr"> 806 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L807" class="LineNr"> 807 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L804" class="LineNr"> 804 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L805" class="LineNr"> 805 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L806" class="LineNr"> 806 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L807" class="LineNr"> 807 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L808" class="LineNr"> 808 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L809" class="LineNr"> 809 </span><span class="Delimiter">}</span> <span id="L810" class="LineNr"> 810 </span> @@ -873,8 +873,8 @@ if ('onhashchange' in window) { <span id="L812" class="LineNr"> 812 </span> <span id="L813" class="LineNr"> 813 </span><span class="Delimiter">:(code)</span> <span id="L814" class="LineNr"> 814 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L814'>test_not_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L815" class="LineNr"> 815 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0f0f00ff</span><span class="Delimiter">;</span> -<span id="L816" class="LineNr"> 816 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L815" class="LineNr"> 815 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0f0f00ff</span><span class="Delimiter">;</span> +<span id="L816" class="LineNr"> 816 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L817" class="LineNr"> 817 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L818" class="LineNr"> 818 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L819" class="LineNr"> 819 </span> <span class="Constant">" f7 d3 \n"</span> <span class="Comment">// not EBX</span> @@ -892,7 +892,7 @@ if ('onhashchange' in window) { <span id="L831" class="LineNr"> 831 </span><span class="Normal">case</span> <span class="Constant">2</span>: <span class="Delimiter">{</span> <span class="Comment">// not r/m32</span> <span id="L832" class="LineNr"> 832 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: not"</span> << end<span class="Delimiter">();</span> <span id="L833" class="LineNr"> 833 </span> *arg1 = ~<span class="Delimiter">(</span>*arg1<span class="Delimiter">);</span> -<span id="L834" class="LineNr"> 834 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> +<span id="L834" class="LineNr"> 834 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> <span id="L835" class="LineNr"> 835 </span> <span class="Comment">// no flags affected</span> <span id="L836" class="LineNr"> 836 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L837" class="LineNr"> 837 </span><span class="Delimiter">}</span> @@ -900,13 +900,13 @@ if ('onhashchange' in window) { <span id="L839" class="LineNr"> 839 </span><span class="SalientComment">//:: compare (cmp)</span> <span id="L840" class="LineNr"> 840 </span> <span id="L841" class="LineNr"> 841 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L842" class="LineNr"> 842 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"39"</span><span class="Delimiter">,</span> <span class="Constant">"compare: set SF if rm32 < r32 (cmp)"</span><span class="Delimiter">);</span> +<span id="L842" class="LineNr"> 842 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"39"</span><span class="Delimiter">,</span> <span class="Constant">"compare: set SF if rm32 < r32 (cmp)"</span><span class="Delimiter">);</span> <span id="L843" class="LineNr"> 843 </span> <span id="L844" class="LineNr"> 844 </span><span class="Delimiter">:(code)</span> <span id="L845" class="LineNr"> 845 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L845'>test_compare_r32_with_r32_greater</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L846" class="LineNr"> 846 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L847" class="LineNr"> 847 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> -<span id="L848" class="LineNr"> 848 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L846" class="LineNr"> 846 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L847" class="LineNr"> 847 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> +<span id="L848" class="LineNr"> 848 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L849" class="LineNr"> 849 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L850" class="LineNr"> 850 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L851" class="LineNr"> 851 </span> <span class="Constant">" 39 d8 \n"</span> <span class="Comment">// compare EAX with EBX</span> @@ -921,29 +921,29 @@ if ('onhashchange' in window) { <span id="L860" class="LineNr"> 860 </span> <span id="L861" class="LineNr"> 861 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L862" class="LineNr"> 862 </span><span class="Normal">case</span> <span class="Constant">0x39</span>: <span class="Delimiter">{</span> <span class="Comment">// set SF if r/m32 < r32</span> -<span id="L863" class="LineNr"> 863 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L863" class="LineNr"> 863 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L864" class="LineNr"> 864 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> reg2 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L865" class="LineNr"> 865 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"compare r/m32 with "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>reg2<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L866" class="LineNr"> 866 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* signed_arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L867" class="LineNr"> 867 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_difference = *signed_arg1 - <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L867" class="LineNr"> 867 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_difference = *signed_arg1 - <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> <span id="L868" class="LineNr"> 868 </span> SF = <span class="Delimiter">(</span>signed_difference < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L869" class="LineNr"> 869 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_difference == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L870" class="LineNr"> 870 </span> <span class="Normal">const</span> <span class="Normal">int64_t</span> signed_full_difference = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">)</span> - <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> -<span id="L871" class="LineNr"> 871 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_difference != signed_full_difference<span class="Delimiter">);</span> +<span id="L869" class="LineNr"> 869 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_difference == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L870" class="LineNr"> 870 </span> <span class="Normal">const</span> <span class="Normal">int64_t</span> signed_full_difference = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">)</span> - <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L871" class="LineNr"> 871 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_difference != signed_full_difference<span class="Delimiter">);</span> <span id="L872" class="LineNr"> 872 </span> <span class="Comment">// set CF</span> <span id="L873" class="LineNr"> 873 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_arg1 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">);</span> -<span id="L874" class="LineNr"> 874 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_difference = unsigned_arg1 - <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L875" class="LineNr"> 875 </span> <span class="Normal">const</span> <span class="Normal">uint64_t</span> unsigned_full_difference = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span>unsigned_arg1<span class="Delimiter">)</span> - <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L876" class="LineNr"> 876 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_difference != unsigned_full_difference<span class="Delimiter">);</span> -<span id="L877" class="LineNr"> 877 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L874" class="LineNr"> 874 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_difference = unsigned_arg1 - <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L875" class="LineNr"> 875 </span> <span class="Normal">const</span> <span class="Normal">uint64_t</span> unsigned_full_difference = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span>unsigned_arg1<span class="Delimiter">)</span> - <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg2]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L876" class="LineNr"> 876 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_difference != unsigned_full_difference<span class="Delimiter">);</span> +<span id="L877" class="LineNr"> 877 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L878" class="LineNr"> 878 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L879" class="LineNr"> 879 </span><span class="Delimiter">}</span> <span id="L880" class="LineNr"> 880 </span> <span id="L881" class="LineNr"> 881 </span><span class="Delimiter">:(code)</span> <span id="L882" class="LineNr"> 882 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L882'>test_compare_r32_with_r32_lesser_unsigned_and_signed</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L883" class="LineNr"> 883 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> -<span id="L884" class="LineNr"> 884 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L885" class="LineNr"> 885 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L883" class="LineNr"> 883 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> +<span id="L884" class="LineNr"> 884 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L885" class="LineNr"> 885 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L886" class="LineNr"> 886 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L887" class="LineNr"> 887 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L888" class="LineNr"> 888 </span> <span class="Constant">" 39 d8 \n"</span> <span class="Comment">// compare EAX with EBX</span> @@ -957,9 +957,9 @@ if ('onhashchange' in window) { <span id="L896" class="LineNr"> 896 </span><span class="Delimiter">}</span> <span id="L897" class="LineNr"> 897 </span> <span id="L898" class="LineNr"> 898 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L898'>test_compare_r32_with_r32_lesser_unsigned_and_signed_due_to_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L899" class="LineNr"> 899 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> -<span id="L900" class="LineNr"> 900 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> -<span id="L901" class="LineNr"> 901 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L899" class="LineNr"> 899 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> +<span id="L900" class="LineNr"> 900 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> +<span id="L901" class="LineNr"> 901 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L902" class="LineNr"> 902 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L903" class="LineNr"> 903 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L904" class="LineNr"> 904 </span> <span class="Constant">" 39 d8 \n"</span> <span class="Comment">// compare EAX with EBX</span> @@ -973,9 +973,9 @@ if ('onhashchange' in window) { <span id="L912" class="LineNr"> 912 </span><span class="Delimiter">}</span> <span id="L913" class="LineNr"> 913 </span> <span id="L914" class="LineNr"> 914 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L914'>test_compare_r32_with_r32_lesser_signed</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L915" class="LineNr"> 915 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// -1</span> -<span id="L916" class="LineNr"> 916 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x00000001</span><span class="Delimiter">;</span> <span class="Comment">// 1</span> -<span id="L917" class="LineNr"> 917 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L915" class="LineNr"> 915 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// -1</span> +<span id="L916" class="LineNr"> 916 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x00000001</span><span class="Delimiter">;</span> <span class="Comment">// 1</span> +<span id="L917" class="LineNr"> 917 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L918" class="LineNr"> 918 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L919" class="LineNr"> 919 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L920" class="LineNr"> 920 </span> <span class="Constant">" 39 d8 \n"</span> <span class="Comment">// compare EAX with EBX</span> @@ -989,9 +989,9 @@ if ('onhashchange' in window) { <span id="L928" class="LineNr"> 928 </span><span class="Delimiter">}</span> <span id="L929" class="LineNr"> 929 </span> <span id="L930" class="LineNr"> 930 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L930'>test_compare_r32_with_r32_lesser_unsigned</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L931" class="LineNr"> 931 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x00000001</span><span class="Delimiter">;</span> <span class="Comment">// 1</span> -<span id="L932" class="LineNr"> 932 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// -1</span> -<span id="L933" class="LineNr"> 933 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L931" class="LineNr"> 931 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x00000001</span><span class="Delimiter">;</span> <span class="Comment">// 1</span> +<span id="L932" class="LineNr"> 932 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// -1</span> +<span id="L933" class="LineNr"> 933 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L934" class="LineNr"> 934 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L935" class="LineNr"> 935 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L936" class="LineNr"> 936 </span> <span class="Constant">" 39 d8 \n"</span> <span class="Comment">// compare EAX with EBX</span> @@ -1005,9 +1005,9 @@ if ('onhashchange' in window) { <span id="L944" class="LineNr"> 944 </span><span class="Delimiter">}</span> <span id="L945" class="LineNr"> 945 </span> <span id="L946" class="LineNr"> 946 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L946'>test_compare_r32_with_r32_equal</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L947" class="LineNr"> 947 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L948" class="LineNr"> 948 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L949" class="LineNr"> 949 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L947" class="LineNr"> 947 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L948" class="LineNr"> 948 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L949" class="LineNr"> 949 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L950" class="LineNr"> 950 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L951" class="LineNr"> 951 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L952" class="LineNr"> 952 </span> <span class="Constant">" 39 d8 \n"</span> <span class="Comment">// compare EAX and EBX</span> @@ -1023,19 +1023,19 @@ if ('onhashchange' in window) { <span id="L962" class="LineNr"> 962 </span><span class="SalientComment">//:: copy (mov)</span> <span id="L963" class="LineNr"> 963 </span> <span id="L964" class="LineNr"> 964 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L965" class="LineNr"> 965 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"89"</span><span class="Delimiter">,</span> <span class="Constant">"copy r32 to rm32 (mov)"</span><span class="Delimiter">);</span> +<span id="L965" class="LineNr"> 965 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"89"</span><span class="Delimiter">,</span> <span class="Constant">"copy r32 to rm32 (mov)"</span><span class="Delimiter">);</span> <span id="L966" class="LineNr"> 966 </span> <span id="L967" class="LineNr"> 967 </span><span class="Delimiter">:(code)</span> <span id="L968" class="LineNr"> 968 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L968'>test_copy_r32_to_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L969" class="LineNr"> 969 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xaf</span><span class="Delimiter">;</span> -<span id="L970" class="LineNr"> 970 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L969" class="LineNr"> 969 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xaf</span><span class="Delimiter">;</span> +<span id="L970" class="LineNr"> 970 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L971" class="LineNr"> 971 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L972" class="LineNr"> 972 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L973" class="LineNr"> 973 </span> <span class="Constant">" 89 d8 \n"</span> <span class="Comment">// copy EBX to EAX</span> <span id="L974" class="LineNr"> 974 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L975" class="LineNr"> 975 </span> <span class="Delimiter">);</span> <span id="L976" class="LineNr"> 976 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L977" class="LineNr"> 977 </span> <span class="Constant">"run: copy <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> +<span id="L977" class="LineNr"> 977 </span> <span class="Constant">"run: copy <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> <span id="L978" class="LineNr"> 978 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L979" class="LineNr"> 979 </span> <span class="Constant">"run: storing 0x000000af\n"</span> <span id="L980" class="LineNr"> 980 </span> <span class="Delimiter">);</span> @@ -1043,32 +1043,32 @@ if ('onhashchange' in window) { <span id="L982" class="LineNr"> 982 </span> <span id="L983" class="LineNr"> 983 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L984" class="LineNr"> 984 </span><span class="Normal">case</span> <span class="Constant">0x89</span>: <span class="Delimiter">{</span> <span class="Comment">// copy r32 to r/m32</span> -<span id="L985" class="LineNr"> 985 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L985" class="LineNr"> 985 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L986" class="LineNr"> 986 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> rsrc = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L987" class="LineNr"> 987 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rsrc<span class="Delimiter">)</span> << <span class="Constant">" to r/m32"</span> << end<span class="Delimiter">();</span> <span id="L988" class="LineNr"> 988 </span> <span class="Normal">int32_t</span>* dest = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L989" class="LineNr"> 989 </span> *dest = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[rsrc]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> -<span id="L990" class="LineNr"> 990 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *dest << end<span class="Delimiter">();</span> +<span id="L989" class="LineNr"> 989 </span> *dest = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[rsrc]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L990" class="LineNr"> 990 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *dest << end<span class="Delimiter">();</span> <span id="L991" class="LineNr"> 991 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L992" class="LineNr"> 992 </span><span class="Delimiter">}</span> <span id="L993" class="LineNr"> 993 </span> <span id="L994" class="LineNr"> 994 </span><span class="SalientComment">//:: xchg</span> <span id="L995" class="LineNr"> 995 </span> <span id="L996" class="LineNr"> 996 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L997" class="LineNr"> 997 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"87"</span><span class="Delimiter">,</span> <span class="Constant">"swap the <a href='003trace.cc.html#L117'>contents</a> of r32 and rm32 (xchg)"</span><span class="Delimiter">);</span> +<span id="L997" class="LineNr"> 997 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"87"</span><span class="Delimiter">,</span> <span class="Constant">"swap the <a href='003trace.cc.html#L117'>contents</a> of r32 and rm32 (xchg)"</span><span class="Delimiter">);</span> <span id="L998" class="LineNr"> 998 </span> <span id="L999" class="LineNr"> 999 </span><span class="Delimiter">:(code)</span> <span id="L1000" class="LineNr">1000 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L1000'>test_xchg_r32_with_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1001" class="LineNr">1001 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xaf</span><span class="Delimiter">;</span> -<span id="L1002" class="LineNr">1002 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2e</span><span class="Delimiter">;</span> -<span id="L1003" class="LineNr">1003 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1001" class="LineNr">1001 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xaf</span><span class="Delimiter">;</span> +<span id="L1002" class="LineNr">1002 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2e</span><span class="Delimiter">;</span> +<span id="L1003" class="LineNr">1003 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1004" class="LineNr">1004 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L1005" class="LineNr">1005 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1006" class="LineNr">1006 </span> <span class="Constant">" 87 d8 \n"</span> <span class="Comment">// exchange EBX with EAX</span> <span id="L1007" class="LineNr">1007 </span> <span class="Comment">// ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)</span> <span id="L1008" class="LineNr">1008 </span> <span class="Delimiter">);</span> <span id="L1009" class="LineNr">1009 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L1010" class="LineNr">1010 </span> <span class="Constant">"run: exchange <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> +<span id="L1010" class="LineNr">1010 </span> <span class="Constant">"run: exchange <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> <span id="L1011" class="LineNr">1011 </span> <span class="Constant">"run: r/m32 is EAX\n"</span> <span id="L1012" class="LineNr">1012 </span> <span class="Constant">"run: storing 0x000000af in r/m32\n"</span> <span id="L1013" class="LineNr">1013 </span> <span class="Constant">"run: storing 0x0000002e in EBX\n"</span> @@ -1077,34 +1077,34 @@ if ('onhashchange' in window) { <span id="L1016" class="LineNr">1016 </span> <span id="L1017" class="LineNr">1017 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L1018" class="LineNr">1018 </span><span class="Normal">case</span> <span class="Constant">0x87</span>: <span class="Delimiter">{</span> <span class="Comment">// exchange r32 with r/m32</span> -<span id="L1019" class="LineNr">1019 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L1019" class="LineNr">1019 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L1020" class="LineNr">1020 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> reg2 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L1021" class="LineNr">1021 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"exchange "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>reg2<span class="Delimiter">)</span> << <span class="Constant">" with r/m32"</span> << end<span class="Delimiter">();</span> <span id="L1022" class="LineNr">1022 </span> <span class="Normal">int32_t</span>* arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> <span id="L1023" class="LineNr">1023 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> tmp = *arg1<span class="Delimiter">;</span> -<span id="L1024" class="LineNr">1024 </span> *arg1 = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> -<span id="L1025" class="LineNr">1025 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg2]<span class="Delimiter">.</span>i = tmp<span class="Delimiter">;</span> -<span id="L1026" class="LineNr">1026 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg1 << <span class="Constant">" in r/m32"</span> << end<span class="Delimiter">();</span> -<span id="L1027" class="LineNr">1027 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg2]<span class="Delimiter">.</span>i << <span class="Constant">" in "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>reg2<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L1024" class="LineNr">1024 </span> *arg1 = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg2]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L1025" class="LineNr">1025 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg2]<span class="Delimiter">.</span>i = tmp<span class="Delimiter">;</span> +<span id="L1026" class="LineNr">1026 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg1 << <span class="Constant">" in r/m32"</span> << end<span class="Delimiter">();</span> +<span id="L1027" class="LineNr">1027 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg2]<span class="Delimiter">.</span>i << <span class="Constant">" in "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>reg2<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L1028" class="LineNr">1028 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1029" class="LineNr">1029 </span><span class="Delimiter">}</span> <span id="L1030" class="LineNr">1030 </span> <span id="L1031" class="LineNr">1031 </span><span class="SalientComment">//:: increment</span> <span id="L1032" class="LineNr">1032 </span> <span id="L1033" class="LineNr">1033 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L1034" class="LineNr">1034 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"40"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L16'>EAX</a> (inc)"</span><span class="Delimiter">);</span> -<span id="L1035" class="LineNr">1035 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"41"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L17'>ECX</a> (inc)"</span><span class="Delimiter">);</span> -<span id="L1036" class="LineNr">1036 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"42"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L18'>EDX</a> (inc)"</span><span class="Delimiter">);</span> -<span id="L1037" class="LineNr">1037 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"43"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L19'>EBX</a> (inc)"</span><span class="Delimiter">);</span> -<span id="L1038" class="LineNr">1038 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"44"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L20'>ESP</a> (inc)"</span><span class="Delimiter">);</span> -<span id="L1039" class="LineNr">1039 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"45"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L21'>EBP</a> (inc)"</span><span class="Delimiter">);</span> -<span id="L1040" class="LineNr">1040 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"46"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L22'>ESI</a> (inc)"</span><span class="Delimiter">);</span> -<span id="L1041" class="LineNr">1041 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"47"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L23'>EDI</a> (inc)"</span><span class="Delimiter">);</span> +<span id="L1034" class="LineNr">1034 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"40"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L10'>EAX</a> (inc)"</span><span class="Delimiter">);</span> +<span id="L1035" class="LineNr">1035 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"41"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L11'>ECX</a> (inc)"</span><span class="Delimiter">);</span> +<span id="L1036" class="LineNr">1036 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"42"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L12'>EDX</a> (inc)"</span><span class="Delimiter">);</span> +<span id="L1037" class="LineNr">1037 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"43"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L13'>EBX</a> (inc)"</span><span class="Delimiter">);</span> +<span id="L1038" class="LineNr">1038 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"44"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L14'>ESP</a> (inc)"</span><span class="Delimiter">);</span> +<span id="L1039" class="LineNr">1039 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"45"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L15'>EBP</a> (inc)"</span><span class="Delimiter">);</span> +<span id="L1040" class="LineNr">1040 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"46"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L16'>ESI</a> (inc)"</span><span class="Delimiter">);</span> +<span id="L1041" class="LineNr">1041 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"47"</span><span class="Delimiter">,</span> <span class="Constant">"increment <a href='010---vm.cc.html#L17'>EDI</a> (inc)"</span><span class="Delimiter">);</span> <span id="L1042" class="LineNr">1042 </span> <span id="L1043" class="LineNr">1043 </span><span class="Delimiter">:(code)</span> <span id="L1044" class="LineNr">1044 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L1044'>test_increment_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1045" class="LineNr">1045 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u = <span class="Constant">0x1f</span><span class="Delimiter">;</span> -<span id="L1046" class="LineNr">1046 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1045" class="LineNr">1045 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u = <span class="Constant">0x1f</span><span class="Delimiter">;</span> +<span id="L1046" class="LineNr">1046 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1047" class="LineNr">1047 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L1048" class="LineNr">1048 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1049" class="LineNr">1049 </span> <span class="Constant">" 41 \n"</span> <span class="Comment">// increment ECX</span> @@ -1124,20 +1124,20 @@ if ('onhashchange' in window) { <span id="L1063" class="LineNr">1063 </span><span class="Normal">case</span> <span class="Constant">0x45</span>: <span id="L1064" class="LineNr">1064 </span><span class="Normal">case</span> <span class="Constant">0x46</span>: <span id="L1065" class="LineNr">1065 </span><span class="Normal">case</span> <span class="Constant">0x47</span>: <span class="Delimiter">{</span> <span class="Comment">// increment r32</span> -<span id="L1066" class="LineNr">1066 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L26'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> -<span id="L1067" class="LineNr">1067 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"increment "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L26'>reg</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L1068" class="LineNr">1068 </span> ++<span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L1069" class="LineNr">1069 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing value 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L1066" class="LineNr">1066 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L20'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> +<span id="L1067" class="LineNr">1067 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"increment "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L20'>reg</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L1068" class="LineNr">1068 </span> ++<span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L1069" class="LineNr">1069 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing value 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> <span id="L1070" class="LineNr">1070 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1071" class="LineNr">1071 </span><span class="Delimiter">}</span> <span id="L1072" class="LineNr">1072 </span> <span id="L1073" class="LineNr">1073 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L1074" class="LineNr">1074 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"ff"</span><span class="Delimiter">,</span> <span class="Constant">"increment/decrement/jump/push/call rm32 based on subop (inc/dec/jmp/push/call)"</span><span class="Delimiter">);</span> +<span id="L1074" class="LineNr">1074 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"ff"</span><span class="Delimiter">,</span> <span class="Constant">"increment/decrement/jump/push/call rm32 based on subop (inc/dec/jmp/push/call)"</span><span class="Delimiter">);</span> <span id="L1075" class="LineNr">1075 </span> <span id="L1076" class="LineNr">1076 </span><span class="Delimiter">:(code)</span> <span id="L1077" class="LineNr">1077 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L1077'>test_increment_rm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1078" class="LineNr">1078 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x20</span><span class="Delimiter">;</span> -<span id="L1079" class="LineNr">1079 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1078" class="LineNr">1078 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x20</span><span class="Delimiter">;</span> +<span id="L1079" class="LineNr">1079 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1080" class="LineNr">1080 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L1081" class="LineNr">1081 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1082" class="LineNr">1082 </span> <span class="Constant">" ff c0 \n"</span> <span class="Comment">// increment EAX</span> @@ -1152,18 +1152,18 @@ if ('onhashchange' in window) { <span id="L1091" class="LineNr">1091 </span> <span id="L1092" class="LineNr">1092 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L1093" class="LineNr">1093 </span><span class="Normal">case</span> <span class="Constant">0xff</span>: <span class="Delimiter">{</span> -<span id="L1094" class="LineNr">1094 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L1094" class="LineNr">1094 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L1095" class="LineNr">1095 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> subop = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span class="Comment">// middle 3 'reg opcode' bits</span> <span id="L1096" class="LineNr">1096 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>subop<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L1097" class="LineNr">1097 </span> <span class="Normal">case</span> <span class="Constant">0</span>: <span class="Delimiter">{</span> <span class="Comment">// increment r/m32</span> <span id="L1098" class="LineNr">1098 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"increment r/m32"</span> << end<span class="Delimiter">();</span> <span id="L1099" class="LineNr">1099 </span> <span class="Normal">int32_t</span>* <a href='001help.cc.html#L15'>arg</a> = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> <span id="L1100" class="LineNr">1100 </span> ++*arg<span class="Delimiter">;</span> -<span id="L1101" class="LineNr">1101 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing value 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg << end<span class="Delimiter">();</span> +<span id="L1101" class="LineNr">1101 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing value 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg << end<span class="Delimiter">();</span> <span id="L1102" class="LineNr">1102 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1103" class="LineNr">1103 </span> <span class="Delimiter">}</span> <span id="L1104" class="LineNr">1104 </span> <span class="Normal">default</span>: -<span id="L1105" class="LineNr">1105 </span> cerr << <span class="Constant">"unrecognized subop for ff: "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L1105" class="LineNr">1105 </span> cerr << <span class="Constant">"unrecognized subop for ff: "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span id="L1106" class="LineNr">1106 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L1107" class="LineNr">1107 </span> <span class="Comment">// End Op ff Subops</span> <span id="L1108" class="LineNr">1108 </span> <span class="Delimiter">}</span> @@ -1173,19 +1173,19 @@ if ('onhashchange' in window) { <span id="L1112" class="LineNr">1112 </span><span class="SalientComment">//:: decrement</span> <span id="L1113" class="LineNr">1113 </span> <span id="L1114" class="LineNr">1114 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L1115" class="LineNr">1115 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"48"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L16'>EAX</a> (dec)"</span><span class="Delimiter">);</span> -<span id="L1116" class="LineNr">1116 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"49"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L17'>ECX</a> (dec)"</span><span class="Delimiter">);</span> -<span id="L1117" class="LineNr">1117 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4a"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L18'>EDX</a> (dec)"</span><span class="Delimiter">);</span> -<span id="L1118" class="LineNr">1118 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4b"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L19'>EBX</a> (dec)"</span><span class="Delimiter">);</span> -<span id="L1119" class="LineNr">1119 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4c"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L20'>ESP</a> (dec)"</span><span class="Delimiter">);</span> -<span id="L1120" class="LineNr">1120 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4d"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L21'>EBP</a> (dec)"</span><span class="Delimiter">);</span> -<span id="L1121" class="LineNr">1121 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4e"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L22'>ESI</a> (dec)"</span><span class="Delimiter">);</span> -<span id="L1122" class="LineNr">1122 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4f"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L23'>EDI</a> (dec)"</span><span class="Delimiter">);</span> +<span id="L1115" class="LineNr">1115 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"48"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L10'>EAX</a> (dec)"</span><span class="Delimiter">);</span> +<span id="L1116" class="LineNr">1116 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"49"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L11'>ECX</a> (dec)"</span><span class="Delimiter">);</span> +<span id="L1117" class="LineNr">1117 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4a"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L12'>EDX</a> (dec)"</span><span class="Delimiter">);</span> +<span id="L1118" class="LineNr">1118 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4b"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L13'>EBX</a> (dec)"</span><span class="Delimiter">);</span> +<span id="L1119" class="LineNr">1119 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4c"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L14'>ESP</a> (dec)"</span><span class="Delimiter">);</span> +<span id="L1120" class="LineNr">1120 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4d"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L15'>EBP</a> (dec)"</span><span class="Delimiter">);</span> +<span id="L1121" class="LineNr">1121 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4e"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L16'>ESI</a> (dec)"</span><span class="Delimiter">);</span> +<span id="L1122" class="LineNr">1122 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"4f"</span><span class="Delimiter">,</span> <span class="Constant">"decrement <a href='010---vm.cc.html#L17'>EDI</a> (dec)"</span><span class="Delimiter">);</span> <span id="L1123" class="LineNr">1123 </span> <span id="L1124" class="LineNr">1124 </span><span class="Delimiter">:(code)</span> <span id="L1125" class="LineNr">1125 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L1125'>test_decrement_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1126" class="LineNr">1126 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u = <span class="Constant">0x1f</span><span class="Delimiter">;</span> -<span id="L1127" class="LineNr">1127 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1126" class="LineNr">1126 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u = <span class="Constant">0x1f</span><span class="Delimiter">;</span> +<span id="L1127" class="LineNr">1127 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1128" class="LineNr">1128 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L1129" class="LineNr">1129 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1130" class="LineNr">1130 </span> <span class="Constant">" 49 \n"</span> <span class="Comment">// decrement ECX</span> @@ -1205,17 +1205,17 @@ if ('onhashchange' in window) { <span id="L1144" class="LineNr">1144 </span><span class="Normal">case</span> <span class="Constant">0x4d</span>: <span id="L1145" class="LineNr">1145 </span><span class="Normal">case</span> <span class="Constant">0x4e</span>: <span id="L1146" class="LineNr">1146 </span><span class="Normal">case</span> <span class="Constant">0x4f</span>: <span class="Delimiter">{</span> <span class="Comment">// decrement r32</span> -<span id="L1147" class="LineNr">1147 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L26'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> -<span id="L1148" class="LineNr">1148 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"decrement "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L26'>reg</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L1149" class="LineNr">1149 </span> --<span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L1150" class="LineNr">1150 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing value 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L1147" class="LineNr">1147 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L20'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> +<span id="L1148" class="LineNr">1148 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"decrement "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L20'>reg</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L1149" class="LineNr">1149 </span> --<span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L1150" class="LineNr">1150 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing value 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> <span id="L1151" class="LineNr">1151 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1152" class="LineNr">1152 </span><span class="Delimiter">}</span> <span id="L1153" class="LineNr">1153 </span> <span id="L1154" class="LineNr">1154 </span><span class="Delimiter">:(code)</span> <span id="L1155" class="LineNr">1155 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L1155'>test_decrement_rm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1156" class="LineNr">1156 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x20</span><span class="Delimiter">;</span> -<span id="L1157" class="LineNr">1157 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1156" class="LineNr">1156 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x20</span><span class="Delimiter">;</span> +<span id="L1157" class="LineNr">1157 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1158" class="LineNr">1158 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L1159" class="LineNr">1159 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1160" class="LineNr">1160 </span> <span class="Constant">" ff c8 \n"</span> <span class="Comment">// decrement EAX</span> @@ -1233,35 +1233,35 @@ if ('onhashchange' in window) { <span id="L1172" class="LineNr">1172 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"decrement r/m32"</span> << end<span class="Delimiter">();</span> <span id="L1173" class="LineNr">1173 </span> <span class="Normal">int32_t</span>* <a href='001help.cc.html#L15'>arg</a> = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> <span id="L1174" class="LineNr">1174 </span> --*arg<span class="Delimiter">;</span> -<span id="L1175" class="LineNr">1175 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing value 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg << end<span class="Delimiter">();</span> +<span id="L1175" class="LineNr">1175 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing value 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg << end<span class="Delimiter">();</span> <span id="L1176" class="LineNr">1176 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1177" class="LineNr">1177 </span><span class="Delimiter">}</span> <span id="L1178" class="LineNr">1178 </span> <span id="L1179" class="LineNr">1179 </span><span class="SalientComment">//:: push</span> <span id="L1180" class="LineNr">1180 </span> <span id="L1181" class="LineNr">1181 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L1182" class="LineNr">1182 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"50"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L16'>EAX</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> -<span id="L1183" class="LineNr">1183 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"51"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L17'>ECX</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> -<span id="L1184" class="LineNr">1184 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"52"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L18'>EDX</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> -<span id="L1185" class="LineNr">1185 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"53"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L19'>EBX</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> -<span id="L1186" class="LineNr">1186 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"54"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L20'>ESP</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> -<span id="L1187" class="LineNr">1187 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"55"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L21'>EBP</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> -<span id="L1188" class="LineNr">1188 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"56"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L22'>ESI</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> -<span id="L1189" class="LineNr">1189 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"57"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L23'>EDI</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> +<span id="L1182" class="LineNr">1182 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"50"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L10'>EAX</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> +<span id="L1183" class="LineNr">1183 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"51"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L11'>ECX</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> +<span id="L1184" class="LineNr">1184 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"52"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L12'>EDX</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> +<span id="L1185" class="LineNr">1185 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"53"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L13'>EBX</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> +<span id="L1186" class="LineNr">1186 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"54"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L14'>ESP</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> +<span id="L1187" class="LineNr">1187 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"55"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L15'>EBP</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> +<span id="L1188" class="LineNr">1188 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"56"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L16'>ESI</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> +<span id="L1189" class="LineNr">1189 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"57"</span><span class="Delimiter">,</span> <span class="Constant">"push <a href='010---vm.cc.html#L17'>EDI</a> to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> <span id="L1190" class="LineNr">1190 </span> <span id="L1191" class="LineNr">1191 </span><span class="Delimiter">:(code)</span> <span id="L1192" class="LineNr">1192 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L1192'>test_push_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1193" class="LineNr">1193 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> -<span id="L1194" class="LineNr">1194 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000008</span><span class="Delimiter">;</span> -<span id="L1195" class="LineNr">1195 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0000000a</span><span class="Delimiter">;</span> -<span id="L1196" class="LineNr">1196 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1193" class="LineNr">1193 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> +<span id="L1194" class="LineNr">1194 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000008</span><span class="Delimiter">;</span> +<span id="L1195" class="LineNr">1195 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0000000a</span><span class="Delimiter">;</span> +<span id="L1196" class="LineNr">1196 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1197" class="LineNr">1197 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L1198" class="LineNr">1198 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1199" class="LineNr">1199 </span> <span class="Constant">" 53 \n"</span> <span class="Comment">// push EBX to stack</span> <span id="L1200" class="LineNr">1200 </span> <span class="Delimiter">);</span> <span id="L1201" class="LineNr">1201 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L1202" class="LineNr">1202 </span> <span class="Constant">"run: <a href='012elf.cc.html#L94'>push</a> EBX\n"</span> -<span id="L1203" class="LineNr">1203 </span> <span class="Constant">"run: decrementing <a href='010---vm.cc.html#L20'>ESP</a> to 0xbd000004\n"</span> +<span id="L1203" class="LineNr">1203 </span> <span class="Constant">"run: decrementing <a href='010---vm.cc.html#L14'>ESP</a> to 0xbd000004\n"</span> <span id="L1204" class="LineNr">1204 </span> <span class="Constant">"run: pushing value 0x0000000a\n"</span> <span id="L1205" class="LineNr">1205 </span> <span class="Delimiter">);</span> <span id="L1206" class="LineNr">1206 </span><span class="Delimiter">}</span> @@ -1275,31 +1275,31 @@ if ('onhashchange' in window) { <span id="L1214" class="LineNr">1214 </span><span class="Normal">case</span> <span class="Constant">0x55</span>: <span id="L1215" class="LineNr">1215 </span><span class="Normal">case</span> <span class="Constant">0x56</span>: <span id="L1216" class="LineNr">1216 </span><span class="Normal">case</span> <span class="Constant">0x57</span>: <span class="Delimiter">{</span> <span class="Comment">// push r32 to stack</span> -<span id="L1217" class="LineNr">1217 </span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L26'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> -<span id="L1218" class="LineNr">1218 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"push "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L26'>reg</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L1217" class="LineNr">1217 </span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L20'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> +<span id="L1218" class="LineNr">1218 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"push "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L20'>reg</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L1219" class="LineNr">1219 </span><span class="CommentedCode">//? cerr << "push: " << NUM(reg) << ": " << Reg[reg].u << " => " << Reg[ESP].u << '\n';</span> -<span id="L1220" class="LineNr">1220 </span> <a href='012elf.cc.html#L94'>push</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> +<span id="L1220" class="LineNr">1220 </span> <a href='012elf.cc.html#L94'>push</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> <span id="L1221" class="LineNr">1221 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1222" class="LineNr">1222 </span><span class="Delimiter">}</span> <span id="L1223" class="LineNr">1223 </span> <span id="L1224" class="LineNr">1224 </span><span class="SalientComment">//:: pop</span> <span id="L1225" class="LineNr">1225 </span> <span id="L1226" class="LineNr">1226 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L1227" class="LineNr">1227 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"58"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L16'>EAX</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> -<span id="L1228" class="LineNr">1228 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"59"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L17'>ECX</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> -<span id="L1229" class="LineNr">1229 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5a"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L18'>EDX</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> -<span id="L1230" class="LineNr">1230 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5b"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L19'>EBX</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> -<span id="L1231" class="LineNr">1231 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5c"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L20'>ESP</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> -<span id="L1232" class="LineNr">1232 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5d"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L21'>EBP</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> -<span id="L1233" class="LineNr">1233 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5e"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L22'>ESI</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> -<span id="L1234" class="LineNr">1234 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5f"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L23'>EDI</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> +<span id="L1227" class="LineNr">1227 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"58"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L10'>EAX</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> +<span id="L1228" class="LineNr">1228 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"59"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L11'>ECX</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> +<span id="L1229" class="LineNr">1229 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5a"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L12'>EDX</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> +<span id="L1230" class="LineNr">1230 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5b"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L13'>EBX</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> +<span id="L1231" class="LineNr">1231 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5c"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L14'>ESP</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> +<span id="L1232" class="LineNr">1232 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5d"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L15'>EBP</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> +<span id="L1233" class="LineNr">1233 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5e"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L16'>ESI</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> +<span id="L1234" class="LineNr">1234 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"5f"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to <a href='010---vm.cc.html#L17'>EDI</a> (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> <span id="L1235" class="LineNr">1235 </span> <span id="L1236" class="LineNr">1236 </span><span class="Delimiter">:(code)</span> <span id="L1237" class="LineNr">1237 </span><span class="Normal">void</span> <a href='013direct_addressing.cc.html#L1237'>test_pop_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1238" class="LineNr">1238 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> -<span id="L1239" class="LineNr">1239 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000008</span><span class="Delimiter">;</span> -<span id="L1240" class="LineNr">1240 </span> <a href='010---vm.cc.html#L249'>write_mem_i32</a><span class="Delimiter">(</span><span class="Constant">0xbd000008</span><span class="Delimiter">,</span> <span class="Constant">0x0000000a</span><span class="Delimiter">);</span> <span class="Comment">// ..before this write</span> -<span id="L1241" class="LineNr">1241 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1238" class="LineNr">1238 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> +<span id="L1239" class="LineNr">1239 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000008</span><span class="Delimiter">;</span> +<span id="L1240" class="LineNr">1240 </span> <a href='010---vm.cc.html#L243'>write_mem_i32</a><span class="Delimiter">(</span><span class="Constant">0xbd000008</span><span class="Delimiter">,</span> <span class="Constant">0x0000000a</span><span class="Delimiter">);</span> <span class="Comment">// ..before this write</span> +<span id="L1241" class="LineNr">1241 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1242" class="LineNr">1242 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> <span id="L1243" class="LineNr">1243 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1244" class="LineNr">1244 </span> <span class="Constant">" 5b \n"</span> <span class="Comment">// pop stack to EBX</span> @@ -1309,7 +1309,7 @@ if ('onhashchange' in window) { <span id="L1248" class="LineNr">1248 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L1249" class="LineNr">1249 </span> <span class="Constant">"run: <a href='013direct_addressing.cc.html#L1272'>pop</a> into EBX\n"</span> <span id="L1250" class="LineNr">1250 </span> <span class="Constant">"run: popping value 0x0000000a\n"</span> -<span id="L1251" class="LineNr">1251 </span> <span class="Constant">"run: incrementing <a href='010---vm.cc.html#L20'>ESP</a> to 0xbd00000c\n"</span> +<span id="L1251" class="LineNr">1251 </span> <span class="Constant">"run: incrementing <a href='010---vm.cc.html#L14'>ESP</a> to 0xbd00000c\n"</span> <span id="L1252" class="LineNr">1252 </span> <span class="Delimiter">);</span> <span id="L1253" class="LineNr">1253 </span><span class="Delimiter">}</span> <span id="L1254" class="LineNr">1254 </span> @@ -1322,20 +1322,20 @@ if ('onhashchange' in window) { <span id="L1261" class="LineNr">1261 </span><span class="Normal">case</span> <span class="Constant">0x5d</span>: <span id="L1262" class="LineNr">1262 </span><span class="Normal">case</span> <span class="Constant">0x5e</span>: <span id="L1263" class="LineNr">1263 </span><span class="Normal">case</span> <span class="Constant">0x5f</span>: <span class="Delimiter">{</span> <span class="Comment">// pop stack into r32</span> -<span id="L1264" class="LineNr">1264 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L26'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> -<span id="L1265" class="LineNr">1265 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pop into "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L26'>reg</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L1264" class="LineNr">1264 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> <a href='010---vm.cc.html#L20'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> +<span id="L1265" class="LineNr">1265 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pop into "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L20'>reg</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L1266" class="LineNr">1266 </span><span class="CommentedCode">//? cerr << "pop from " << Reg[ESP].u << '\n';</span> -<span id="L1267" class="LineNr">1267 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg]<span class="Delimiter">.</span>u = <a href='013direct_addressing.cc.html#L1272'>pop</a><span class="Delimiter">();</span> +<span id="L1267" class="LineNr">1267 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg]<span class="Delimiter">.</span>u = <a href='013direct_addressing.cc.html#L1272'>pop</a><span class="Delimiter">();</span> <span id="L1268" class="LineNr">1268 </span><span class="CommentedCode">//? cerr << "=> " << NUM(reg) << ": " << Reg[reg].u << '\n';</span> <span id="L1269" class="LineNr">1269 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1270" class="LineNr">1270 </span><span class="Delimiter">}</span> <span id="L1271" class="LineNr">1271 </span><span class="Delimiter">:(code)</span> <span id="L1272" class="LineNr">1272 </span><span class="Normal">uint32_t</span> <a href='013direct_addressing.cc.html#L1272'>pop</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1273" class="LineNr">1273 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> result = <a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> -<span id="L1274" class="LineNr">1274 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"popping value 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << result << end<span class="Delimiter">();</span> -<span id="L1275" class="LineNr">1275 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u += <span class="Constant">4</span><span class="Delimiter">;</span> -<span id="L1276" class="LineNr">1276 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"incrementing <a href='010---vm.cc.html#L20'>ESP</a> to 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> -<span id="L1277" class="LineNr">1277 </span> assert<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u < <a href='012elf.cc.html#L153'>AFTER_STACK</a><span class="Delimiter">);</span> +<span id="L1273" class="LineNr">1273 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> result = <a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> +<span id="L1274" class="LineNr">1274 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"popping value 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << result << end<span class="Delimiter">();</span> +<span id="L1275" class="LineNr">1275 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u += <span class="Constant">4</span><span class="Delimiter">;</span> +<span id="L1276" class="LineNr">1276 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"incrementing <a href='010---vm.cc.html#L14'>ESP</a> to 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L1277" class="LineNr">1277 </span> assert<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u < <a href='012elf.cc.html#L153'>AFTER_STACK</a><span class="Delimiter">);</span> <span id="L1278" class="LineNr">1278 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span id="L1279" class="LineNr">1279 </span><span class="Delimiter">}</span> </pre> diff --git a/html/014indirect_addressing.cc.html b/html/014indirect_addressing.cc.html index a25191d9..e70b8317 100644 --- a/html/014indirect_addressing.cc.html +++ b/html/014indirect_addressing.cc.html @@ -61,9 +61,9 @@ if ('onhashchange' in window) { <span id="L2" class="LineNr"> 2 </span><span class="Comment">//: we'll now start providing data in a separate segment</span> <span id="L3" class="LineNr"> 3 </span> <span id="L4" class="LineNr"> 4 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L4'>test_add_r32_to_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L5" class="LineNr"> 5 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> -<span id="L6" class="LineNr"> 6 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L7" class="LineNr"> 7 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L5" class="LineNr"> 5 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> +<span id="L6" class="LineNr"> 6 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L7" class="LineNr"> 7 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L8" class="LineNr"> 8 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L9" class="LineNr"> 9 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L10" class="LineNr"> 10 </span> <span class="Constant">" 01 18 \n"</span> <span class="Comment">// add EBX to *EAX</span> @@ -72,8 +72,8 @@ if ('onhashchange' in window) { <span id="L13" class="LineNr"> 13 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L14" class="LineNr"> 14 </span> <span class="Delimiter">);</span> <span id="L15" class="LineNr"> 15 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L16" class="LineNr"> 16 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L17" class="LineNr"> 17 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L16" class="LineNr"> 16 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L17" class="LineNr"> 17 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L18" class="LineNr"> 18 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L19" class="LineNr"> 19 </span> <span class="Delimiter">);</span> <span id="L20" class="LineNr"> 20 </span><span class="Delimiter">}</span> @@ -82,8 +82,8 @@ if ('onhashchange' in window) { <span id="L23" class="LineNr"> 23 </span><span class="Normal">case</span> <span class="Constant">0</span>: <span class="Comment">// indirect addressing</span> <span id="L24" class="LineNr"> 24 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>rm<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L25" class="LineNr"> 25 </span> <span class="Normal">default</span>: <span class="Comment">// address in register</span> -<span id="L26" class="LineNr"> 26 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[rm]<span class="Delimiter">.</span>u << <span class="Constant">" ("</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rm<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> -<span id="L27" class="LineNr"> 27 </span> addr = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[rm]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L26" class="LineNr"> 26 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[rm]<span class="Delimiter">.</span>u << <span class="Constant">" ("</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rm<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> +<span id="L27" class="LineNr"> 27 </span> addr = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[rm]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> <span id="L28" class="LineNr"> 28 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L29" class="LineNr"> 29 </span> <span class="Comment">// End Mod 0 Special-cases(addr)</span> <span id="L30" class="LineNr"> 30 </span> <span class="Delimiter">}</span> @@ -92,13 +92,13 @@ if ('onhashchange' in window) { <span id="L33" class="LineNr"> 33 </span><span class="Comment">//:</span> <span id="L34" class="LineNr"> 34 </span> <span id="L35" class="LineNr"> 35 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L36" class="LineNr"> 36 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"03"</span><span class="Delimiter">,</span> <span class="Constant">"add rm32 to r32 (add)"</span><span class="Delimiter">);</span> +<span id="L36" class="LineNr"> 36 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"03"</span><span class="Delimiter">,</span> <span class="Constant">"add rm32 to r32 (add)"</span><span class="Delimiter">);</span> <span id="L37" class="LineNr"> 37 </span> <span id="L38" class="LineNr"> 38 </span><span class="Delimiter">:(code)</span> <span id="L39" class="LineNr"> 39 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L39'>test_add_mem_at_r32_to_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L40" class="LineNr"> 40 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L41" class="LineNr"> 41 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> -<span id="L42" class="LineNr"> 42 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L40" class="LineNr"> 40 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L41" class="LineNr"> 41 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> +<span id="L42" class="LineNr"> 42 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L43" class="LineNr"> 43 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L44" class="LineNr"> 44 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L45" class="LineNr"> 45 </span> <span class="Constant">" 03 18 \n"</span> <span class="Comment">// add *EAX to EBX</span> @@ -108,38 +108,38 @@ if ('onhashchange' in window) { <span id="L49" class="LineNr"> 49 </span> <span class="Delimiter">);</span> <span id="L50" class="LineNr"> 50 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L51" class="LineNr"> 51 </span> <span class="Constant">"run: add r/m32 to EBX\n"</span> -<span id="L52" class="LineNr"> 52 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L52" class="LineNr"> 52 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L53" class="LineNr"> 53 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L54" class="LineNr"> 54 </span> <span class="Delimiter">);</span> <span id="L55" class="LineNr"> 55 </span><span class="Delimiter">}</span> <span id="L56" class="LineNr"> 56 </span> <span id="L57" class="LineNr"> 57 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L58" class="LineNr"> 58 </span><span class="Normal">case</span> <span class="Constant">0x03</span>: <span class="Delimiter">{</span> <span class="Comment">// add r/m32 to r32</span> -<span id="L59" class="LineNr"> 59 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L60" class="LineNr"> 60 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg1 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L61" class="LineNr"> 61 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"add r/m32 to "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg1<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L62" class="LineNr"> 62 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* signed_arg2 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L63" class="LineNr"> 63 </span> <span class="Normal">int32_t</span> signed_result = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i + *signed_arg2<span class="Delimiter">;</span> +<span id="L63" class="LineNr"> 63 </span> <span class="Normal">int32_t</span> signed_result = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i + *signed_arg2<span class="Delimiter">;</span> <span id="L64" class="LineNr"> 64 </span> SF = <span class="Delimiter">(</span>signed_result < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L65" class="LineNr"> 65 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L66" class="LineNr"> 66 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> + *signed_arg2<span class="Delimiter">;</span> -<span id="L67" class="LineNr"> 67 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> +<span id="L65" class="LineNr"> 65 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L66" class="LineNr"> 66 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> + *signed_arg2<span class="Delimiter">;</span> +<span id="L67" class="LineNr"> 67 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> <span id="L68" class="LineNr"> 68 </span> <span class="Comment">// set CF</span> <span id="L69" class="LineNr"> 69 </span> <span class="Normal">uint32_t</span> unsigned_arg2 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*signed_arg2<span class="Delimiter">);</span> -<span id="L70" class="LineNr"> 70 </span> <span class="Normal">uint32_t</span> unsigned_result = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>u + unsigned_arg2<span class="Delimiter">;</span> -<span id="L71" class="LineNr"> 71 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> + unsigned_arg2<span class="Delimiter">;</span> -<span id="L72" class="LineNr"> 72 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> -<span id="L73" class="LineNr"> 73 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> -<span id="L74" class="LineNr"> 74 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i = signed_result<span class="Delimiter">;</span> -<span id="L75" class="LineNr"> 75 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L70" class="LineNr"> 70 </span> <span class="Normal">uint32_t</span> unsigned_result = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>u + unsigned_arg2<span class="Delimiter">;</span> +<span id="L71" class="LineNr"> 71 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> + unsigned_arg2<span class="Delimiter">;</span> +<span id="L72" class="LineNr"> 72 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> +<span id="L73" class="LineNr"> 73 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> +<span id="L74" class="LineNr"> 74 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i = signed_result<span class="Delimiter">;</span> +<span id="L75" class="LineNr"> 75 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> <span id="L76" class="LineNr"> 76 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L77" class="LineNr"> 77 </span><span class="Delimiter">}</span> <span id="L78" class="LineNr"> 78 </span> <span id="L79" class="LineNr"> 79 </span><span class="Delimiter">:(code)</span> <span id="L80" class="LineNr"> 80 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L80'>test_add_mem_at_r32_to_r32_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L81" class="LineNr"> 81 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L82" class="LineNr"> 82 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> -<span id="L83" class="LineNr"> 83 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L81" class="LineNr"> 81 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L82" class="LineNr"> 82 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> +<span id="L83" class="LineNr"> 83 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L84" class="LineNr"> 84 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L85" class="LineNr"> 85 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L86" class="LineNr"> 86 </span> <span class="Constant">" 03 18 \n"</span> <span class="Comment">// add *EAX to EBX</span> @@ -149,17 +149,17 @@ if ('onhashchange' in window) { <span id="L90" class="LineNr"> 90 </span> <span class="Delimiter">);</span> <span id="L91" class="LineNr"> 91 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L92" class="LineNr"> 92 </span> <span class="Constant">"run: add r/m32 to EBX\n"</span> -<span id="L93" class="LineNr"> 93 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L94" class="LineNr"> 94 </span> <span class="Constant">"run: effective address contains 1\n"</span> +<span id="L93" class="LineNr"> 93 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L94" class="LineNr"> 94 </span> <span class="Constant">"run: effective address contains 0x00000001\n"</span> <span id="L95" class="LineNr"> 95 </span> <span class="Constant">"run: SF=1; ZF=0; CF=0; OF=1\n"</span> <span id="L96" class="LineNr"> 96 </span> <span class="Constant">"run: storing 0x80000000\n"</span> <span id="L97" class="LineNr"> 97 </span> <span class="Delimiter">);</span> <span id="L98" class="LineNr"> 98 </span><span class="Delimiter">}</span> <span id="L99" class="LineNr"> 99 </span> <span id="L100" class="LineNr"> 100 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L100'>test_add_mem_at_r32_to_r32_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L101" class="LineNr"> 101 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L102" class="LineNr"> 102 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest unsigned number</span> -<span id="L103" class="LineNr"> 103 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L101" class="LineNr"> 101 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L102" class="LineNr"> 102 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest unsigned number</span> +<span id="L103" class="LineNr"> 103 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L104" class="LineNr"> 104 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L105" class="LineNr"> 105 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L106" class="LineNr"> 106 </span> <span class="Constant">" 03 18 \n"</span> <span class="Comment">// add *EAX to EBX</span> @@ -169,17 +169,17 @@ if ('onhashchange' in window) { <span id="L110" class="LineNr"> 110 </span> <span class="Delimiter">);</span> <span id="L111" class="LineNr"> 111 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L112" class="LineNr"> 112 </span> <span class="Constant">"run: add r/m32 to EBX\n"</span> -<span id="L113" class="LineNr"> 113 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L114" class="LineNr"> 114 </span> <span class="Constant">"run: effective address contains 1\n"</span> +<span id="L113" class="LineNr"> 113 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L114" class="LineNr"> 114 </span> <span class="Constant">"run: effective address contains 0x00000001\n"</span> <span id="L115" class="LineNr"> 115 </span> <span class="Constant">"run: SF=0; ZF=1; CF=1; OF=0\n"</span> <span id="L116" class="LineNr"> 116 </span> <span class="Constant">"run: storing 0x00000000\n"</span> <span id="L117" class="LineNr"> 117 </span> <span class="Delimiter">);</span> <span id="L118" class="LineNr"> 118 </span><span class="Delimiter">}</span> <span id="L119" class="LineNr"> 119 </span> <span id="L120" class="LineNr"> 120 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L120'>test_add_mem_at_r32_to_r32_unsigned_and_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L121" class="LineNr"> 121 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L122" class="LineNr"> 122 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> -<span id="L123" class="LineNr"> 123 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L121" class="LineNr"> 121 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L122" class="LineNr"> 122 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> +<span id="L123" class="LineNr"> 123 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L124" class="LineNr"> 124 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L125" class="LineNr"> 125 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L126" class="LineNr"> 126 </span> <span class="Constant">" 03 18 \n"</span> <span class="Comment">// add *EAX to EBX</span> @@ -189,8 +189,8 @@ if ('onhashchange' in window) { <span id="L130" class="LineNr"> 130 </span> <span class="Delimiter">);</span> <span id="L131" class="LineNr"> 131 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L132" class="LineNr"> 132 </span> <span class="Constant">"run: add r/m32 to EBX\n"</span> -<span id="L133" class="LineNr"> 133 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L134" class="LineNr"> 134 </span> <span class="Constant">"run: effective address contains 80000000\n"</span> +<span id="L133" class="LineNr"> 133 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L134" class="LineNr"> 134 </span> <span class="Constant">"run: effective address contains 0x80000000\n"</span> <span id="L135" class="LineNr"> 135 </span> <span class="Constant">"run: SF=0; ZF=1; CF=1; OF=1\n"</span> <span id="L136" class="LineNr"> 136 </span> <span class="Constant">"run: storing 0x00000000\n"</span> <span id="L137" class="LineNr"> 137 </span> <span class="Delimiter">);</span> @@ -200,9 +200,9 @@ if ('onhashchange' in window) { <span id="L141" class="LineNr"> 141 </span> <span id="L142" class="LineNr"> 142 </span><span class="Delimiter">:(code)</span> <span id="L143" class="LineNr"> 143 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L143'>test_subtract_r32_from_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L144" class="LineNr"> 144 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L145" class="LineNr"> 145 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L146" class="LineNr"> 146 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L144" class="LineNr"> 144 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L145" class="LineNr"> 145 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L146" class="LineNr"> 146 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L147" class="LineNr"> 147 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L148" class="LineNr"> 148 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L149" class="LineNr"> 149 </span> <span class="Constant">" 29 18 \n"</span> <span class="Comment">// subtract EBX from *EAX</span> @@ -211,8 +211,8 @@ if ('onhashchange' in window) { <span id="L152" class="LineNr"> 152 </span> <span class="Constant">"0a 00 00 00\n"</span> <span class="Comment">// 0x0000000a</span> <span id="L153" class="LineNr"> 153 </span> <span class="Delimiter">);</span> <span id="L154" class="LineNr"> 154 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L155" class="LineNr"> 155 </span> <span class="Constant">"run: subtract <a href='010---vm.cc.html#L19'>EBX</a> from r/m32\n"</span> -<span id="L156" class="LineNr"> 156 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L155" class="LineNr"> 155 </span> <span class="Constant">"run: subtract <a href='010---vm.cc.html#L13'>EBX</a> from r/m32\n"</span> +<span id="L156" class="LineNr"> 156 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L157" class="LineNr"> 157 </span> <span class="Constant">"run: storing 0x00000009\n"</span> <span id="L158" class="LineNr"> 158 </span> <span class="Delimiter">);</span> <span id="L159" class="LineNr"> 159 </span><span class="Delimiter">}</span> @@ -220,13 +220,13 @@ if ('onhashchange' in window) { <span id="L161" class="LineNr"> 161 </span><span class="Comment">//:</span> <span id="L162" class="LineNr"> 162 </span> <span id="L163" class="LineNr"> 163 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L164" class="LineNr"> 164 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"2b"</span><span class="Delimiter">,</span> <span class="Constant">"subtract rm32 from r32 (sub)"</span><span class="Delimiter">);</span> +<span id="L164" class="LineNr"> 164 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"2b"</span><span class="Delimiter">,</span> <span class="Constant">"subtract rm32 from r32 (sub)"</span><span class="Delimiter">);</span> <span id="L165" class="LineNr"> 165 </span> <span id="L166" class="LineNr"> 166 </span><span class="Delimiter">:(code)</span> <span id="L167" class="LineNr"> 167 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L167'>test_subtract_mem_at_r32_from_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L168" class="LineNr"> 168 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L169" class="LineNr"> 169 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">10</span><span class="Delimiter">;</span> -<span id="L170" class="LineNr"> 170 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L168" class="LineNr"> 168 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L169" class="LineNr"> 169 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">10</span><span class="Delimiter">;</span> +<span id="L170" class="LineNr"> 170 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L171" class="LineNr"> 171 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L172" class="LineNr"> 172 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L173" class="LineNr"> 173 </span> <span class="Constant">" 2b 18 \n"</span> <span class="Comment">// subtract *EAX from EBX</span> @@ -236,38 +236,38 @@ if ('onhashchange' in window) { <span id="L177" class="LineNr"> 177 </span> <span class="Delimiter">);</span> <span id="L178" class="LineNr"> 178 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L179" class="LineNr"> 179 </span> <span class="Constant">"run: subtract r/m32 from EBX\n"</span> -<span id="L180" class="LineNr"> 180 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L180" class="LineNr"> 180 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L181" class="LineNr"> 181 </span> <span class="Constant">"run: storing 0x00000009\n"</span> <span id="L182" class="LineNr"> 182 </span> <span class="Delimiter">);</span> <span id="L183" class="LineNr"> 183 </span><span class="Delimiter">}</span> <span id="L184" class="LineNr"> 184 </span> <span id="L185" class="LineNr"> 185 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L186" class="LineNr"> 186 </span><span class="Normal">case</span> <span class="Constant">0x2b</span>: <span class="Delimiter">{</span> <span class="Comment">// subtract r/m32 from r32</span> -<span id="L187" class="LineNr"> 187 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L187" class="LineNr"> 187 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L188" class="LineNr"> 188 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg1 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L189" class="LineNr"> 189 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subtract r/m32 from "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg1<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L190" class="LineNr"> 190 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* signed_arg2 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L191" class="LineNr"> 191 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_result = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i - *signed_arg2<span class="Delimiter">;</span> +<span id="L191" class="LineNr"> 191 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_result = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i - *signed_arg2<span class="Delimiter">;</span> <span id="L192" class="LineNr"> 192 </span> SF = <span class="Delimiter">(</span>signed_result < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L193" class="LineNr"> 193 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L194" class="LineNr"> 194 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> - *signed_arg2<span class="Delimiter">;</span> -<span id="L195" class="LineNr"> 195 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> +<span id="L193" class="LineNr"> 193 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L194" class="LineNr"> 194 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> - *signed_arg2<span class="Delimiter">;</span> +<span id="L195" class="LineNr"> 195 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> <span id="L196" class="LineNr"> 196 </span> <span class="Comment">// set CF</span> <span id="L197" class="LineNr"> 197 </span> <span class="Normal">uint32_t</span> unsigned_arg2 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*signed_arg2<span class="Delimiter">);</span> -<span id="L198" class="LineNr"> 198 </span> <span class="Normal">uint32_t</span> unsigned_result = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>u - unsigned_arg2<span class="Delimiter">;</span> -<span id="L199" class="LineNr"> 199 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> - unsigned_arg2<span class="Delimiter">;</span> -<span id="L200" class="LineNr"> 200 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> -<span id="L201" class="LineNr"> 201 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> -<span id="L202" class="LineNr"> 202 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i = signed_result<span class="Delimiter">;</span> -<span id="L203" class="LineNr"> 203 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L198" class="LineNr"> 198 </span> <span class="Normal">uint32_t</span> unsigned_result = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>u - unsigned_arg2<span class="Delimiter">;</span> +<span id="L199" class="LineNr"> 199 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> - unsigned_arg2<span class="Delimiter">;</span> +<span id="L200" class="LineNr"> 200 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> +<span id="L201" class="LineNr"> 201 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> +<span id="L202" class="LineNr"> 202 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i = signed_result<span class="Delimiter">;</span> +<span id="L203" class="LineNr"> 203 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> <span id="L204" class="LineNr"> 204 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L205" class="LineNr"> 205 </span><span class="Delimiter">}</span> <span id="L206" class="LineNr"> 206 </span> <span id="L207" class="LineNr"> 207 </span><span class="Delimiter">:(code)</span> <span id="L208" class="LineNr"> 208 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L208'>test_subtract_mem_at_r32_from_r32_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L209" class="LineNr"> 209 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L210" class="LineNr"> 210 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> -<span id="L211" class="LineNr"> 211 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L209" class="LineNr"> 209 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L210" class="LineNr"> 210 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> +<span id="L211" class="LineNr"> 211 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L212" class="LineNr"> 212 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L213" class="LineNr"> 213 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L214" class="LineNr"> 214 </span> <span class="Constant">" 2b 18 \n"</span> <span class="Comment">// subtract *EAX from EBX</span> @@ -277,17 +277,17 @@ if ('onhashchange' in window) { <span id="L218" class="LineNr"> 218 </span> <span class="Delimiter">);</span> <span id="L219" class="LineNr"> 219 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L220" class="LineNr"> 220 </span> <span class="Constant">"run: subtract r/m32 from EBX\n"</span> -<span id="L221" class="LineNr"> 221 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L222" class="LineNr"> 222 </span> <span class="Constant">"run: effective address contains 7fffffff\n"</span> +<span id="L221" class="LineNr"> 221 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L222" class="LineNr"> 222 </span> <span class="Constant">"run: effective address contains 0x7fffffff\n"</span> <span id="L223" class="LineNr"> 223 </span> <span class="Constant">"run: SF=0; ZF=0; CF=0; OF=1\n"</span> <span id="L224" class="LineNr"> 224 </span> <span class="Constant">"run: storing 0x00000001\n"</span> <span id="L225" class="LineNr"> 225 </span> <span class="Delimiter">);</span> <span id="L226" class="LineNr"> 226 </span><span class="Delimiter">}</span> <span id="L227" class="LineNr"> 227 </span> <span id="L228" class="LineNr"> 228 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L228'>test_subtract_mem_at_r32_from_r32_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L229" class="LineNr"> 229 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L230" class="LineNr"> 230 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L231" class="LineNr"> 231 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L229" class="LineNr"> 229 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L230" class="LineNr"> 230 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L231" class="LineNr"> 231 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L232" class="LineNr"> 232 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L233" class="LineNr"> 233 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L234" class="LineNr"> 234 </span> <span class="Constant">" 2b 18 \n"</span> <span class="Comment">// subtract *EAX from EBX</span> @@ -297,17 +297,17 @@ if ('onhashchange' in window) { <span id="L238" class="LineNr"> 238 </span> <span class="Delimiter">);</span> <span id="L239" class="LineNr"> 239 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L240" class="LineNr"> 240 </span> <span class="Constant">"run: subtract r/m32 from EBX\n"</span> -<span id="L241" class="LineNr"> 241 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L242" class="LineNr"> 242 </span> <span class="Constant">"run: effective address contains 1\n"</span> +<span id="L241" class="LineNr"> 241 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L242" class="LineNr"> 242 </span> <span class="Constant">"run: effective address contains 0x00000001\n"</span> <span id="L243" class="LineNr"> 243 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=0\n"</span> <span id="L244" class="LineNr"> 244 </span> <span class="Constant">"run: storing 0xffffffff\n"</span> <span id="L245" class="LineNr"> 245 </span> <span class="Delimiter">);</span> <span id="L246" class="LineNr"> 246 </span><span class="Delimiter">}</span> <span id="L247" class="LineNr"> 247 </span> <span id="L248" class="LineNr"> 248 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L248'>test_subtract_mem_at_r32_from_r32_signed_and_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L249" class="LineNr"> 249 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L250" class="LineNr"> 250 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L251" class="LineNr"> 251 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L249" class="LineNr"> 249 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L250" class="LineNr"> 250 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L251" class="LineNr"> 251 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L252" class="LineNr"> 252 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L253" class="LineNr"> 253 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L254" class="LineNr"> 254 </span> <span class="Constant">" 2b 18 \n"</span> <span class="Comment">// subtract *EAX from EBX</span> @@ -317,8 +317,8 @@ if ('onhashchange' in window) { <span id="L258" class="LineNr"> 258 </span> <span class="Delimiter">);</span> <span id="L259" class="LineNr"> 259 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L260" class="LineNr"> 260 </span> <span class="Constant">"run: subtract r/m32 from EBX\n"</span> -<span id="L261" class="LineNr"> 261 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L262" class="LineNr"> 262 </span> <span class="Constant">"run: effective address contains 80000000\n"</span> +<span id="L261" class="LineNr"> 261 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L262" class="LineNr"> 262 </span> <span class="Constant">"run: effective address contains 0x80000000\n"</span> <span id="L263" class="LineNr"> 263 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=1\n"</span> <span id="L264" class="LineNr"> 264 </span> <span class="Constant">"run: storing 0x80000000\n"</span> <span id="L265" class="LineNr"> 265 </span> <span class="Delimiter">);</span> @@ -327,9 +327,9 @@ if ('onhashchange' in window) { <span id="L268" class="LineNr"> 268 </span><span class="SalientComment">//:: and</span> <span id="L269" class="LineNr"> 269 </span><span class="Delimiter">:(code)</span> <span id="L270" class="LineNr"> 270 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L270'>test_and_r32_with_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L271" class="LineNr"> 271 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L272" class="LineNr"> 272 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xff</span><span class="Delimiter">;</span> -<span id="L273" class="LineNr"> 273 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L271" class="LineNr"> 271 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L272" class="LineNr"> 272 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xff</span><span class="Delimiter">;</span> +<span id="L273" class="LineNr"> 273 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L274" class="LineNr"> 274 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L275" class="LineNr"> 275 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L276" class="LineNr"> 276 </span> <span class="Constant">" 21 18 \n"</span> <span class="Comment">// and EBX with *EAX</span> @@ -338,8 +338,8 @@ if ('onhashchange' in window) { <span id="L279" class="LineNr"> 279 </span> <span class="Constant">"0d 0c 0b 0a\n"</span> <span class="Comment">// 0x0a0b0c0d</span> <span id="L280" class="LineNr"> 280 </span> <span class="Delimiter">);</span> <span id="L281" class="LineNr"> 281 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L282" class="LineNr"> 282 </span> <span class="Constant">"run: and <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> -<span id="L283" class="LineNr"> 283 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L282" class="LineNr"> 282 </span> <span class="Constant">"run: and <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> +<span id="L283" class="LineNr"> 283 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L284" class="LineNr"> 284 </span> <span class="Constant">"run: storing 0x0000000d\n"</span> <span id="L285" class="LineNr"> 285 </span> <span class="Delimiter">);</span> <span id="L286" class="LineNr"> 286 </span><span class="Delimiter">}</span> @@ -347,13 +347,13 @@ if ('onhashchange' in window) { <span id="L288" class="LineNr"> 288 </span><span class="Comment">//:</span> <span id="L289" class="LineNr"> 289 </span> <span id="L290" class="LineNr"> 290 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L291" class="LineNr"> 291 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"23"</span><span class="Delimiter">,</span> <span class="Constant">"r32 = bitwise AND of r32 with rm32 (and)"</span><span class="Delimiter">);</span> +<span id="L291" class="LineNr"> 291 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"23"</span><span class="Delimiter">,</span> <span class="Constant">"r32 = bitwise AND of r32 with rm32 (and)"</span><span class="Delimiter">);</span> <span id="L292" class="LineNr"> 292 </span> <span id="L293" class="LineNr"> 293 </span><span class="Delimiter">:(code)</span> <span id="L294" class="LineNr"> 294 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L294'>test_and_mem_at_r32_with_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L295" class="LineNr"> 295 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L296" class="LineNr"> 296 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L297" class="LineNr"> 297 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L295" class="LineNr"> 295 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L296" class="LineNr"> 296 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L297" class="LineNr"> 297 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L298" class="LineNr"> 298 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L299" class="LineNr"> 299 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L300" class="LineNr"> 300 </span> <span class="Constant">" 23 18 \n"</span> <span class="Comment">// and *EAX with EBX</span> @@ -363,26 +363,26 @@ if ('onhashchange' in window) { <span id="L304" class="LineNr"> 304 </span> <span class="Delimiter">);</span> <span id="L305" class="LineNr"> 305 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L306" class="LineNr"> 306 </span> <span class="Constant">"run: and r/m32 with EBX\n"</span> -<span id="L307" class="LineNr"> 307 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L307" class="LineNr"> 307 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L308" class="LineNr"> 308 </span> <span class="Constant">"run: storing 0x0000000d\n"</span> <span id="L309" class="LineNr"> 309 </span> <span class="Delimiter">);</span> <span id="L310" class="LineNr"> 310 </span><span class="Delimiter">}</span> <span id="L311" class="LineNr"> 311 </span> <span id="L312" class="LineNr"> 312 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L313" class="LineNr"> 313 </span><span class="Normal">case</span> <span class="Constant">0x23</span>: <span class="Delimiter">{</span> <span class="Comment">// and r/m32 with r32</span> -<span id="L314" class="LineNr"> 314 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L314" class="LineNr"> 314 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L315" class="LineNr"> 315 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg1 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L316" class="LineNr"> 316 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"and r/m32 with "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg1<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L317" class="LineNr"> 317 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L318" class="LineNr"> 318 </span> <span class="Comment">// difference</span> <span id="L319" class="LineNr"> 319 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* signed_arg2 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L320" class="LineNr"> 320 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i &= *signed_arg2<span class="Delimiter">;</span> -<span id="L321" class="LineNr"> 321 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L322" class="LineNr"> 322 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L323" class="LineNr"> 323 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L324" class="LineNr"> 324 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L325" class="LineNr"> 325 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L326" class="LineNr"> 326 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L320" class="LineNr"> 320 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i &= *signed_arg2<span class="Delimiter">;</span> +<span id="L321" class="LineNr"> 321 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L322" class="LineNr"> 322 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> +<span id="L323" class="LineNr"> 323 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L324" class="LineNr"> 324 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L325" class="LineNr"> 325 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L326" class="LineNr"> 326 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L327" class="LineNr"> 327 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L328" class="LineNr"> 328 </span><span class="Delimiter">}</span> <span id="L329" class="LineNr"> 329 </span> @@ -390,9 +390,9 @@ if ('onhashchange' in window) { <span id="L331" class="LineNr"> 331 </span> <span id="L332" class="LineNr"> 332 </span><span class="Delimiter">:(code)</span> <span id="L333" class="LineNr"> 333 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L333'>test_or_r32_with_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L334" class="LineNr"> 334 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L335" class="LineNr"> 335 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xa0b0c0d0</span><span class="Delimiter">;</span> -<span id="L336" class="LineNr"> 336 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L334" class="LineNr"> 334 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L335" class="LineNr"> 335 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xa0b0c0d0</span><span class="Delimiter">;</span> +<span id="L336" class="LineNr"> 336 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L337" class="LineNr"> 337 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L338" class="LineNr"> 338 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L339" class="LineNr"> 339 </span> <span class="Constant">" 09 18 #\n"</span> <span class="Comment">// EBX with *EAX</span> @@ -401,8 +401,8 @@ if ('onhashchange' in window) { <span id="L342" class="LineNr"> 342 </span> <span class="Constant">"0d 0c 0b 0a\n"</span> <span class="Comment">// 0x0a0b0c0d</span> <span id="L343" class="LineNr"> 343 </span> <span class="Delimiter">);</span> <span id="L344" class="LineNr"> 344 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L345" class="LineNr"> 345 </span> <span class="Constant">"run: or <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> -<span id="L346" class="LineNr"> 346 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L345" class="LineNr"> 345 </span> <span class="Constant">"run: or <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> +<span id="L346" class="LineNr"> 346 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L347" class="LineNr"> 347 </span> <span class="Constant">"run: storing 0xaabbccdd\n"</span> <span id="L348" class="LineNr"> 348 </span> <span class="Delimiter">);</span> <span id="L349" class="LineNr"> 349 </span><span class="Delimiter">}</span> @@ -410,13 +410,13 @@ if ('onhashchange' in window) { <span id="L351" class="LineNr"> 351 </span><span class="Comment">//:</span> <span id="L352" class="LineNr"> 352 </span> <span id="L353" class="LineNr"> 353 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L354" class="LineNr"> 354 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"0b"</span><span class="Delimiter">,</span> <span class="Constant">"r32 = bitwise OR of r32 with rm32 (or)"</span><span class="Delimiter">);</span> +<span id="L354" class="LineNr"> 354 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"0b"</span><span class="Delimiter">,</span> <span class="Constant">"r32 = bitwise OR of r32 with rm32 (or)"</span><span class="Delimiter">);</span> <span id="L355" class="LineNr"> 355 </span> <span id="L356" class="LineNr"> 356 </span><span class="Delimiter">:(code)</span> <span id="L357" class="LineNr"> 357 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L357'>test_or_mem_at_r32_with_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L358" class="LineNr"> 358 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L359" class="LineNr"> 359 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xa0b0c0d0</span><span class="Delimiter">;</span> -<span id="L360" class="LineNr"> 360 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L358" class="LineNr"> 358 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L359" class="LineNr"> 359 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xa0b0c0d0</span><span class="Delimiter">;</span> +<span id="L360" class="LineNr"> 360 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L361" class="LineNr"> 361 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L362" class="LineNr"> 362 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L363" class="LineNr"> 363 </span> <span class="Constant">" 0b 18 \n"</span> <span class="Comment">// or *EAX with EBX</span> @@ -426,26 +426,26 @@ if ('onhashchange' in window) { <span id="L367" class="LineNr"> 367 </span> <span class="Delimiter">);</span> <span id="L368" class="LineNr"> 368 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L369" class="LineNr"> 369 </span> <span class="Constant">"run: or r/m32 with EBX\n"</span> -<span id="L370" class="LineNr"> 370 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L370" class="LineNr"> 370 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L371" class="LineNr"> 371 </span> <span class="Constant">"run: storing 0xaabbccdd\n"</span> <span id="L372" class="LineNr"> 372 </span> <span class="Delimiter">);</span> <span id="L373" class="LineNr"> 373 </span><span class="Delimiter">}</span> <span id="L374" class="LineNr"> 374 </span> <span id="L375" class="LineNr"> 375 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L376" class="LineNr"> 376 </span><span class="Normal">case</span> <span class="Constant">0x0b</span>: <span class="Delimiter">{</span> <span class="Comment">// or r/m32 with r32</span> -<span id="L377" class="LineNr"> 377 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L377" class="LineNr"> 377 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L378" class="LineNr"> 378 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg1 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L379" class="LineNr"> 379 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"or r/m32 with "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg1<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L380" class="LineNr"> 380 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L381" class="LineNr"> 381 </span> <span class="Comment">// difference</span> <span id="L382" class="LineNr"> 382 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* signed_arg2 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L383" class="LineNr"> 383 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i |= *signed_arg2<span class="Delimiter">;</span> -<span id="L384" class="LineNr"> 384 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L385" class="LineNr"> 385 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L386" class="LineNr"> 386 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L387" class="LineNr"> 387 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L388" class="LineNr"> 388 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L389" class="LineNr"> 389 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L383" class="LineNr"> 383 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i |= *signed_arg2<span class="Delimiter">;</span> +<span id="L384" class="LineNr"> 384 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L385" class="LineNr"> 385 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> +<span id="L386" class="LineNr"> 386 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L387" class="LineNr"> 387 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L388" class="LineNr"> 388 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L389" class="LineNr"> 389 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L390" class="LineNr"> 390 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L391" class="LineNr"> 391 </span><span class="Delimiter">}</span> <span id="L392" class="LineNr"> 392 </span> @@ -453,9 +453,9 @@ if ('onhashchange' in window) { <span id="L394" class="LineNr"> 394 </span> <span id="L395" class="LineNr"> 395 </span><span class="Delimiter">:(code)</span> <span id="L396" class="LineNr"> 396 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L396'>test_xor_r32_with_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L397" class="LineNr"> 397 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L398" class="LineNr"> 398 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xa0b0c0d0</span><span class="Delimiter">;</span> -<span id="L399" class="LineNr"> 399 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L397" class="LineNr"> 397 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L398" class="LineNr"> 398 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xa0b0c0d0</span><span class="Delimiter">;</span> +<span id="L399" class="LineNr"> 399 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L400" class="LineNr"> 400 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L401" class="LineNr"> 401 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L402" class="LineNr"> 402 </span> <span class="Constant">" 31 18 \n"</span> <span class="Comment">// xor EBX with *EAX</span> @@ -463,8 +463,8 @@ if ('onhashchange' in window) { <span id="L404" class="LineNr"> 404 </span> <span class="Constant">"0d 0c bb aa\n"</span> <span class="Comment">// 0xaabb0c0d</span> <span id="L405" class="LineNr"> 405 </span> <span class="Delimiter">);</span> <span id="L406" class="LineNr"> 406 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L407" class="LineNr"> 407 </span> <span class="Constant">"run: xor <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> -<span id="L408" class="LineNr"> 408 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L407" class="LineNr"> 407 </span> <span class="Constant">"run: xor <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> +<span id="L408" class="LineNr"> 408 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L409" class="LineNr"> 409 </span> <span class="Constant">"run: storing 0x0a0bccdd\n"</span> <span id="L410" class="LineNr"> 410 </span> <span class="Delimiter">);</span> <span id="L411" class="LineNr"> 411 </span><span class="Delimiter">}</span> @@ -472,13 +472,13 @@ if ('onhashchange' in window) { <span id="L413" class="LineNr"> 413 </span><span class="Comment">//:</span> <span id="L414" class="LineNr"> 414 </span> <span id="L415" class="LineNr"> 415 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L416" class="LineNr"> 416 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"33"</span><span class="Delimiter">,</span> <span class="Constant">"r32 = bitwise XOR of r32 with rm32 (xor)"</span><span class="Delimiter">);</span> +<span id="L416" class="LineNr"> 416 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"33"</span><span class="Delimiter">,</span> <span class="Constant">"r32 = bitwise XOR of r32 with rm32 (xor)"</span><span class="Delimiter">);</span> <span id="L417" class="LineNr"> 417 </span> <span id="L418" class="LineNr"> 418 </span><span class="Delimiter">:(code)</span> <span id="L419" class="LineNr"> 419 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L419'>test_xor_mem_at_r32_with_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L420" class="LineNr"> 420 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L421" class="LineNr"> 421 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xa0b0c0d0</span><span class="Delimiter">;</span> -<span id="L422" class="LineNr"> 422 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L420" class="LineNr"> 420 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L421" class="LineNr"> 421 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xa0b0c0d0</span><span class="Delimiter">;</span> +<span id="L422" class="LineNr"> 422 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L423" class="LineNr"> 423 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L424" class="LineNr"> 424 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L425" class="LineNr"> 425 </span> <span class="Constant">" 33 18 \n"</span> <span class="Comment">// xor *EAX with EBX</span> @@ -488,26 +488,26 @@ if ('onhashchange' in window) { <span id="L429" class="LineNr"> 429 </span> <span class="Delimiter">);</span> <span id="L430" class="LineNr"> 430 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L431" class="LineNr"> 431 </span> <span class="Constant">"run: xor r/m32 with EBX\n"</span> -<span id="L432" class="LineNr"> 432 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L432" class="LineNr"> 432 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L433" class="LineNr"> 433 </span> <span class="Constant">"run: storing 0xaabbccdd\n"</span> <span id="L434" class="LineNr"> 434 </span> <span class="Delimiter">);</span> <span id="L435" class="LineNr"> 435 </span><span class="Delimiter">}</span> <span id="L436" class="LineNr"> 436 </span> <span id="L437" class="LineNr"> 437 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L438" class="LineNr"> 438 </span><span class="Normal">case</span> <span class="Constant">0x33</span>: <span class="Delimiter">{</span> <span class="Comment">// xor r/m32 with r32</span> -<span id="L439" class="LineNr"> 439 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L439" class="LineNr"> 439 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L440" class="LineNr"> 440 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg1 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L441" class="LineNr"> 441 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"xor r/m32 with "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg1<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L442" class="LineNr"> 442 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L443" class="LineNr"> 443 </span> <span class="Comment">// difference</span> <span id="L444" class="LineNr"> 444 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* signed_arg2 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L445" class="LineNr"> 445 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i |= *signed_arg2<span class="Delimiter">;</span> -<span id="L446" class="LineNr"> 446 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L447" class="LineNr"> 447 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L448" class="LineNr"> 448 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L449" class="LineNr"> 449 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L450" class="LineNr"> 450 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L451" class="LineNr"> 451 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L445" class="LineNr"> 445 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i |= *signed_arg2<span class="Delimiter">;</span> +<span id="L446" class="LineNr"> 446 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L447" class="LineNr"> 447 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> +<span id="L448" class="LineNr"> 448 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L449" class="LineNr"> 449 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L450" class="LineNr"> 450 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L451" class="LineNr"> 451 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L452" class="LineNr"> 452 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L453" class="LineNr"> 453 </span><span class="Delimiter">}</span> <span id="L454" class="LineNr"> 454 </span> @@ -515,8 +515,8 @@ if ('onhashchange' in window) { <span id="L456" class="LineNr"> 456 </span> <span id="L457" class="LineNr"> 457 </span><span class="Delimiter">:(code)</span> <span id="L458" class="LineNr"> 458 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L458'>test_not_of_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L459" class="LineNr"> 459 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L460" class="LineNr"> 460 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L459" class="LineNr"> 459 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L460" class="LineNr"> 460 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L461" class="LineNr"> 461 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L462" class="LineNr"> 462 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L463" class="LineNr"> 463 </span> <span class="Constant">" f7 13 \n"</span> <span class="Comment">// not *EBX</span> @@ -526,7 +526,7 @@ if ('onhashchange' in window) { <span id="L467" class="LineNr"> 467 </span> <span class="Delimiter">);</span> <span id="L468" class="LineNr"> 468 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L469" class="LineNr"> 469 </span> <span class="Constant">"run: operate on r/m32\n"</span> -<span id="L470" class="LineNr"> 470 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> +<span id="L470" class="LineNr"> 470 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> <span id="L471" class="LineNr"> 471 </span> <span class="Constant">"run: subop: not\n"</span> <span id="L472" class="LineNr"> 472 </span> <span class="Constant">"run: storing 0xf0f0ff00\n"</span> <span id="L473" class="LineNr"> 473 </span> <span class="Delimiter">);</span> @@ -536,9 +536,9 @@ if ('onhashchange' in window) { <span id="L477" class="LineNr"> 477 </span> <span id="L478" class="LineNr"> 478 </span><span class="Delimiter">:(code)</span> <span id="L479" class="LineNr"> 479 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L479'>test_compare_mem_at_r32_with_r32_greater</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L480" class="LineNr"> 480 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L481" class="LineNr"> 481 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> -<span id="L482" class="LineNr"> 482 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L480" class="LineNr"> 480 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L481" class="LineNr"> 481 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> +<span id="L482" class="LineNr"> 482 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L483" class="LineNr"> 483 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L484" class="LineNr"> 484 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L485" class="LineNr"> 485 </span> <span class="Constant">" 39 18 \n"</span> <span class="Comment">// compare *EAX with EBX</span> @@ -548,16 +548,16 @@ if ('onhashchange' in window) { <span id="L489" class="LineNr"> 489 </span> <span class="Delimiter">);</span> <span id="L490" class="LineNr"> 490 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L491" class="LineNr"> 491 </span> <span class="Constant">"run: compare r/m32 with EBX\n"</span> -<span id="L492" class="LineNr"> 492 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L492" class="LineNr"> 492 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L493" class="LineNr"> 493 </span> <span class="Constant">"run: SF=0; ZF=0; CF=0; OF=0\n"</span> <span id="L494" class="LineNr"> 494 </span> <span class="Delimiter">);</span> <span id="L495" class="LineNr"> 495 </span><span class="Delimiter">}</span> <span id="L496" class="LineNr"> 496 </span> <span id="L497" class="LineNr"> 497 </span><span class="Delimiter">:(code)</span> <span id="L498" class="LineNr"> 498 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L498'>test_compare_mem_at_r32_with_r32_lesser</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L499" class="LineNr"> 499 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L500" class="LineNr"> 500 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L501" class="LineNr"> 501 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L499" class="LineNr"> 499 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L500" class="LineNr"> 500 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L501" class="LineNr"> 501 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L502" class="LineNr"> 502 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L503" class="LineNr"> 503 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L504" class="LineNr"> 504 </span> <span class="Constant">" 39 18 \n"</span> <span class="Comment">// compare *EAX with EBX</span> @@ -567,16 +567,16 @@ if ('onhashchange' in window) { <span id="L508" class="LineNr"> 508 </span> <span class="Delimiter">);</span> <span id="L509" class="LineNr"> 509 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L510" class="LineNr"> 510 </span> <span class="Constant">"run: compare r/m32 with EBX\n"</span> -<span id="L511" class="LineNr"> 511 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L511" class="LineNr"> 511 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L512" class="LineNr"> 512 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=0\n"</span> <span id="L513" class="LineNr"> 513 </span> <span class="Delimiter">);</span> <span id="L514" class="LineNr"> 514 </span><span class="Delimiter">}</span> <span id="L515" class="LineNr"> 515 </span> <span id="L516" class="LineNr"> 516 </span><span class="Delimiter">:(code)</span> <span id="L517" class="LineNr"> 517 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L517'>test_compare_mem_at_r32_with_r32_equal</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L518" class="LineNr"> 518 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L519" class="LineNr"> 519 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L520" class="LineNr"> 520 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L518" class="LineNr"> 518 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L519" class="LineNr"> 519 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L520" class="LineNr"> 520 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L521" class="LineNr"> 521 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L522" class="LineNr"> 522 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L523" class="LineNr"> 523 </span> <span class="Constant">" 39 18 \n"</span> <span class="Comment">// compare *EAX and EBX</span> @@ -586,7 +586,7 @@ if ('onhashchange' in window) { <span id="L527" class="LineNr"> 527 </span> <span class="Delimiter">);</span> <span id="L528" class="LineNr"> 528 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L529" class="LineNr"> 529 </span> <span class="Constant">"run: compare r/m32 with EBX\n"</span> -<span id="L530" class="LineNr"> 530 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L530" class="LineNr"> 530 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L531" class="LineNr"> 531 </span> <span class="Constant">"run: SF=0; ZF=1; CF=0; OF=0\n"</span> <span id="L532" class="LineNr"> 532 </span> <span class="Delimiter">);</span> <span id="L533" class="LineNr"> 533 </span><span class="Delimiter">}</span> @@ -594,13 +594,13 @@ if ('onhashchange' in window) { <span id="L535" class="LineNr"> 535 </span><span class="Comment">//:</span> <span id="L536" class="LineNr"> 536 </span> <span id="L537" class="LineNr"> 537 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L538" class="LineNr"> 538 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"3b"</span><span class="Delimiter">,</span> <span class="Constant">"compare: set SF if r32 < rm32 (cmp)"</span><span class="Delimiter">);</span> +<span id="L538" class="LineNr"> 538 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"3b"</span><span class="Delimiter">,</span> <span class="Constant">"compare: set SF if r32 < rm32 (cmp)"</span><span class="Delimiter">);</span> <span id="L539" class="LineNr"> 539 </span> <span id="L540" class="LineNr"> 540 </span><span class="Delimiter">:(code)</span> <span id="L541" class="LineNr"> 541 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L541'>test_compare_r32_with_mem_at_r32_greater</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L542" class="LineNr"> 542 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L543" class="LineNr"> 543 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L544" class="LineNr"> 544 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L542" class="LineNr"> 542 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L543" class="LineNr"> 543 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L544" class="LineNr"> 544 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L545" class="LineNr"> 545 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L546" class="LineNr"> 546 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L547" class="LineNr"> 547 </span> <span class="Constant">" 3b 18 \n"</span> <span class="Comment">// compare EBX with *EAX</span> @@ -609,36 +609,36 @@ if ('onhashchange' in window) { <span id="L550" class="LineNr"> 550 </span> <span class="Constant">"07 0c 0b 0a\n"</span> <span class="Comment">// 0x0a0b0c07</span> <span id="L551" class="LineNr"> 551 </span> <span class="Delimiter">);</span> <span id="L552" class="LineNr"> 552 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L553" class="LineNr"> 553 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> -<span id="L554" class="LineNr"> 554 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L553" class="LineNr"> 553 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> +<span id="L554" class="LineNr"> 554 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L555" class="LineNr"> 555 </span> <span class="Constant">"run: SF=0; ZF=0; CF=0; OF=0\n"</span> <span id="L556" class="LineNr"> 556 </span> <span class="Delimiter">);</span> <span id="L557" class="LineNr"> 557 </span><span class="Delimiter">}</span> <span id="L558" class="LineNr"> 558 </span> <span id="L559" class="LineNr"> 559 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L560" class="LineNr"> 560 </span><span class="Normal">case</span> <span class="Constant">0x3b</span>: <span class="Delimiter">{</span> <span class="Comment">// set SF if r32 < r/m32</span> -<span id="L561" class="LineNr"> 561 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L561" class="LineNr"> 561 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L562" class="LineNr"> 562 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> reg1 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L563" class="LineNr"> 563 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"compare "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>reg1<span class="Delimiter">)</span> << <span class="Constant">" with r/m32"</span> << end<span class="Delimiter">();</span> <span id="L564" class="LineNr"> 564 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* signed_arg2 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L565" class="LineNr"> 565 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_difference = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg1]<span class="Delimiter">.</span>i - *signed_arg2<span class="Delimiter">;</span> +<span id="L565" class="LineNr"> 565 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_difference = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg1]<span class="Delimiter">.</span>i - *signed_arg2<span class="Delimiter">;</span> <span id="L566" class="LineNr"> 566 </span> SF = <span class="Delimiter">(</span>signed_difference < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L567" class="LineNr"> 567 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_difference == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L568" class="LineNr"> 568 </span> <span class="Normal">int64_t</span> full_signed_difference = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg1]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> - *signed_arg2<span class="Delimiter">;</span> -<span id="L569" class="LineNr"> 569 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_difference != full_signed_difference<span class="Delimiter">);</span> +<span id="L567" class="LineNr"> 567 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_difference == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L568" class="LineNr"> 568 </span> <span class="Normal">int64_t</span> full_signed_difference = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg1]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> - *signed_arg2<span class="Delimiter">;</span> +<span id="L569" class="LineNr"> 569 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_difference != full_signed_difference<span class="Delimiter">);</span> <span id="L570" class="LineNr"> 570 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_arg2 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*signed_arg2<span class="Delimiter">);</span> -<span id="L571" class="LineNr"> 571 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_difference = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg1]<span class="Delimiter">.</span>u - unsigned_arg2<span class="Delimiter">;</span> -<span id="L572" class="LineNr"> 572 </span> <span class="Normal">const</span> <span class="Normal">uint64_t</span> full_unsigned_difference = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg1]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> - unsigned_arg2<span class="Delimiter">;</span> -<span id="L573" class="LineNr"> 573 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_difference != full_unsigned_difference<span class="Delimiter">);</span> -<span id="L574" class="LineNr"> 574 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L571" class="LineNr"> 571 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_difference = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg1]<span class="Delimiter">.</span>u - unsigned_arg2<span class="Delimiter">;</span> +<span id="L572" class="LineNr"> 572 </span> <span class="Normal">const</span> <span class="Normal">uint64_t</span> full_unsigned_difference = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg1]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> - unsigned_arg2<span class="Delimiter">;</span> +<span id="L573" class="LineNr"> 573 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_difference != full_unsigned_difference<span class="Delimiter">);</span> +<span id="L574" class="LineNr"> 574 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L575" class="LineNr"> 575 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L576" class="LineNr"> 576 </span><span class="Delimiter">}</span> <span id="L577" class="LineNr"> 577 </span> <span id="L578" class="LineNr"> 578 </span><span class="Delimiter">:(code)</span> <span id="L579" class="LineNr"> 579 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L579'>test_compare_r32_with_mem_at_r32_lesser_unsigned_and_signed</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L580" class="LineNr"> 580 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L581" class="LineNr"> 581 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> -<span id="L582" class="LineNr"> 582 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L580" class="LineNr"> 580 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L581" class="LineNr"> 581 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> +<span id="L582" class="LineNr"> 582 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L583" class="LineNr"> 583 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L584" class="LineNr"> 584 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L585" class="LineNr"> 585 </span> <span class="Constant">" 3b 18 \n"</span> <span class="Comment">// compare EBX with *EAX</span> @@ -647,17 +647,17 @@ if ('onhashchange' in window) { <span id="L588" class="LineNr"> 588 </span> <span class="Constant">"0d 0c 0b 0a\n"</span> <span class="Comment">// 0x0a0b0c0d</span> <span id="L589" class="LineNr"> 589 </span> <span class="Delimiter">);</span> <span id="L590" class="LineNr"> 590 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L591" class="LineNr"> 591 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> -<span id="L592" class="LineNr"> 592 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L593" class="LineNr"> 593 </span> <span class="Constant">"run: effective address contains a0b0c0d\n"</span> +<span id="L591" class="LineNr"> 591 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> +<span id="L592" class="LineNr"> 592 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L593" class="LineNr"> 593 </span> <span class="Constant">"run: effective address contains 0x0a0b0c0d\n"</span> <span id="L594" class="LineNr"> 594 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=0\n"</span> <span id="L595" class="LineNr"> 595 </span> <span class="Delimiter">);</span> <span id="L596" class="LineNr"> 596 </span><span class="Delimiter">}</span> <span id="L597" class="LineNr"> 597 </span> <span id="L598" class="LineNr"> 598 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L598'>test_compare_r32_with_mem_at_r32_lesser_unsigned_and_signed_due_to_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L599" class="LineNr"> 599 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L600" class="LineNr"> 600 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> -<span id="L601" class="LineNr"> 601 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L599" class="LineNr"> 599 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L600" class="LineNr"> 600 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> +<span id="L601" class="LineNr"> 601 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L602" class="LineNr"> 602 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L603" class="LineNr"> 603 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L604" class="LineNr"> 604 </span> <span class="Constant">" 3b 18 \n"</span> <span class="Comment">// compare EBX with *EAX</span> @@ -666,17 +666,17 @@ if ('onhashchange' in window) { <span id="L607" class="LineNr"> 607 </span> <span class="Constant">"00 00 00 80\n"</span> <span class="Comment">// smallest negative signed integer</span> <span id="L608" class="LineNr"> 608 </span> <span class="Delimiter">);</span> <span id="L609" class="LineNr"> 609 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L610" class="LineNr"> 610 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> -<span id="L611" class="LineNr"> 611 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L612" class="LineNr"> 612 </span> <span class="Constant">"run: effective address contains 80000000\n"</span> +<span id="L610" class="LineNr"> 610 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> +<span id="L611" class="LineNr"> 611 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L612" class="LineNr"> 612 </span> <span class="Constant">"run: effective address contains 0x80000000\n"</span> <span id="L613" class="LineNr"> 613 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=1\n"</span> <span id="L614" class="LineNr"> 614 </span> <span class="Delimiter">);</span> <span id="L615" class="LineNr"> 615 </span><span class="Delimiter">}</span> <span id="L616" class="LineNr"> 616 </span> <span id="L617" class="LineNr"> 617 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L617'>test_compare_r32_with_mem_at_r32_lesser_signed</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L618" class="LineNr"> 618 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L619" class="LineNr"> 619 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// -1</span> -<span id="L620" class="LineNr"> 620 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L618" class="LineNr"> 618 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L619" class="LineNr"> 619 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// -1</span> +<span id="L620" class="LineNr"> 620 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L621" class="LineNr"> 621 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L622" class="LineNr"> 622 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L623" class="LineNr"> 623 </span> <span class="Constant">" 3b 18 \n"</span> <span class="Comment">// compare EBX with *EAX</span> @@ -685,17 +685,17 @@ if ('onhashchange' in window) { <span id="L626" class="LineNr"> 626 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 1</span> <span id="L627" class="LineNr"> 627 </span> <span class="Delimiter">);</span> <span id="L628" class="LineNr"> 628 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L629" class="LineNr"> 629 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> -<span id="L630" class="LineNr"> 630 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L631" class="LineNr"> 631 </span> <span class="Constant">"run: effective address contains 1\n"</span> +<span id="L629" class="LineNr"> 629 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> +<span id="L630" class="LineNr"> 630 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L631" class="LineNr"> 631 </span> <span class="Constant">"run: effective address contains 0x00000001\n"</span> <span id="L632" class="LineNr"> 632 </span> <span class="Constant">"run: SF=1; ZF=0; CF=0; OF=0\n"</span> <span id="L633" class="LineNr"> 633 </span> <span class="Delimiter">);</span> <span id="L634" class="LineNr"> 634 </span><span class="Delimiter">}</span> <span id="L635" class="LineNr"> 635 </span> <span id="L636" class="LineNr"> 636 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L636'>test_compare_r32_with_mem_at_r32_lesser_unsigned</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L637" class="LineNr"> 637 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L638" class="LineNr"> 638 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x00000001</span><span class="Delimiter">;</span> <span class="Comment">// 1</span> -<span id="L639" class="LineNr"> 639 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L637" class="LineNr"> 637 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L638" class="LineNr"> 638 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x00000001</span><span class="Delimiter">;</span> <span class="Comment">// 1</span> +<span id="L639" class="LineNr"> 639 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L640" class="LineNr"> 640 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L641" class="LineNr"> 641 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L642" class="LineNr"> 642 </span> <span class="Constant">" 3b 18 \n"</span> <span class="Comment">// compare EBX with *EAX</span> @@ -704,17 +704,17 @@ if ('onhashchange' in window) { <span id="L645" class="LineNr"> 645 </span> <span class="Constant">"ff ff ff ff\n"</span> <span class="Comment">// -1</span> <span id="L646" class="LineNr"> 646 </span> <span class="Delimiter">);</span> <span id="L647" class="LineNr"> 647 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L648" class="LineNr"> 648 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> -<span id="L649" class="LineNr"> 649 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L650" class="LineNr"> 650 </span> <span class="Constant">"run: effective address contains ffffffff\n"</span> +<span id="L648" class="LineNr"> 648 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> +<span id="L649" class="LineNr"> 649 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L650" class="LineNr"> 650 </span> <span class="Constant">"run: effective address contains 0xffffffff\n"</span> <span id="L651" class="LineNr"> 651 </span> <span class="Constant">"run: SF=0; ZF=0; CF=1; OF=0\n"</span> <span id="L652" class="LineNr"> 652 </span> <span class="Delimiter">);</span> <span id="L653" class="LineNr"> 653 </span><span class="Delimiter">}</span> <span id="L654" class="LineNr"> 654 </span> <span id="L655" class="LineNr"> 655 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L655'>test_compare_r32_with_mem_at_r32_equal</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L656" class="LineNr"> 656 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L657" class="LineNr"> 657 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> -<span id="L658" class="LineNr"> 658 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L656" class="LineNr"> 656 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L657" class="LineNr"> 657 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c0d</span><span class="Delimiter">;</span> +<span id="L658" class="LineNr"> 658 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L659" class="LineNr"> 659 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L660" class="LineNr"> 660 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L661" class="LineNr"> 661 </span> <span class="Constant">" 3b 18 \n"</span> <span class="Comment">// compare EBX with *EAX</span> @@ -723,8 +723,8 @@ if ('onhashchange' in window) { <span id="L664" class="LineNr"> 664 </span> <span class="Constant">"0d 0c 0b 0a\n"</span> <span class="Comment">// 0x0a0b0c0d</span> <span id="L665" class="LineNr"> 665 </span> <span class="Delimiter">);</span> <span id="L666" class="LineNr"> 666 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L667" class="LineNr"> 667 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L19'>EBX</a> with r/m32\n"</span> -<span id="L668" class="LineNr"> 668 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L667" class="LineNr"> 667 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L13'>EBX</a> with r/m32\n"</span> +<span id="L668" class="LineNr"> 668 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L669" class="LineNr"> 669 </span> <span class="Constant">"run: SF=0; ZF=1; CF=0; OF=0\n"</span> <span id="L670" class="LineNr"> 670 </span> <span class="Delimiter">);</span> <span id="L671" class="LineNr"> 671 </span><span class="Delimiter">}</span> @@ -732,17 +732,17 @@ if ('onhashchange' in window) { <span id="L673" class="LineNr"> 673 </span><span class="SalientComment">//:: copy (mov)</span> <span id="L674" class="LineNr"> 674 </span> <span id="L675" class="LineNr"> 675 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L675'>test_copy_r32_to_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L676" class="LineNr"> 676 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xaf</span><span class="Delimiter">;</span> -<span id="L677" class="LineNr"> 677 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x60</span><span class="Delimiter">;</span> -<span id="L678" class="LineNr"> 678 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L676" class="LineNr"> 676 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xaf</span><span class="Delimiter">;</span> +<span id="L677" class="LineNr"> 677 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x60</span><span class="Delimiter">;</span> +<span id="L678" class="LineNr"> 678 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L679" class="LineNr"> 679 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L680" class="LineNr"> 680 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L681" class="LineNr"> 681 </span> <span class="Constant">" 89 18 \n"</span> <span class="Comment">// copy EBX to *EAX</span> <span id="L682" class="LineNr"> 682 </span> <span class="Comment">// ModR/M in binary: 00 (indirect mode) 011 (src EAX) 000 (dest EAX)</span> <span id="L683" class="LineNr"> 683 </span> <span class="Delimiter">);</span> <span id="L684" class="LineNr"> 684 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L685" class="LineNr"> 685 </span> <span class="Constant">"run: copy <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L686" class="LineNr"> 686 </span> <span class="Constant">"run: effective address is 0x00000060 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L685" class="LineNr"> 685 </span> <span class="Constant">"run: copy <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L686" class="LineNr"> 686 </span> <span class="Constant">"run: effective address is 0x00000060 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L687" class="LineNr"> 687 </span> <span class="Constant">"run: storing 0x000000af\n"</span> <span id="L688" class="LineNr"> 688 </span> <span class="Delimiter">);</span> <span id="L689" class="LineNr"> 689 </span><span class="Delimiter">}</span> @@ -750,12 +750,12 @@ if ('onhashchange' in window) { <span id="L691" class="LineNr"> 691 </span><span class="Comment">//:</span> <span id="L692" class="LineNr"> 692 </span> <span id="L693" class="LineNr"> 693 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L694" class="LineNr"> 694 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"8b"</span><span class="Delimiter">,</span> <span class="Constant">"copy rm32 to r32 (mov)"</span><span class="Delimiter">);</span> +<span id="L694" class="LineNr"> 694 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"8b"</span><span class="Delimiter">,</span> <span class="Constant">"copy rm32 to r32 (mov)"</span><span class="Delimiter">);</span> <span id="L695" class="LineNr"> 695 </span> <span id="L696" class="LineNr"> 696 </span><span class="Delimiter">:(code)</span> <span id="L697" class="LineNr"> 697 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L697'>test_copy_mem_at_r32_to_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L698" class="LineNr"> 698 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L699" class="LineNr"> 699 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L698" class="LineNr"> 698 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L699" class="LineNr"> 699 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L700" class="LineNr"> 700 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L701" class="LineNr"> 701 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L702" class="LineNr"> 702 </span> <span class="Constant">" 8b 18 \n"</span> <span class="Comment">// copy *EAX to EBX</span> @@ -764,19 +764,19 @@ if ('onhashchange' in window) { <span id="L705" class="LineNr"> 705 </span> <span class="Delimiter">);</span> <span id="L706" class="LineNr"> 706 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L707" class="LineNr"> 707 </span> <span class="Constant">"run: copy r/m32 to EBX\n"</span> -<span id="L708" class="LineNr"> 708 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L708" class="LineNr"> 708 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L709" class="LineNr"> 709 </span> <span class="Constant">"run: storing 0x000000af\n"</span> <span id="L710" class="LineNr"> 710 </span> <span class="Delimiter">);</span> <span id="L711" class="LineNr"> 711 </span><span class="Delimiter">}</span> <span id="L712" class="LineNr"> 712 </span> <span id="L713" class="LineNr"> 713 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L714" class="LineNr"> 714 </span><span class="Normal">case</span> <span class="Constant">0x8b</span>: <span class="Delimiter">{</span> <span class="Comment">// copy r32 to r/m32</span> -<span id="L715" class="LineNr"> 715 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L715" class="LineNr"> 715 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L716" class="LineNr"> 716 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> rdest = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L717" class="LineNr"> 717 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy r/m32 to "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rdest<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L718" class="LineNr"> 718 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* src = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L719" class="LineNr"> 719 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[rdest]<span class="Delimiter">.</span>i = *src<span class="Delimiter">;</span> -<span id="L720" class="LineNr"> 720 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *src << end<span class="Delimiter">();</span> +<span id="L719" class="LineNr"> 719 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[rdest]<span class="Delimiter">.</span>i = *src<span class="Delimiter">;</span> +<span id="L720" class="LineNr"> 720 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *src << end<span class="Delimiter">();</span> <span id="L721" class="LineNr"> 721 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L722" class="LineNr"> 722 </span><span class="Delimiter">}</span> <span id="L723" class="LineNr"> 723 </span> @@ -784,8 +784,8 @@ if ('onhashchange' in window) { <span id="L725" class="LineNr"> 725 </span> <span id="L726" class="LineNr"> 726 </span><span class="Delimiter">:(code)</span> <span id="L727" class="LineNr"> 727 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L727'>test_jump_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L728" class="LineNr"> 728 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L729" class="LineNr"> 729 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L728" class="LineNr"> 728 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L729" class="LineNr"> 729 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L730" class="LineNr"> 730 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L731" class="LineNr"> 731 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L732" class="LineNr"> 732 </span> <span class="Constant">" ff 20 \n"</span> <span class="Comment">// jump to *EAX</span> @@ -798,7 +798,7 @@ if ('onhashchange' in window) { <span id="L739" class="LineNr"> 739 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L740" class="LineNr"> 740 </span> <span class="Constant">"run: 0x00000001 opcode: ff\n"</span> <span id="L741" class="LineNr"> 741 </span> <span class="Constant">"run: jump to r/m32\n"</span> -<span id="L742" class="LineNr"> 742 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L742" class="LineNr"> 742 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L743" class="LineNr"> 743 </span> <span class="Constant">"run: jumping to 0x00000008\n"</span> <span id="L744" class="LineNr"> 744 </span> <span class="Constant">"run: 0x00000008 opcode: b8\n"</span> <span id="L745" class="LineNr"> 745 </span> <span class="Delimiter">);</span> @@ -809,8 +809,8 @@ if ('onhashchange' in window) { <span id="L750" class="LineNr"> 750 </span><span class="Normal">case</span> <span class="Constant">4</span>: <span class="Delimiter">{</span> <span class="Comment">// jump to r/m32</span> <span id="L751" class="LineNr"> 751 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump to r/m32"</span> << end<span class="Delimiter">();</span> <span id="L752" class="LineNr"> 752 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* arg2 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L753" class="LineNr"> 753 </span> <a href='010---vm.cc.html#L32'>EIP</a> = *arg2<span class="Delimiter">;</span> -<span id="L754" class="LineNr"> 754 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jumping to 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L32'>EIP</a> << end<span class="Delimiter">();</span> +<span id="L753" class="LineNr"> 753 </span> <a href='010---vm.cc.html#L26'>EIP</a> = *arg2<span class="Delimiter">;</span> +<span id="L754" class="LineNr"> 754 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jumping to 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L26'>EIP</a> << end<span class="Delimiter">();</span> <span id="L755" class="LineNr"> 755 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L756" class="LineNr"> 756 </span><span class="Delimiter">}</span> <span id="L757" class="LineNr"> 757 </span> @@ -818,10 +818,10 @@ if ('onhashchange' in window) { <span id="L759" class="LineNr"> 759 </span> <span id="L760" class="LineNr"> 760 </span><span class="Delimiter">:(code)</span> <span id="L761" class="LineNr"> 761 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L761'>test_push_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L762" class="LineNr"> 762 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L763" class="LineNr"> 763 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> -<span id="L764" class="LineNr"> 764 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000014</span><span class="Delimiter">;</span> -<span id="L765" class="LineNr"> 765 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L762" class="LineNr"> 762 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L763" class="LineNr"> 763 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> +<span id="L764" class="LineNr"> 764 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000014</span><span class="Delimiter">;</span> +<span id="L765" class="LineNr"> 765 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L766" class="LineNr"> 766 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L767" class="LineNr"> 767 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L768" class="LineNr"> 768 </span> <span class="Constant">" ff 30 \n"</span> <span class="Comment">// push *EAX to stack</span> @@ -830,8 +830,8 @@ if ('onhashchange' in window) { <span id="L771" class="LineNr"> 771 </span> <span class="Delimiter">);</span> <span id="L772" class="LineNr"> 772 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L773" class="LineNr"> 773 </span> <span class="Constant">"run: <a href='012elf.cc.html#L94'>push</a> r/m32\n"</span> -<span id="L774" class="LineNr"> 774 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L775" class="LineNr"> 775 </span> <span class="Constant">"run: decrementing <a href='010---vm.cc.html#L20'>ESP</a> to 0xbd000010\n"</span> +<span id="L774" class="LineNr"> 774 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L775" class="LineNr"> 775 </span> <span class="Constant">"run: decrementing <a href='010---vm.cc.html#L14'>ESP</a> to 0xbd000010\n"</span> <span id="L776" class="LineNr"> 776 </span> <span class="Constant">"run: pushing value 0x000000af\n"</span> <span id="L777" class="LineNr"> 777 </span> <span class="Delimiter">);</span> <span id="L778" class="LineNr"> 778 </span><span class="Delimiter">}</span> @@ -847,15 +847,15 @@ if ('onhashchange' in window) { <span id="L788" class="LineNr"> 788 </span><span class="SalientComment">//:: pop</span> <span id="L789" class="LineNr"> 789 </span> <span id="L790" class="LineNr"> 790 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L791" class="LineNr"> 791 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"8f"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to rm32 (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> +<span id="L791" class="LineNr"> 791 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"8f"</span><span class="Delimiter">,</span> <span class="Constant">"pop top of stack to rm32 (<a href='013direct_addressing.cc.html#L1272'>pop</a>)"</span><span class="Delimiter">);</span> <span id="L792" class="LineNr"> 792 </span> <span id="L793" class="LineNr"> 793 </span><span class="Delimiter">:(code)</span> <span id="L794" class="LineNr"> 794 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L794'>test_pop_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L795" class="LineNr"> 795 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x60</span><span class="Delimiter">;</span> -<span id="L796" class="LineNr"> 796 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> -<span id="L797" class="LineNr"> 797 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000000</span><span class="Delimiter">;</span> -<span id="L798" class="LineNr"> 798 </span> <a href='010---vm.cc.html#L249'>write_mem_i32</a><span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">,</span> <span class="Constant">0x00000030</span><span class="Delimiter">);</span> -<span id="L799" class="LineNr"> 799 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L795" class="LineNr"> 795 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x60</span><span class="Delimiter">;</span> +<span id="L796" class="LineNr"> 796 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> +<span id="L797" class="LineNr"> 797 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000000</span><span class="Delimiter">;</span> +<span id="L798" class="LineNr"> 798 </span> <a href='010---vm.cc.html#L243'>write_mem_i32</a><span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">,</span> <span class="Constant">0x00000030</span><span class="Delimiter">);</span> +<span id="L799" class="LineNr"> 799 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L800" class="LineNr"> 800 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L801" class="LineNr"> 801 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L802" class="LineNr"> 802 </span> <span class="Constant">" 8f 00 \n"</span> <span class="Comment">// pop stack into *EAX</span> @@ -863,15 +863,15 @@ if ('onhashchange' in window) { <span id="L804" class="LineNr"> 804 </span> <span class="Delimiter">);</span> <span id="L805" class="LineNr"> 805 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L806" class="LineNr"> 806 </span> <span class="Constant">"run: <a href='013direct_addressing.cc.html#L1272'>pop</a> into r/m32\n"</span> -<span id="L807" class="LineNr"> 807 </span> <span class="Constant">"run: effective address is 0x00000060 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L807" class="LineNr"> 807 </span> <span class="Constant">"run: effective address is 0x00000060 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L808" class="LineNr"> 808 </span> <span class="Constant">"run: popping value 0x00000030\n"</span> -<span id="L809" class="LineNr"> 809 </span> <span class="Constant">"run: incrementing <a href='010---vm.cc.html#L20'>ESP</a> to 0xbd000004\n"</span> +<span id="L809" class="LineNr"> 809 </span> <span class="Constant">"run: incrementing <a href='010---vm.cc.html#L14'>ESP</a> to 0xbd000004\n"</span> <span id="L810" class="LineNr"> 810 </span> <span class="Delimiter">);</span> <span id="L811" class="LineNr"> 811 </span><span class="Delimiter">}</span> <span id="L812" class="LineNr"> 812 </span> <span id="L813" class="LineNr"> 813 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L814" class="LineNr"> 814 </span><span class="Normal">case</span> <span class="Constant">0x8f</span>: <span class="Delimiter">{</span> <span class="Comment">// pop stack into r/m32</span> -<span id="L815" class="LineNr"> 815 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L815" class="LineNr"> 815 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L816" class="LineNr"> 816 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> subop = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L817" class="LineNr"> 817 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>subop<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L818" class="LineNr"> 818 </span> <span class="Normal">case</span> <span class="Constant">0</span>: <span class="Delimiter">{</span> @@ -888,8 +888,8 @@ if ('onhashchange' in window) { <span id="L829" class="LineNr"> 829 </span> <span id="L830" class="LineNr"> 830 </span><span class="Delimiter">:(code)</span> <span id="L831" class="LineNr"> 831 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L831'>test_add_r32_to_mem_at_displacement</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L832" class="LineNr"> 832 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> -<span id="L833" class="LineNr"> 833 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L832" class="LineNr"> 832 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> +<span id="L833" class="LineNr"> 833 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L834" class="LineNr"> 834 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L835" class="LineNr"> 835 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L836" class="LineNr"> 836 </span> <span class="Constant">" 01 1d 00 20 00 00 \n"</span> <span class="Comment">// add EBX to *0x2000</span> @@ -898,25 +898,25 @@ if ('onhashchange' in window) { <span id="L839" class="LineNr"> 839 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L840" class="LineNr"> 840 </span> <span class="Delimiter">);</span> <span id="L841" class="LineNr"> 841 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L842" class="LineNr"> 842 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L843" class="LineNr"> 843 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='040---tests.cc.html#L84'>disp32</a>)\n"</span> +<span id="L842" class="LineNr"> 842 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L843" class="LineNr"> 843 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='040---tests.cc.html#L82'>disp32</a>)\n"</span> <span id="L844" class="LineNr"> 844 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L845" class="LineNr"> 845 </span> <span class="Delimiter">);</span> <span id="L846" class="LineNr"> 846 </span><span class="Delimiter">}</span> <span id="L847" class="LineNr"> 847 </span> <span id="L848" class="LineNr"> 848 </span><span class="Delimiter">:(before "End Mod 0 Special-cases(addr)")</span> <span id="L849" class="LineNr"> 849 </span><span class="Normal">case</span> <span class="Constant">5</span>: <span class="Comment">// exception: mod 0b00 rm 0b101 => incoming disp32</span> -<span id="L850" class="LineNr"> 850 </span> addr = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L851" class="LineNr"> 851 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" (<a href='040---tests.cc.html#L84'>disp32</a>)"</span> << end<span class="Delimiter">();</span> +<span id="L850" class="LineNr"> 850 </span> addr = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L851" class="LineNr"> 851 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" (<a href='040---tests.cc.html#L82'>disp32</a>)"</span> << end<span class="Delimiter">();</span> <span id="L852" class="LineNr"> 852 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L853" class="LineNr"> 853 </span> <span id="L854" class="LineNr"> 854 </span><span class="Comment">//:</span> <span id="L855" class="LineNr"> 855 </span> <span id="L856" class="LineNr"> 856 </span><span class="Delimiter">:(code)</span> <span id="L857" class="LineNr"> 857 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L857'>test_add_r32_to_mem_at_r32_plus_disp8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L858" class="LineNr"> 858 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> -<span id="L859" class="LineNr"> 859 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x1ffe</span><span class="Delimiter">;</span> <span class="Comment">// dest</span> -<span id="L860" class="LineNr"> 860 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L858" class="LineNr"> 858 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> +<span id="L859" class="LineNr"> 859 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x1ffe</span><span class="Delimiter">;</span> <span class="Comment">// dest</span> +<span id="L860" class="LineNr"> 860 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L861" class="LineNr"> 861 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L862" class="LineNr"> 862 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L863" class="LineNr"> 863 </span> <span class="Constant">" 01 58 02 \n"</span> <span class="Comment">// add EBX to *(EAX+2)</span> @@ -925,8 +925,8 @@ if ('onhashchange' in window) { <span id="L866" class="LineNr"> 866 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L867" class="LineNr"> 867 </span> <span class="Delimiter">);</span> <span id="L868" class="LineNr"> 868 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L869" class="LineNr"> 869 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L870" class="LineNr"> 870 </span> <span class="Constant">"run: effective address is initially 0x00001ffe (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L869" class="LineNr"> 869 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L870" class="LineNr"> 870 </span> <span class="Constant">"run: effective address is initially 0x00001ffe (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L871" class="LineNr"> 871 </span> <span class="Constant">"run: effective address is 0x00002000 (after adding disp8)\n"</span> <span id="L872" class="LineNr"> 872 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L873" class="LineNr"> 873 </span> <span class="Delimiter">);</span> @@ -936,15 +936,15 @@ if ('onhashchange' in window) { <span id="L877" class="LineNr"> 877 </span><span class="Normal">case</span> <span class="Constant">1</span>: <span class="Delimiter">{</span> <span class="Comment">// indirect + disp8 addressing</span> <span id="L878" class="LineNr"> 878 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>rm<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L879" class="LineNr"> 879 </span> <span class="Normal">default</span>: -<span id="L880" class="LineNr"> 880 </span> addr = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[rm]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L881" class="LineNr"> 881 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is initially 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" ("</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rm<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> +<span id="L880" class="LineNr"> 880 </span> addr = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[rm]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L881" class="LineNr"> 881 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is initially 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" ("</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rm<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> <span id="L882" class="LineNr"> 882 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L883" class="LineNr"> 883 </span> <span class="Comment">// End Mod 1 Special-cases(addr)</span> <span id="L884" class="LineNr"> 884 </span> <span class="Delimiter">}</span> -<span id="L885" class="LineNr"> 885 </span> <span class="Normal">int8_t</span> displacement = <span class="Normal">static_cast</span><<span class="Normal">int8_t</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> +<span id="L885" class="LineNr"> 885 </span> <span class="Normal">int8_t</span> displacement = <span class="Normal">static_cast</span><<span class="Normal">int8_t</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> <span id="L886" class="LineNr"> 886 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>addr > <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L887" class="LineNr"> 887 </span> addr += displacement<span class="Delimiter">;</span> -<span id="L888" class="LineNr"> 888 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" (after adding disp8)"</span> << end<span class="Delimiter">();</span> +<span id="L888" class="LineNr"> 888 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" (after adding disp8)"</span> << end<span class="Delimiter">();</span> <span id="L889" class="LineNr"> 889 </span> <span class="Delimiter">}</span> <span id="L890" class="LineNr"> 890 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> <span id="L891" class="LineNr"> 891 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"null address; skipping displacement"</span> << end<span class="Delimiter">();</span> @@ -954,9 +954,9 @@ if ('onhashchange' in window) { <span id="L895" class="LineNr"> 895 </span> <span id="L896" class="LineNr"> 896 </span><span class="Delimiter">:(code)</span> <span id="L897" class="LineNr"> 897 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L897'>test_add_r32_to_mem_at_r32_plus_negative_disp8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L898" class="LineNr"> 898 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> -<span id="L899" class="LineNr"> 899 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2001</span><span class="Delimiter">;</span> <span class="Comment">// dest</span> -<span id="L900" class="LineNr"> 900 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L898" class="LineNr"> 898 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> +<span id="L899" class="LineNr"> 899 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2001</span><span class="Delimiter">;</span> <span class="Comment">// dest</span> +<span id="L900" class="LineNr"> 900 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L901" class="LineNr"> 901 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L902" class="LineNr"> 902 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L903" class="LineNr"> 903 </span> <span class="Constant">" 01 58 ff \n"</span> <span class="Comment">// add EBX to *(EAX-1)</span> @@ -965,8 +965,8 @@ if ('onhashchange' in window) { <span id="L906" class="LineNr"> 906 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L907" class="LineNr"> 907 </span> <span class="Delimiter">);</span> <span id="L908" class="LineNr"> 908 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L909" class="LineNr"> 909 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L910" class="LineNr"> 910 </span> <span class="Constant">"run: effective address is initially 0x00002001 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L909" class="LineNr"> 909 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L910" class="LineNr"> 910 </span> <span class="Constant">"run: effective address is initially 0x00002001 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L911" class="LineNr"> 911 </span> <span class="Constant">"run: effective address is 0x00002000 (after adding disp8)\n"</span> <span id="L912" class="LineNr"> 912 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L913" class="LineNr"> 913 </span> <span class="Delimiter">);</span> @@ -976,9 +976,9 @@ if ('onhashchange' in window) { <span id="L917" class="LineNr"> 917 </span> <span id="L918" class="LineNr"> 918 </span><span class="Delimiter">:(code)</span> <span id="L919" class="LineNr"> 919 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L919'>test_add_r32_to_mem_at_r32_plus_disp32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L920" class="LineNr"> 920 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> -<span id="L921" class="LineNr"> 921 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x1ffe</span><span class="Delimiter">;</span> <span class="Comment">// dest</span> -<span id="L922" class="LineNr"> 922 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L920" class="LineNr"> 920 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> +<span id="L921" class="LineNr"> 921 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x1ffe</span><span class="Delimiter">;</span> <span class="Comment">// dest</span> +<span id="L922" class="LineNr"> 922 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L923" class="LineNr"> 923 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L924" class="LineNr"> 924 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L925" class="LineNr"> 925 </span> <span class="Constant">" 01 98 02 00 00 00 \n"</span> <span class="Comment">// add EBX to *(EAX+2)</span> @@ -987,9 +987,9 @@ if ('onhashchange' in window) { <span id="L928" class="LineNr"> 928 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L929" class="LineNr"> 929 </span> <span class="Delimiter">);</span> <span id="L930" class="LineNr"> 930 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L931" class="LineNr"> 931 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L932" class="LineNr"> 932 </span> <span class="Constant">"run: effective address is initially 0x00001ffe (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L933" class="LineNr"> 933 </span> <span class="Constant">"run: effective address is 0x00002000 (after adding <a href='040---tests.cc.html#L84'>disp32</a>)\n"</span> +<span id="L931" class="LineNr"> 931 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L932" class="LineNr"> 932 </span> <span class="Constant">"run: effective address is initially 0x00001ffe (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L933" class="LineNr"> 933 </span> <span class="Constant">"run: effective address is 0x00002000 (after adding <a href='040---tests.cc.html#L82'>disp32</a>)\n"</span> <span id="L934" class="LineNr"> 934 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L935" class="LineNr"> 935 </span> <span class="Delimiter">);</span> <span id="L936" class="LineNr"> 936 </span><span class="Delimiter">}</span> @@ -998,22 +998,22 @@ if ('onhashchange' in window) { <span id="L939" class="LineNr"> 939 </span><span class="Normal">case</span> <span class="Constant">2</span>: <span class="Comment">// indirect + disp32 addressing</span> <span id="L940" class="LineNr"> 940 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>rm<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L941" class="LineNr"> 941 </span> <span class="Normal">default</span>: -<span id="L942" class="LineNr"> 942 </span> addr = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[rm]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L943" class="LineNr"> 943 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is initially 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" ("</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rm<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> +<span id="L942" class="LineNr"> 942 </span> addr = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[rm]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L943" class="LineNr"> 943 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is initially 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" ("</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rm<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> <span id="L944" class="LineNr"> 944 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L945" class="LineNr"> 945 </span> <span class="Comment">// End Mod 2 Special-cases(addr)</span> <span id="L946" class="LineNr"> 946 </span> <span class="Delimiter">}</span> <span id="L947" class="LineNr"> 947 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>addr > <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L948" class="LineNr"> 948 </span> addr += <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L949" class="LineNr"> 949 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" (after adding <a href='040---tests.cc.html#L84'>disp32</a>)"</span> << end<span class="Delimiter">();</span> +<span id="L948" class="LineNr"> 948 </span> addr += <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L949" class="LineNr"> 949 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" (after adding <a href='040---tests.cc.html#L82'>disp32</a>)"</span> << end<span class="Delimiter">();</span> <span id="L950" class="LineNr"> 950 </span> <span class="Delimiter">}</span> <span id="L951" class="LineNr"> 951 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L952" class="LineNr"> 952 </span> <span id="L953" class="LineNr"> 953 </span><span class="Delimiter">:(code)</span> <span id="L954" class="LineNr"> 954 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L954'>test_add_r32_to_mem_at_r32_plus_negative_disp32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L955" class="LineNr"> 955 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> -<span id="L956" class="LineNr"> 956 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2001</span><span class="Delimiter">;</span> <span class="Comment">// dest</span> -<span id="L957" class="LineNr"> 957 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L955" class="LineNr"> 955 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> +<span id="L956" class="LineNr"> 956 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2001</span><span class="Delimiter">;</span> <span class="Comment">// dest</span> +<span id="L957" class="LineNr"> 957 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L958" class="LineNr"> 958 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L959" class="LineNr"> 959 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L960" class="LineNr"> 960 </span> <span class="Constant">" 01 98 ff ff ff ff \n"</span> <span class="Comment">// add EBX to *(EAX-1)</span> @@ -1022,9 +1022,9 @@ if ('onhashchange' in window) { <span id="L963" class="LineNr"> 963 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L964" class="LineNr"> 964 </span> <span class="Delimiter">);</span> <span id="L965" class="LineNr"> 965 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L966" class="LineNr"> 966 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L967" class="LineNr"> 967 </span> <span class="Constant">"run: effective address is initially 0x00002001 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> -<span id="L968" class="LineNr"> 968 </span> <span class="Constant">"run: effective address is 0x00002000 (after adding <a href='040---tests.cc.html#L84'>disp32</a>)\n"</span> +<span id="L966" class="LineNr"> 966 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L967" class="LineNr"> 967 </span> <span class="Constant">"run: effective address is initially 0x00002001 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> +<span id="L968" class="LineNr"> 968 </span> <span class="Constant">"run: effective address is 0x00002000 (after adding <a href='040---tests.cc.html#L82'>disp32</a>)\n"</span> <span id="L969" class="LineNr"> 969 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L970" class="LineNr"> 970 </span> <span class="Delimiter">);</span> <span id="L971" class="LineNr"> 971 </span><span class="Delimiter">}</span> @@ -1032,12 +1032,12 @@ if ('onhashchange' in window) { <span id="L973" class="LineNr"> 973 </span><span class="SalientComment">//:: copy address (lea)</span> <span id="L974" class="LineNr"> 974 </span> <span id="L975" class="LineNr"> 975 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L976" class="LineNr"> 976 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"8d"</span><span class="Delimiter">,</span> <span class="Constant">"copy address in rm32 into r32 (lea)"</span><span class="Delimiter">);</span> +<span id="L976" class="LineNr"> 976 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"8d"</span><span class="Delimiter">,</span> <span class="Constant">"copy address in rm32 into r32 (lea)"</span><span class="Delimiter">);</span> <span id="L977" class="LineNr"> 977 </span> <span id="L978" class="LineNr"> 978 </span><span class="Delimiter">:(code)</span> <span id="L979" class="LineNr"> 979 </span><span class="Normal">void</span> <a href='014indirect_addressing.cc.html#L979'>test_copy_address</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L980" class="LineNr"> 980 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L981" class="LineNr"> 981 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L980" class="LineNr"> 980 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L981" class="LineNr"> 981 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L982" class="LineNr"> 982 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L983" class="LineNr"> 983 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L984" class="LineNr"> 984 </span> <span class="Constant">" 8d 18 \n"</span> <span class="Comment">// copy address in EAX into EBX</span> @@ -1045,16 +1045,16 @@ if ('onhashchange' in window) { <span id="L986" class="LineNr"> 986 </span> <span class="Delimiter">);</span> <span id="L987" class="LineNr"> 987 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L988" class="LineNr"> 988 </span> <span class="Constant">"run: copy address into EBX\n"</span> -<span id="L989" class="LineNr"> 989 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L989" class="LineNr"> 989 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L990" class="LineNr"> 990 </span> <span class="Delimiter">);</span> <span id="L991" class="LineNr"> 991 </span><span class="Delimiter">}</span> <span id="L992" class="LineNr"> 992 </span> <span id="L993" class="LineNr"> 993 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L994" class="LineNr"> 994 </span><span class="Normal">case</span> <span class="Constant">0x8d</span>: <span class="Delimiter">{</span> <span class="Comment">// copy address of m32 to r32</span> -<span id="L995" class="LineNr"> 995 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L995" class="LineNr"> 995 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L996" class="LineNr"> 996 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> arg1 = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L997" class="LineNr"> 997 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy address into "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>arg1<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L998" class="LineNr"> 998 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[arg1]<span class="Delimiter">.</span>u = <a href='013direct_addressing.cc.html#L116'>effective_address_number</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> +<span id="L998" class="LineNr"> 998 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[arg1]<span class="Delimiter">.</span>u = <a href='013direct_addressing.cc.html#L116'>effective_address_number</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> <span id="L999" class="LineNr"> 999 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1000" class="LineNr">1000 </span><span class="Delimiter">}</span> </pre> diff --git a/html/015immediate_addressing.cc.html b/html/015immediate_addressing.cc.html index c5d39b5e..31f25c72 100644 --- a/html/015immediate_addressing.cc.html +++ b/html/015immediate_addressing.cc.html @@ -62,32 +62,32 @@ if ('onhashchange' in window) { <span id="L1" class="LineNr"> 1 </span><span class="Comment">//: instructions that (immediately) contain an argument to act with</span> <span id="L2" class="LineNr"> 2 </span> <span id="L3" class="LineNr"> 3 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L4" class="LineNr"> 4 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"05"</span><span class="Delimiter">,</span> <span class="Constant">"add imm32 to <a href='010---vm.cc.html#L16'>EAX</a> (add)"</span><span class="Delimiter">);</span> +<span id="L4" class="LineNr"> 4 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"05"</span><span class="Delimiter">,</span> <span class="Constant">"add imm32 to <a href='010---vm.cc.html#L10'>EAX</a> (add)"</span><span class="Delimiter">);</span> <span id="L5" class="LineNr"> 5 </span> <span id="L6" class="LineNr"> 6 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L7" class="LineNr"> 7 </span><span class="Normal">case</span> <span class="Constant">0x05</span>: <span class="Delimiter">{</span> <span class="Comment">// add imm32 to EAX</span> -<span id="L8" class="LineNr"> 8 </span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L9" class="LineNr"> 9 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"add imm32 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << signed_arg2 << <span class="Constant">" to EAX"</span> << end<span class="Delimiter">();</span> -<span id="L10" class="LineNr"> 10 </span> <span class="Normal">int32_t</span> signed_result = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i + signed_arg2<span class="Delimiter">;</span> +<span id="L8" class="LineNr"> 8 </span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L9" class="LineNr"> 9 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"add imm32 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << signed_arg2 << <span class="Constant">" to EAX"</span> << end<span class="Delimiter">();</span> +<span id="L10" class="LineNr"> 10 </span> <span class="Normal">int32_t</span> signed_result = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i + signed_arg2<span class="Delimiter">;</span> <span id="L11" class="LineNr"> 11 </span> SF = <span class="Delimiter">(</span>signed_result < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L12" class="LineNr"> 12 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L13" class="LineNr"> 13 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> + signed_arg2<span class="Delimiter">;</span> -<span id="L14" class="LineNr"> 14 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> +<span id="L12" class="LineNr"> 12 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L13" class="LineNr"> 13 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> + signed_arg2<span class="Delimiter">;</span> +<span id="L14" class="LineNr"> 14 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> <span id="L15" class="LineNr"> 15 </span> <span class="Comment">// set CF</span> <span id="L16" class="LineNr"> 16 </span> <span class="Normal">uint32_t</span> unsigned_arg2 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>signed_arg2<span class="Delimiter">);</span> -<span id="L17" class="LineNr"> 17 </span> <span class="Normal">uint32_t</span> unsigned_result = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u + unsigned_arg2<span class="Delimiter">;</span> -<span id="L18" class="LineNr"> 18 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> + unsigned_arg2<span class="Delimiter">;</span> -<span id="L19" class="LineNr"> 19 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> -<span id="L20" class="LineNr"> 20 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> -<span id="L21" class="LineNr"> 21 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = signed_result<span class="Delimiter">;</span> -<span id="L22" class="LineNr"> 22 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L17" class="LineNr"> 17 </span> <span class="Normal">uint32_t</span> unsigned_result = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u + unsigned_arg2<span class="Delimiter">;</span> +<span id="L18" class="LineNr"> 18 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> + unsigned_arg2<span class="Delimiter">;</span> +<span id="L19" class="LineNr"> 19 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> +<span id="L20" class="LineNr"> 20 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> +<span id="L21" class="LineNr"> 21 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = signed_result<span class="Delimiter">;</span> +<span id="L22" class="LineNr"> 22 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> <span id="L23" class="LineNr"> 23 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L24" class="LineNr"> 24 </span><span class="Delimiter">}</span> <span id="L25" class="LineNr"> 25 </span> <span id="L26" class="LineNr"> 26 </span><span class="Delimiter">:(code)</span> <span id="L27" class="LineNr"> 27 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L27'>test_add_imm32_to_EAX_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L28" class="LineNr"> 28 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> -<span id="L29" class="LineNr"> 29 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L28" class="LineNr"> 28 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> +<span id="L29" class="LineNr"> 29 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L30" class="LineNr"> 30 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L31" class="LineNr"> 31 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L32" class="LineNr"> 32 </span> <span class="Constant">" 05 01 00 00 00 \n"</span> <span class="Comment">// add 1 to EAX</span> @@ -100,9 +100,9 @@ if ('onhashchange' in window) { <span id="L39" class="LineNr"> 39 </span><span class="Delimiter">}</span> <span id="L40" class="LineNr"> 40 </span> <span id="L41" class="LineNr"> 41 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L41'>test_add_imm32_to_EAX_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L42" class="LineNr"> 42 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest unsigned number</span> -<span id="L43" class="LineNr"> 43 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L44" class="LineNr"> 44 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L42" class="LineNr"> 42 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest unsigned number</span> +<span id="L43" class="LineNr"> 43 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L44" class="LineNr"> 44 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L45" class="LineNr"> 45 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L46" class="LineNr"> 46 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L47" class="LineNr"> 47 </span> <span class="Constant">" 05 01 00 00 00 \n"</span> <span class="Comment">// add 1 to EAX</span> @@ -115,8 +115,8 @@ if ('onhashchange' in window) { <span id="L54" class="LineNr"> 54 </span><span class="Delimiter">}</span> <span id="L55" class="LineNr"> 55 </span> <span id="L56" class="LineNr"> 56 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L56'>test_add_imm32_to_EAX_unsigned_and_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L57" class="LineNr"> 57 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> -<span id="L58" class="LineNr"> 58 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L57" class="LineNr"> 57 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> +<span id="L58" class="LineNr"> 58 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L59" class="LineNr"> 59 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L60" class="LineNr"> 60 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L61" class="LineNr"> 61 </span> <span class="Constant">" 05 00 00 00 80 \n"</span> <span class="Comment">// add 0x80000000 to EAX</span> @@ -131,12 +131,12 @@ if ('onhashchange' in window) { <span id="L70" class="LineNr"> 70 </span><span class="Comment">//:</span> <span id="L71" class="LineNr"> 71 </span> <span id="L72" class="LineNr"> 72 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L73" class="LineNr"> 73 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"81"</span><span class="Delimiter">,</span> <span class="Constant">"combine rm32 with imm32 based on subop (add/sub/and/or/xor/cmp)"</span><span class="Delimiter">);</span> +<span id="L73" class="LineNr"> 73 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"81"</span><span class="Delimiter">,</span> <span class="Constant">"combine rm32 with imm32 based on subop (add/sub/and/or/xor/cmp)"</span><span class="Delimiter">);</span> <span id="L74" class="LineNr"> 74 </span> <span id="L75" class="LineNr"> 75 </span><span class="Delimiter">:(code)</span> <span id="L76" class="LineNr"> 76 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L76'>test_add_imm32_to_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L77" class="LineNr"> 77 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L78" class="LineNr"> 78 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L77" class="LineNr"> 77 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L78" class="LineNr"> 78 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L79" class="LineNr"> 79 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L80" class="LineNr"> 80 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L81" class="LineNr"> 81 </span> <span class="Constant">" 81 c3 0a 0b 0c 0d\n"</span> <span class="Comment">// add 0x0d0c0b0a to EBX</span> @@ -154,33 +154,33 @@ if ('onhashchange' in window) { <span id="L93" class="LineNr"> 93 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L94" class="LineNr"> 94 </span><span class="Normal">case</span> <span class="Constant">0x81</span>: <span class="Delimiter">{</span> <span class="Comment">// combine r/m32 with imm32</span> <span id="L95" class="LineNr"> 95 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"combine r/m32 with imm32"</span> << end<span class="Delimiter">();</span> -<span id="L96" class="LineNr"> 96 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L96" class="LineNr"> 96 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L97" class="LineNr"> 97 </span> <span class="Normal">int32_t</span>* signed_arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L98" class="LineNr"> 98 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L99" class="LineNr"> 99 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"imm32 is 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << signed_arg2 << end<span class="Delimiter">();</span> +<span id="L98" class="LineNr"> 98 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L99" class="LineNr"> 99 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"imm32 is 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << signed_arg2 << end<span class="Delimiter">();</span> <span id="L100" class="LineNr"> 100 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> subop = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span class="Comment">// middle 3 'reg opcode' bits</span> <span id="L101" class="LineNr"> 101 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>subop<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L102" class="LineNr"> 102 </span> <span class="Normal">case</span> <span class="Constant">0</span>: <span class="Delimiter">{</span> <span id="L103" class="LineNr"> 103 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop add"</span> << end<span class="Delimiter">();</span> <span id="L104" class="LineNr"> 104 </span> <span class="Normal">int32_t</span> signed_result = *signed_arg1 + signed_arg2<span class="Delimiter">;</span> <span id="L105" class="LineNr"> 105 </span> SF = <span class="Delimiter">(</span>signed_result < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L106" class="LineNr"> 106 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L106" class="LineNr"> 106 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L107" class="LineNr"> 107 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">)</span> + signed_arg2<span class="Delimiter">;</span> -<span id="L108" class="LineNr"> 108 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> +<span id="L108" class="LineNr"> 108 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> <span id="L109" class="LineNr"> 109 </span> <span class="Comment">// set CF</span> <span id="L110" class="LineNr"> 110 </span> <span class="Normal">uint32_t</span> unsigned_arg1 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">);</span> <span id="L111" class="LineNr"> 111 </span> <span class="Normal">uint32_t</span> unsigned_arg2 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>signed_arg2<span class="Delimiter">);</span> <span id="L112" class="LineNr"> 112 </span> <span class="Normal">uint32_t</span> unsigned_result = unsigned_arg1 + unsigned_arg2<span class="Delimiter">;</span> <span id="L113" class="LineNr"> 113 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span>unsigned_arg1<span class="Delimiter">)</span> + unsigned_arg2<span class="Delimiter">;</span> -<span id="L114" class="LineNr"> 114 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> -<span id="L115" class="LineNr"> 115 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L114" class="LineNr"> 114 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> +<span id="L115" class="LineNr"> 115 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L116" class="LineNr"> 116 </span> *signed_arg1 = signed_result<span class="Delimiter">;</span> -<span id="L117" class="LineNr"> 117 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> +<span id="L117" class="LineNr"> 117 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> <span id="L118" class="LineNr"> 118 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L119" class="LineNr"> 119 </span> <span class="Delimiter">}</span> <span id="L120" class="LineNr"> 120 </span> <span class="Comment">// End Op 81 Subops</span> <span id="L121" class="LineNr"> 121 </span> <span class="Normal">default</span>: -<span id="L122" class="LineNr"> 122 </span> cerr << <span class="Constant">"unrecognized subop for opcode 81: "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L122" class="LineNr"> 122 </span> cerr << <span class="Constant">"unrecognized subop for opcode 81: "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span id="L123" class="LineNr"> 123 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L124" class="LineNr"> 124 </span> <span class="Delimiter">}</span> <span id="L125" class="LineNr"> 125 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -188,8 +188,8 @@ if ('onhashchange' in window) { <span id="L127" class="LineNr"> 127 </span> <span id="L128" class="LineNr"> 128 </span><span class="Delimiter">:(code)</span> <span id="L129" class="LineNr"> 129 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L129'>test_add_imm32_to_r32_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L130" class="LineNr"> 130 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> -<span id="L131" class="LineNr"> 131 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L130" class="LineNr"> 130 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> +<span id="L131" class="LineNr"> 131 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L132" class="LineNr"> 132 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L133" class="LineNr"> 133 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L134" class="LineNr"> 134 </span> <span class="Constant">" 81 c3 01 00 00 00\n"</span> <span class="Comment">// add 1 to EBX</span> @@ -206,8 +206,8 @@ if ('onhashchange' in window) { <span id="L145" class="LineNr"> 145 </span><span class="Delimiter">}</span> <span id="L146" class="LineNr"> 146 </span> <span id="L147" class="LineNr"> 147 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L147'>test_add_imm32_to_r32_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L148" class="LineNr"> 148 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest unsigned number</span> -<span id="L149" class="LineNr"> 149 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L148" class="LineNr"> 148 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest unsigned number</span> +<span id="L149" class="LineNr"> 149 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L150" class="LineNr"> 150 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L151" class="LineNr"> 151 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L152" class="LineNr"> 152 </span> <span class="Constant">" 81 c3 01 00 00 00\n"</span> <span class="Comment">// add 1 to EBX</span> @@ -224,8 +224,8 @@ if ('onhashchange' in window) { <span id="L163" class="LineNr"> 163 </span><span class="Delimiter">}</span> <span id="L164" class="LineNr"> 164 </span> <span id="L165" class="LineNr"> 165 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L165'>test_add_imm32_to_r32_unsigned_and_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L166" class="LineNr"> 166 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> -<span id="L167" class="LineNr"> 167 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L166" class="LineNr"> 166 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> +<span id="L167" class="LineNr"> 167 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L168" class="LineNr"> 168 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L169" class="LineNr"> 169 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L170" class="LineNr"> 170 </span> <span class="Constant">" 81 c3 00 00 00 80\n"</span> <span class="Comment">// add 0x80000000 to EBX</span> @@ -245,8 +245,8 @@ if ('onhashchange' in window) { <span id="L184" class="LineNr"> 184 </span> <span id="L185" class="LineNr"> 185 </span><span class="Delimiter">:(code)</span> <span id="L186" class="LineNr"> 186 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L186'>test_add_imm32_to_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L187" class="LineNr"> 187 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L188" class="LineNr"> 188 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L187" class="LineNr"> 187 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L188" class="LineNr"> 188 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L189" class="LineNr"> 189 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L190" class="LineNr"> 190 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L191" class="LineNr"> 191 </span> <span class="Constant">" 81 03 0a 0b 0c 0d \n"</span> <span class="Comment">// add 0x0d0c0b0a to *EBX</span> @@ -256,7 +256,7 @@ if ('onhashchange' in window) { <span id="L195" class="LineNr"> 195 </span> <span class="Delimiter">);</span> <span id="L196" class="LineNr"> 196 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L197" class="LineNr"> 197 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L198" class="LineNr"> 198 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> +<span id="L198" class="LineNr"> 198 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> <span id="L199" class="LineNr"> 199 </span> <span class="Constant">"run: imm32 is 0x0d0c0b0a\n"</span> <span id="L200" class="LineNr"> 200 </span> <span class="Constant">"run: subop add\n"</span> <span id="L201" class="LineNr"> 201 </span> <span class="Constant">"run: storing 0x0d0c0b0b\n"</span> @@ -266,12 +266,12 @@ if ('onhashchange' in window) { <span id="L205" class="LineNr"> 205 </span><span class="SalientComment">//:: subtract</span> <span id="L206" class="LineNr"> 206 </span> <span id="L207" class="LineNr"> 207 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L208" class="LineNr"> 208 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"2d"</span><span class="Delimiter">,</span> <span class="Constant">"subtract imm32 from <a href='010---vm.cc.html#L16'>EAX</a> (sub)"</span><span class="Delimiter">);</span> +<span id="L208" class="LineNr"> 208 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"2d"</span><span class="Delimiter">,</span> <span class="Constant">"subtract imm32 from <a href='010---vm.cc.html#L10'>EAX</a> (sub)"</span><span class="Delimiter">);</span> <span id="L209" class="LineNr"> 209 </span> <span id="L210" class="LineNr"> 210 </span><span class="Delimiter">:(code)</span> <span id="L211" class="LineNr"> 211 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L211'>test_subtract_imm32_from_EAX</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L212" class="LineNr"> 212 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0baa</span><span class="Delimiter">;</span> -<span id="L213" class="LineNr"> 213 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L212" class="LineNr"> 212 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0baa</span><span class="Delimiter">;</span> +<span id="L213" class="LineNr"> 213 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L214" class="LineNr"> 214 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L215" class="LineNr"> 215 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L216" class="LineNr"> 216 </span> <span class="Constant">" 2d 0a 0b 0c 0d \n"</span> <span class="Comment">// subtract 0x0d0c0b0a from EAX</span> @@ -284,28 +284,28 @@ if ('onhashchange' in window) { <span id="L223" class="LineNr"> 223 </span> <span id="L224" class="LineNr"> 224 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L225" class="LineNr"> 225 </span><span class="Normal">case</span> <span class="Constant">0x2d</span>: <span class="Delimiter">{</span> <span class="Comment">// subtract imm32 from EAX</span> -<span id="L226" class="LineNr"> 226 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L227" class="LineNr"> 227 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subtract imm32 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << signed_arg2 << <span class="Constant">" from EAX"</span> << end<span class="Delimiter">();</span> -<span id="L228" class="LineNr"> 228 </span> <span class="Normal">int32_t</span> signed_result = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i - signed_arg2<span class="Delimiter">;</span> +<span id="L226" class="LineNr"> 226 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L227" class="LineNr"> 227 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subtract imm32 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << signed_arg2 << <span class="Constant">" from EAX"</span> << end<span class="Delimiter">();</span> +<span id="L228" class="LineNr"> 228 </span> <span class="Normal">int32_t</span> signed_result = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i - signed_arg2<span class="Delimiter">;</span> <span id="L229" class="LineNr"> 229 </span> SF = <span class="Delimiter">(</span>signed_result < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L230" class="LineNr"> 230 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L231" class="LineNr"> 231 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> - signed_arg2<span class="Delimiter">;</span> -<span id="L232" class="LineNr"> 232 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> +<span id="L230" class="LineNr"> 230 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L231" class="LineNr"> 231 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i<span class="Delimiter">)</span> - signed_arg2<span class="Delimiter">;</span> +<span id="L232" class="LineNr"> 232 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> <span id="L233" class="LineNr"> 233 </span> <span class="Comment">// set CF</span> <span id="L234" class="LineNr"> 234 </span> <span class="Normal">uint32_t</span> unsigned_arg2 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>signed_arg2<span class="Delimiter">);</span> -<span id="L235" class="LineNr"> 235 </span> <span class="Normal">uint32_t</span> unsigned_result = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u - unsigned_arg2<span class="Delimiter">;</span> -<span id="L236" class="LineNr"> 236 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> - unsigned_arg2<span class="Delimiter">;</span> -<span id="L237" class="LineNr"> 237 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> -<span id="L238" class="LineNr"> 238 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> -<span id="L239" class="LineNr"> 239 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = signed_result<span class="Delimiter">;</span> -<span id="L240" class="LineNr"> 240 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L235" class="LineNr"> 235 </span> <span class="Normal">uint32_t</span> unsigned_result = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u - unsigned_arg2<span class="Delimiter">;</span> +<span id="L236" class="LineNr"> 236 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> - unsigned_arg2<span class="Delimiter">;</span> +<span id="L237" class="LineNr"> 237 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> +<span id="L238" class="LineNr"> 238 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> +<span id="L239" class="LineNr"> 239 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = signed_result<span class="Delimiter">;</span> +<span id="L240" class="LineNr"> 240 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> <span id="L241" class="LineNr"> 241 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L242" class="LineNr"> 242 </span><span class="Delimiter">}</span> <span id="L243" class="LineNr"> 243 </span> <span id="L244" class="LineNr"> 244 </span><span class="Delimiter">:(code)</span> <span id="L245" class="LineNr"> 245 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L245'>test_subtract_imm32_from_EAX_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L246" class="LineNr"> 246 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> -<span id="L247" class="LineNr"> 247 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L246" class="LineNr"> 246 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x80000000</span><span class="Delimiter">;</span> <span class="Comment">// smallest negative signed integer</span> +<span id="L247" class="LineNr"> 247 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L248" class="LineNr"> 248 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L249" class="LineNr"> 249 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L250" class="LineNr"> 250 </span> <span class="Constant">" 2d ff ff ff 7f \n"</span> <span class="Comment">// subtract largest positive signed integer from EAX</span> @@ -318,8 +318,8 @@ if ('onhashchange' in window) { <span id="L257" class="LineNr"> 257 </span><span class="Delimiter">}</span> <span id="L258" class="LineNr"> 258 </span> <span id="L259" class="LineNr"> 259 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L259'>test_subtract_imm32_from_EAX_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L260" class="LineNr"> 260 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L261" class="LineNr"> 261 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L260" class="LineNr"> 260 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L261" class="LineNr"> 261 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L262" class="LineNr"> 262 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L263" class="LineNr"> 263 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L264" class="LineNr"> 264 </span> <span class="Constant">" 2d 01 00 00 00 \n"</span> <span class="Comment">// subtract 1 from EAX</span> @@ -332,8 +332,8 @@ if ('onhashchange' in window) { <span id="L271" class="LineNr"> 271 </span><span class="Delimiter">}</span> <span id="L272" class="LineNr"> 272 </span> <span id="L273" class="LineNr"> 273 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L273'>test_subtract_imm32_from_EAX_signed_and_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L274" class="LineNr"> 274 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L275" class="LineNr"> 275 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L274" class="LineNr"> 274 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L275" class="LineNr"> 275 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L276" class="LineNr"> 276 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L277" class="LineNr"> 277 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L278" class="LineNr"> 278 </span> <span class="Constant">" 2d 00 00 00 80 \n"</span> <span class="Comment">// subtract smallest negative signed integer from EAX</span> @@ -348,8 +348,8 @@ if ('onhashchange' in window) { <span id="L287" class="LineNr"> 287 </span><span class="Comment">//:</span> <span id="L288" class="LineNr"> 288 </span> <span id="L289" class="LineNr"> 289 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L289'>test_subtract_imm32_from_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L290" class="LineNr"> 290 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L291" class="LineNr"> 291 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L290" class="LineNr"> 290 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L291" class="LineNr"> 291 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L292" class="LineNr"> 292 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L293" class="LineNr"> 293 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L294" class="LineNr"> 294 </span> <span class="Constant">" 81 2b 01 00 00 00 \n"</span> <span class="Comment">// subtract 1 from *EBX</span> @@ -359,7 +359,7 @@ if ('onhashchange' in window) { <span id="L298" class="LineNr"> 298 </span> <span class="Delimiter">);</span> <span id="L299" class="LineNr"> 299 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L300" class="LineNr"> 300 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L301" class="LineNr"> 301 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> +<span id="L301" class="LineNr"> 301 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> <span id="L302" class="LineNr"> 302 </span> <span class="Constant">"run: imm32 is 0x00000001\n"</span> <span id="L303" class="LineNr"> 303 </span> <span class="Constant">"run: subop subtract\n"</span> <span id="L304" class="LineNr"> 304 </span> <span class="Constant">"run: storing 0x00000009\n"</span> @@ -371,25 +371,25 @@ if ('onhashchange' in window) { <span id="L310" class="LineNr"> 310 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop subtract"</span> << end<span class="Delimiter">();</span> <span id="L311" class="LineNr"> 311 </span> <span class="Normal">int32_t</span> signed_result = *signed_arg1 - signed_arg2<span class="Delimiter">;</span> <span id="L312" class="LineNr"> 312 </span> SF = <span class="Delimiter">(</span>signed_result < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L313" class="LineNr"> 313 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L313" class="LineNr"> 313 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_result == <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L314" class="LineNr"> 314 </span> <span class="Normal">int64_t</span> signed_full_result = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">)</span> - signed_arg2<span class="Delimiter">;</span> -<span id="L315" class="LineNr"> 315 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> +<span id="L315" class="LineNr"> 315 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_result != signed_full_result<span class="Delimiter">);</span> <span id="L316" class="LineNr"> 316 </span> <span class="Comment">// set CF</span> <span id="L317" class="LineNr"> 317 </span> <span class="Normal">uint32_t</span> unsigned_arg1 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">);</span> <span id="L318" class="LineNr"> 318 </span> <span class="Normal">uint32_t</span> unsigned_arg2 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>signed_arg2<span class="Delimiter">);</span> <span id="L319" class="LineNr"> 319 </span> <span class="Normal">uint32_t</span> unsigned_result = unsigned_arg1 - unsigned_arg2<span class="Delimiter">;</span> <span id="L320" class="LineNr"> 320 </span> <span class="Normal">uint64_t</span> unsigned_full_result = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span>unsigned_arg1<span class="Delimiter">)</span> - unsigned_arg2<span class="Delimiter">;</span> -<span id="L321" class="LineNr"> 321 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> -<span id="L322" class="LineNr"> 322 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L321" class="LineNr"> 321 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_result != unsigned_full_result<span class="Delimiter">);</span> +<span id="L322" class="LineNr"> 322 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L323" class="LineNr"> 323 </span> *signed_arg1 = signed_result<span class="Delimiter">;</span> -<span id="L324" class="LineNr"> 324 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> +<span id="L324" class="LineNr"> 324 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> <span id="L325" class="LineNr"> 325 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L326" class="LineNr"> 326 </span><span class="Delimiter">}</span> <span id="L327" class="LineNr"> 327 </span> <span id="L328" class="LineNr"> 328 </span><span class="Delimiter">:(code)</span> <span id="L329" class="LineNr"> 329 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L329'>test_subtract_imm32_from_mem_at_r32_signed_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L330" class="LineNr"> 330 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L331" class="LineNr"> 331 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L330" class="LineNr"> 330 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L331" class="LineNr"> 331 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L332" class="LineNr"> 332 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L333" class="LineNr"> 333 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L334" class="LineNr"> 334 </span> <span class="Constant">" 81 2b ff ff ff 7f \n"</span> <span class="Comment">// subtract largest positive signed integer from *EBX</span> @@ -399,8 +399,8 @@ if ('onhashchange' in window) { <span id="L338" class="LineNr"> 338 </span> <span class="Delimiter">);</span> <span id="L339" class="LineNr"> 339 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L340" class="LineNr"> 340 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L341" class="LineNr"> 341 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> -<span id="L342" class="LineNr"> 342 </span> <span class="Constant">"run: effective address contains 80000000\n"</span> +<span id="L341" class="LineNr"> 341 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> +<span id="L342" class="LineNr"> 342 </span> <span class="Constant">"run: effective address contains 0x80000000\n"</span> <span id="L343" class="LineNr"> 343 </span> <span class="Constant">"run: imm32 is 0x7fffffff\n"</span> <span id="L344" class="LineNr"> 344 </span> <span class="Constant">"run: subop subtract\n"</span> <span id="L345" class="LineNr"> 345 </span> <span class="Constant">"run: SF=0; ZF=0; CF=0; OF=1\n"</span> @@ -409,8 +409,8 @@ if ('onhashchange' in window) { <span id="L348" class="LineNr"> 348 </span><span class="Delimiter">}</span> <span id="L349" class="LineNr"> 349 </span> <span id="L350" class="LineNr"> 350 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L350'>test_subtract_imm32_from_mem_at_r32_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L351" class="LineNr"> 351 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L352" class="LineNr"> 352 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L351" class="LineNr"> 351 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L352" class="LineNr"> 352 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L353" class="LineNr"> 353 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L354" class="LineNr"> 354 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L355" class="LineNr"> 355 </span> <span class="Constant">" 81 2b 01 00 00 00 \n"</span> <span class="Comment">// subtract 1 from *EBX</span> @@ -420,8 +420,8 @@ if ('onhashchange' in window) { <span id="L359" class="LineNr"> 359 </span> <span class="Delimiter">);</span> <span id="L360" class="LineNr"> 360 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L361" class="LineNr"> 361 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L362" class="LineNr"> 362 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> -<span id="L363" class="LineNr"> 363 </span> <span class="Constant">"run: effective address contains 0\n"</span> +<span id="L362" class="LineNr"> 362 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> +<span id="L363" class="LineNr"> 363 </span> <span class="Constant">"run: effective address contains 0x00000000\n"</span> <span id="L364" class="LineNr"> 364 </span> <span class="Constant">"run: imm32 is 0x00000001\n"</span> <span id="L365" class="LineNr"> 365 </span> <span class="Constant">"run: subop subtract\n"</span> <span id="L366" class="LineNr"> 366 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=0\n"</span> @@ -430,8 +430,8 @@ if ('onhashchange' in window) { <span id="L369" class="LineNr"> 369 </span><span class="Delimiter">}</span> <span id="L370" class="LineNr"> 370 </span> <span id="L371" class="LineNr"> 371 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L371'>test_subtract_imm32_from_mem_at_r32_signed_and_unsigned_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L372" class="LineNr"> 372 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L373" class="LineNr"> 373 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L372" class="LineNr"> 372 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L373" class="LineNr"> 373 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L374" class="LineNr"> 374 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L375" class="LineNr"> 375 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L376" class="LineNr"> 376 </span> <span class="Constant">" 81 2b 00 00 00 80 \n"</span> <span class="Comment">// subtract smallest negative signed integer from *EBX</span> @@ -441,8 +441,8 @@ if ('onhashchange' in window) { <span id="L380" class="LineNr"> 380 </span> <span class="Delimiter">);</span> <span id="L381" class="LineNr"> 381 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L382" class="LineNr"> 382 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L383" class="LineNr"> 383 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> -<span id="L384" class="LineNr"> 384 </span> <span class="Constant">"run: effective address contains 0\n"</span> +<span id="L383" class="LineNr"> 383 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> +<span id="L384" class="LineNr"> 384 </span> <span class="Constant">"run: effective address contains 0x00000000\n"</span> <span id="L385" class="LineNr"> 385 </span> <span class="Constant">"run: imm32 is 0x80000000\n"</span> <span id="L386" class="LineNr"> 386 </span> <span class="Constant">"run: subop subtract\n"</span> <span id="L387" class="LineNr"> 387 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=1\n"</span> @@ -453,8 +453,8 @@ if ('onhashchange' in window) { <span id="L392" class="LineNr"> 392 </span><span class="Comment">//:</span> <span id="L393" class="LineNr"> 393 </span> <span id="L394" class="LineNr"> 394 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L394'>test_subtract_imm32_from_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L395" class="LineNr"> 395 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">10</span><span class="Delimiter">;</span> -<span id="L396" class="LineNr"> 396 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L395" class="LineNr"> 395 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">10</span><span class="Delimiter">;</span> +<span id="L396" class="LineNr"> 396 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L397" class="LineNr"> 397 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L398" class="LineNr"> 398 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L399" class="LineNr"> 399 </span> <span class="Constant">" 81 eb 01 00 00 00 \n"</span> <span class="Comment">// subtract 1 from EBX</span> @@ -472,12 +472,12 @@ if ('onhashchange' in window) { <span id="L411" class="LineNr"> 411 </span><span class="SalientComment">//:: shift left</span> <span id="L412" class="LineNr"> 412 </span> <span id="L413" class="LineNr"> 413 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L414" class="LineNr"> 414 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"c1"</span><span class="Delimiter">,</span> <span class="Constant">"shift rm32 by imm8 bits depending on subop (sal/sar/shl/shr)"</span><span class="Delimiter">);</span> +<span id="L414" class="LineNr"> 414 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"c1"</span><span class="Delimiter">,</span> <span class="Constant">"shift rm32 by imm8 bits depending on subop (sal/sar/shl/shr)"</span><span class="Delimiter">);</span> <span id="L415" class="LineNr"> 415 </span> <span id="L416" class="LineNr"> 416 </span><span class="Delimiter">:(code)</span> <span id="L417" class="LineNr"> 417 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L417'>test_shift_left_r32_with_imm8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L418" class="LineNr"> 418 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">13</span><span class="Delimiter">;</span> -<span id="L419" class="LineNr"> 419 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L418" class="LineNr"> 418 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">13</span><span class="Delimiter">;</span> +<span id="L419" class="LineNr"> 419 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L420" class="LineNr"> 420 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L421" class="LineNr"> 421 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L422" class="LineNr"> 422 </span> <span class="Constant">" c1 e3 01 \n"</span> <span class="Comment">// shift EBX left by 1 bit</span> @@ -493,31 +493,31 @@ if ('onhashchange' in window) { <span id="L432" class="LineNr"> 432 </span> <span id="L433" class="LineNr"> 433 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L434" class="LineNr"> 434 </span><span class="Normal">case</span> <span class="Constant">0xc1</span>: <span class="Delimiter">{</span> -<span id="L435" class="LineNr"> 435 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L435" class="LineNr"> 435 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L436" class="LineNr"> 436 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"operate on r/m32"</span> << end<span class="Delimiter">();</span> <span id="L437" class="LineNr"> 437 </span> <span class="Normal">int32_t</span>* arg1 = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> <span id="L438" class="LineNr"> 438 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> subop = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span class="Comment">// middle 3 'reg opcode' bits</span> <span id="L439" class="LineNr"> 439 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>subop<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L440" class="LineNr"> 440 </span> <span class="Normal">case</span> <span class="Constant">4</span>: <span class="Delimiter">{</span> <span class="Comment">// shift left r/m32 by CL</span> <span id="L441" class="LineNr"> 441 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: shift left by CL bits"</span> << end<span class="Delimiter">();</span> -<span id="L442" class="LineNr"> 442 </span> <span class="Normal">uint8_t</span> count = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">()</span> & <span class="Constant">0x1f</span><span class="Delimiter">;</span> +<span id="L442" class="LineNr"> 442 </span> <span class="Normal">uint8_t</span> count = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">()</span> & <span class="Constant">0x1f</span><span class="Delimiter">;</span> <span id="L443" class="LineNr"> 443 </span> <span class="Comment">// OF is only defined if count is 1</span> <span id="L444" class="LineNr"> 444 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>count == <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L445" class="LineNr"> 445 </span> <span class="Normal">bool</span> msb = <span class="Delimiter">(</span>*arg1 & <span class="Constant">0x80000000</span><span class="Delimiter">)</span> >> <span class="Constant">1</span><span class="Delimiter">;</span> <span id="L446" class="LineNr"> 446 </span> <span class="Normal">bool</span> pnsb = <span class="Delimiter">(</span>*arg1 & <span class="Constant">0x40000000</span><span class="Delimiter">);</span> -<span id="L447" class="LineNr"> 447 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>msb != pnsb<span class="Delimiter">);</span> +<span id="L447" class="LineNr"> 447 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>msb != pnsb<span class="Delimiter">);</span> <span id="L448" class="LineNr"> 448 </span> <span class="Delimiter">}</span> <span id="L449" class="LineNr"> 449 </span> *arg1 = <span class="Delimiter">(</span>*arg1 << count<span class="Delimiter">);</span> -<span id="L450" class="LineNr"> 450 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L450" class="LineNr"> 450 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L451" class="LineNr"> 451 </span> SF = <span class="Delimiter">(</span>*arg1 < <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L452" class="LineNr"> 452 </span> <span class="Comment">// CF undefined</span> -<span id="L453" class="LineNr"> 453 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> -<span id="L454" class="LineNr"> 454 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> +<span id="L453" class="LineNr"> 453 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> +<span id="L454" class="LineNr"> 454 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> <span id="L455" class="LineNr"> 455 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L456" class="LineNr"> 456 </span> <span class="Delimiter">}</span> <span id="L457" class="LineNr"> 457 </span> <span class="Comment">// End Op c1 Subops</span> <span id="L458" class="LineNr"> 458 </span> <span class="Normal">default</span>: -<span id="L459" class="LineNr"> 459 </span> cerr << <span class="Constant">"unrecognized subop for opcode c1: "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L459" class="LineNr"> 459 </span> cerr << <span class="Constant">"unrecognized subop for opcode c1: "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span id="L460" class="LineNr"> 460 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L461" class="LineNr"> 461 </span> <span class="Delimiter">}</span> <span id="L462" class="LineNr"> 462 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -527,8 +527,8 @@ if ('onhashchange' in window) { <span id="L466" class="LineNr"> 466 </span> <span id="L467" class="LineNr"> 467 </span><span class="Delimiter">:(code)</span> <span id="L468" class="LineNr"> 468 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L468'>test_shift_right_arithmetic_r32_with_imm8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L469" class="LineNr"> 469 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">26</span><span class="Delimiter">;</span> -<span id="L470" class="LineNr"> 470 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L469" class="LineNr"> 469 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">26</span><span class="Delimiter">;</span> +<span id="L470" class="LineNr"> 470 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L471" class="LineNr"> 471 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L472" class="LineNr"> 472 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L473" class="LineNr"> 473 </span> <span class="Constant">" c1 fb 01 \n"</span> <span class="Comment">// shift EBX right by 1 bit</span> @@ -545,24 +545,24 @@ if ('onhashchange' in window) { <span id="L484" class="LineNr"> 484 </span><span class="Delimiter">:(before "End Op c1 Subops")</span> <span id="L485" class="LineNr"> 485 </span><span class="Normal">case</span> <span class="Constant">7</span>: <span class="Delimiter">{</span> <span class="Comment">// shift right r/m32 by CL, preserving sign</span> <span id="L486" class="LineNr"> 486 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: shift right by CL bits, while preserving sign"</span> << end<span class="Delimiter">();</span> -<span id="L487" class="LineNr"> 487 </span> <span class="Normal">uint8_t</span> count = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">()</span> & <span class="Constant">0x1f</span><span class="Delimiter">;</span> +<span id="L487" class="LineNr"> 487 </span> <span class="Normal">uint8_t</span> count = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">()</span> & <span class="Constant">0x1f</span><span class="Delimiter">;</span> <span id="L488" class="LineNr"> 488 </span> <span class="Normal">int32_t</span> result = <span class="Delimiter">(</span>*arg1 >> count<span class="Delimiter">);</span> -<span id="L489" class="LineNr"> 489 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L489" class="LineNr"> 489 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L490" class="LineNr"> 490 </span> SF = <span class="Delimiter">(</span>*arg1 < <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L491" class="LineNr"> 491 </span> <span class="Comment">// OF is only defined if count is 1</span> -<span id="L492" class="LineNr"> 492 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>count == <span class="Constant">1</span><span class="Delimiter">)</span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L492" class="LineNr"> 492 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>count == <span class="Constant">1</span><span class="Delimiter">)</span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L493" class="LineNr"> 493 </span> <span class="Comment">// CF</span> -<span id="L494" class="LineNr"> 494 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">((</span>*arg1 >> <span class="Delimiter">(</span>count-<span class="Constant">1</span><span class="Delimiter">))</span> & <span class="Constant">0x1</span><span class="Delimiter">);</span> -<span id="L495" class="LineNr"> 495 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L494" class="LineNr"> 494 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">((</span>*arg1 >> <span class="Delimiter">(</span>count-<span class="Constant">1</span><span class="Delimiter">))</span> & <span class="Constant">0x1</span><span class="Delimiter">);</span> +<span id="L495" class="LineNr"> 495 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L496" class="LineNr"> 496 </span> *arg1 = result<span class="Delimiter">;</span> -<span id="L497" class="LineNr"> 497 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> +<span id="L497" class="LineNr"> 497 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> <span id="L498" class="LineNr"> 498 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L499" class="LineNr"> 499 </span><span class="Delimiter">}</span> <span id="L500" class="LineNr"> 500 </span> <span id="L501" class="LineNr"> 501 </span><span class="Delimiter">:(code)</span> <span id="L502" class="LineNr"> 502 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L502'>test_shift_right_arithmetic_odd_r32_with_imm8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L503" class="LineNr"> 503 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">27</span><span class="Delimiter">;</span> -<span id="L504" class="LineNr"> 504 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L503" class="LineNr"> 503 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">27</span><span class="Delimiter">;</span> +<span id="L504" class="LineNr"> 504 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L505" class="LineNr"> 505 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L506" class="LineNr"> 506 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L507" class="LineNr"> 507 </span> <span class="Constant">" c1 fb 01 \n"</span> <span class="Comment">// shift EBX right by 1 bit</span> @@ -579,8 +579,8 @@ if ('onhashchange' in window) { <span id="L518" class="LineNr"> 518 </span> <span id="L519" class="LineNr"> 519 </span><span class="Delimiter">:(code)</span> <span id="L520" class="LineNr"> 520 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L520'>test_shift_right_arithmetic_negative_r32_with_imm8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L521" class="LineNr"> 521 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xfffffffd</span><span class="Delimiter">;</span> <span class="Comment">// -3</span> -<span id="L522" class="LineNr"> 522 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L521" class="LineNr"> 521 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xfffffffd</span><span class="Delimiter">;</span> <span class="Comment">// -3</span> +<span id="L522" class="LineNr"> 522 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L523" class="LineNr"> 523 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L524" class="LineNr"> 524 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L525" class="LineNr"> 525 </span> <span class="Constant">" c1 fb 01 \n"</span> <span class="Comment">// shift EBX right by 1 bit, while preserving sign</span> @@ -599,8 +599,8 @@ if ('onhashchange' in window) { <span id="L538" class="LineNr"> 538 </span> <span id="L539" class="LineNr"> 539 </span><span class="Delimiter">:(code)</span> <span id="L540" class="LineNr"> 540 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L540'>test_shift_right_logical_r32_with_imm8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L541" class="LineNr"> 541 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">26</span><span class="Delimiter">;</span> -<span id="L542" class="LineNr"> 542 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L541" class="LineNr"> 541 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">26</span><span class="Delimiter">;</span> +<span id="L542" class="LineNr"> 542 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L543" class="LineNr"> 543 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L544" class="LineNr"> 544 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L545" class="LineNr"> 545 </span> <span class="Constant">" c1 eb 01 \n"</span> <span class="Comment">// shift EBX right by 1 bit, while padding zeroes</span> @@ -617,28 +617,28 @@ if ('onhashchange' in window) { <span id="L556" class="LineNr"> 556 </span><span class="Delimiter">:(before "End Op c1 Subops")</span> <span id="L557" class="LineNr"> 557 </span><span class="Normal">case</span> <span class="Constant">5</span>: <span class="Delimiter">{</span> <span class="Comment">// shift right r/m32 by CL, preserving sign</span> <span id="L558" class="LineNr"> 558 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop: shift right by CL bits, while padding zeroes"</span> << end<span class="Delimiter">();</span> -<span id="L559" class="LineNr"> 559 </span> <span class="Normal">uint8_t</span> count = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">()</span> & <span class="Constant">0x1f</span><span class="Delimiter">;</span> +<span id="L559" class="LineNr"> 559 </span> <span class="Normal">uint8_t</span> count = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">()</span> & <span class="Constant">0x1f</span><span class="Delimiter">;</span> <span id="L560" class="LineNr"> 560 </span> <span class="Comment">// OF is only defined if count is 1</span> <span id="L561" class="LineNr"> 561 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>count == <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L562" class="LineNr"> 562 </span> <span class="Normal">bool</span> msb = <span class="Delimiter">(</span>*arg1 & <span class="Constant">0x80000000</span><span class="Delimiter">)</span> >> <span class="Constant">1</span><span class="Delimiter">;</span> <span id="L563" class="LineNr"> 563 </span> <span class="Normal">bool</span> pnsb = <span class="Delimiter">(</span>*arg1 & <span class="Constant">0x40000000</span><span class="Delimiter">);</span> -<span id="L564" class="LineNr"> 564 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>msb != pnsb<span class="Delimiter">);</span> +<span id="L564" class="LineNr"> 564 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>msb != pnsb<span class="Delimiter">);</span> <span id="L565" class="LineNr"> 565 </span> <span class="Delimiter">}</span> <span id="L566" class="LineNr"> 566 </span> <span class="Normal">uint32_t</span>* uarg1 = <span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>arg1<span class="Delimiter">);</span> <span id="L567" class="LineNr"> 567 </span> *uarg1 = <span class="Delimiter">(</span>*uarg1 >> count<span class="Delimiter">);</span> -<span id="L568" class="LineNr"> 568 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*uarg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L568" class="LineNr"> 568 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*uarg1 == <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L569" class="LineNr"> 569 </span> <span class="Comment">// result is always positive by definition</span> <span id="L570" class="LineNr"> 570 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L571" class="LineNr"> 571 </span> <span class="Comment">// CF undefined</span> -<span id="L572" class="LineNr"> 572 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> -<span id="L573" class="LineNr"> 573 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> +<span id="L572" class="LineNr"> 572 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> +<span id="L573" class="LineNr"> 573 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *arg1 << end<span class="Delimiter">();</span> <span id="L574" class="LineNr"> 574 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L575" class="LineNr"> 575 </span><span class="Delimiter">}</span> <span id="L576" class="LineNr"> 576 </span> <span id="L577" class="LineNr"> 577 </span><span class="Delimiter">:(code)</span> <span id="L578" class="LineNr"> 578 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L578'>test_shift_right_logical_odd_r32_with_imm8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L579" class="LineNr"> 579 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">27</span><span class="Delimiter">;</span> -<span id="L580" class="LineNr"> 580 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L579" class="LineNr"> 579 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">27</span><span class="Delimiter">;</span> +<span id="L580" class="LineNr"> 580 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L581" class="LineNr"> 581 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L582" class="LineNr"> 582 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L583" class="LineNr"> 583 </span> <span class="Constant">" c1 eb 01 \n"</span> <span class="Comment">// shift EBX right by 1 bit, while padding zeroes</span> @@ -654,8 +654,8 @@ if ('onhashchange' in window) { <span id="L593" class="LineNr"> 593 </span> <span id="L594" class="LineNr"> 594 </span><span class="Delimiter">:(code)</span> <span id="L595" class="LineNr"> 595 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L595'>test_shift_right_logical_negative_r32_with_imm8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L596" class="LineNr"> 596 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xfffffffd</span><span class="Delimiter">;</span> -<span id="L597" class="LineNr"> 597 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L596" class="LineNr"> 596 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xfffffffd</span><span class="Delimiter">;</span> +<span id="L597" class="LineNr"> 597 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L598" class="LineNr"> 598 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L599" class="LineNr"> 599 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L600" class="LineNr"> 600 </span> <span class="Constant">" c1 eb 01 \n"</span> <span class="Comment">// shift EBX right by 1 bit, while padding zeroes</span> @@ -672,12 +672,12 @@ if ('onhashchange' in window) { <span id="L611" class="LineNr"> 611 </span><span class="SalientComment">//:: and</span> <span id="L612" class="LineNr"> 612 </span> <span id="L613" class="LineNr"> 613 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L614" class="LineNr"> 614 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"25"</span><span class="Delimiter">,</span> <span class="Constant">"EAX = bitwise AND of imm32 with <a href='010---vm.cc.html#L16'>EAX</a> (and)"</span><span class="Delimiter">);</span> +<span id="L614" class="LineNr"> 614 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"25"</span><span class="Delimiter">,</span> <span class="Constant">"EAX = bitwise AND of imm32 with <a href='010---vm.cc.html#L10'>EAX</a> (and)"</span><span class="Delimiter">);</span> <span id="L615" class="LineNr"> 615 </span> <span id="L616" class="LineNr"> 616 </span><span class="Delimiter">:(code)</span> <span id="L617" class="LineNr"> 617 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L617'>test_and_EAX_with_imm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L618" class="LineNr"> 618 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xff</span><span class="Delimiter">;</span> -<span id="L619" class="LineNr"> 619 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L618" class="LineNr"> 618 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xff</span><span class="Delimiter">;</span> +<span id="L619" class="LineNr"> 619 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L620" class="LineNr"> 620 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L621" class="LineNr"> 621 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L622" class="LineNr"> 622 </span> <span class="Constant">" 25 0a 0b 0c 0d \n"</span> <span class="Comment">// and 0x0d0c0b0a with EAX</span> @@ -692,15 +692,15 @@ if ('onhashchange' in window) { <span id="L631" class="LineNr"> 631 </span><span class="Normal">case</span> <span class="Constant">0x25</span>: <span class="Delimiter">{</span> <span class="Comment">// and imm32 with EAX</span> <span id="L632" class="LineNr"> 632 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L633" class="LineNr"> 633 </span> <span class="Comment">// difference</span> -<span id="L634" class="LineNr"> 634 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L635" class="LineNr"> 635 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"and imm32 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << signed_arg2 << <span class="Constant">" with EAX"</span> << end<span class="Delimiter">();</span> -<span id="L636" class="LineNr"> 636 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i &= signed_arg2<span class="Delimiter">;</span> -<span id="L637" class="LineNr"> 637 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L638" class="LineNr"> 638 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L639" class="LineNr"> 639 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L640" class="LineNr"> 640 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L641" class="LineNr"> 641 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L642" class="LineNr"> 642 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L634" class="LineNr"> 634 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L635" class="LineNr"> 635 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"and imm32 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << signed_arg2 << <span class="Constant">" with EAX"</span> << end<span class="Delimiter">();</span> +<span id="L636" class="LineNr"> 636 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i &= signed_arg2<span class="Delimiter">;</span> +<span id="L637" class="LineNr"> 637 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L638" class="LineNr"> 638 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> +<span id="L639" class="LineNr"> 639 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L640" class="LineNr"> 640 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L641" class="LineNr"> 641 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L642" class="LineNr"> 642 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L643" class="LineNr"> 643 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L644" class="LineNr"> 644 </span><span class="Delimiter">}</span> <span id="L645" class="LineNr"> 645 </span> @@ -708,8 +708,8 @@ if ('onhashchange' in window) { <span id="L647" class="LineNr"> 647 </span> <span id="L648" class="LineNr"> 648 </span><span class="Delimiter">:(code)</span> <span id="L649" class="LineNr"> 649 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L649'>test_and_imm32_with_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L650" class="LineNr"> 650 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L651" class="LineNr"> 651 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L650" class="LineNr"> 650 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L651" class="LineNr"> 651 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L652" class="LineNr"> 652 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L653" class="LineNr"> 653 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L654" class="LineNr"> 654 </span> <span class="Constant">" 81 23 0a 0b 0c 0d \n"</span> <span class="Comment">// and 0x0d0c0b0a with *EBX</span> @@ -719,7 +719,7 @@ if ('onhashchange' in window) { <span id="L658" class="LineNr"> 658 </span> <span class="Delimiter">);</span> <span id="L659" class="LineNr"> 659 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L660" class="LineNr"> 660 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L661" class="LineNr"> 661 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> +<span id="L661" class="LineNr"> 661 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> <span id="L662" class="LineNr"> 662 </span> <span class="Constant">"run: imm32 is 0x0d0c0b0a\n"</span> <span id="L663" class="LineNr"> 663 </span> <span class="Constant">"run: subop and\n"</span> <span id="L664" class="LineNr"> 664 </span> <span class="Constant">"run: storing 0x0000000a\n"</span> @@ -732,12 +732,12 @@ if ('onhashchange' in window) { <span id="L671" class="LineNr"> 671 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L672" class="LineNr"> 672 </span> <span class="Comment">// difference</span> <span id="L673" class="LineNr"> 673 </span> *signed_arg1 &= signed_arg2<span class="Delimiter">;</span> -<span id="L674" class="LineNr"> 674 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> +<span id="L674" class="LineNr"> 674 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> <span id="L675" class="LineNr"> 675 </span> SF = <span class="Delimiter">(</span>*signed_arg1 >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L676" class="LineNr"> 676 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L677" class="LineNr"> 677 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L678" class="LineNr"> 678 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L679" class="LineNr"> 679 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L676" class="LineNr"> 676 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L677" class="LineNr"> 677 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L678" class="LineNr"> 678 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L679" class="LineNr"> 679 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L680" class="LineNr"> 680 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L681" class="LineNr"> 681 </span><span class="Delimiter">}</span> <span id="L682" class="LineNr"> 682 </span> @@ -745,8 +745,8 @@ if ('onhashchange' in window) { <span id="L684" class="LineNr"> 684 </span> <span id="L685" class="LineNr"> 685 </span><span class="Delimiter">:(code)</span> <span id="L686" class="LineNr"> 686 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L686'>test_and_imm32_with_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L687" class="LineNr"> 687 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xff</span><span class="Delimiter">;</span> -<span id="L688" class="LineNr"> 688 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L687" class="LineNr"> 687 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xff</span><span class="Delimiter">;</span> +<span id="L688" class="LineNr"> 688 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L689" class="LineNr"> 689 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L690" class="LineNr"> 690 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L691" class="LineNr"> 691 </span> <span class="Constant">" 81 e3 0a 0b 0c 0d \n"</span> <span class="Comment">// and 0x0d0c0b0a with EBX</span> @@ -764,12 +764,12 @@ if ('onhashchange' in window) { <span id="L703" class="LineNr"> 703 </span><span class="SalientComment">//:: or</span> <span id="L704" class="LineNr"> 704 </span> <span id="L705" class="LineNr"> 705 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L706" class="LineNr"> 706 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"0d"</span><span class="Delimiter">,</span> <span class="Constant">"EAX = bitwise OR of imm32 with <a href='010---vm.cc.html#L16'>EAX</a> (or)"</span><span class="Delimiter">);</span> +<span id="L706" class="LineNr"> 706 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"0d"</span><span class="Delimiter">,</span> <span class="Constant">"EAX = bitwise OR of imm32 with <a href='010---vm.cc.html#L10'>EAX</a> (or)"</span><span class="Delimiter">);</span> <span id="L707" class="LineNr"> 707 </span> <span id="L708" class="LineNr"> 708 </span><span class="Delimiter">:(code)</span> <span id="L709" class="LineNr"> 709 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L709'>test_or_EAX_with_imm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L710" class="LineNr"> 710 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xd0c0b0a0</span><span class="Delimiter">;</span> -<span id="L711" class="LineNr"> 711 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L710" class="LineNr"> 710 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xd0c0b0a0</span><span class="Delimiter">;</span> +<span id="L711" class="LineNr"> 711 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L712" class="LineNr"> 712 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L713" class="LineNr"> 713 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L714" class="LineNr"> 714 </span> <span class="Constant">" 0d 0a 0b 0c 0d \n"</span> <span class="Comment">// or 0x0d0c0b0a with EAX</span> @@ -784,15 +784,15 @@ if ('onhashchange' in window) { <span id="L723" class="LineNr"> 723 </span><span class="Normal">case</span> <span class="Constant">0x0d</span>: <span class="Delimiter">{</span> <span class="Comment">// or imm32 with EAX</span> <span id="L724" class="LineNr"> 724 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L725" class="LineNr"> 725 </span> <span class="Comment">// difference</span> -<span id="L726" class="LineNr"> 726 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L727" class="LineNr"> 727 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"or imm32 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << signed_arg2 << <span class="Constant">" with EAX"</span> << end<span class="Delimiter">();</span> -<span id="L728" class="LineNr"> 728 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i |= signed_arg2<span class="Delimiter">;</span> -<span id="L729" class="LineNr"> 729 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L730" class="LineNr"> 730 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L731" class="LineNr"> 731 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L732" class="LineNr"> 732 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L733" class="LineNr"> 733 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L734" class="LineNr"> 734 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L726" class="LineNr"> 726 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L727" class="LineNr"> 727 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"or imm32 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << signed_arg2 << <span class="Constant">" with EAX"</span> << end<span class="Delimiter">();</span> +<span id="L728" class="LineNr"> 728 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i |= signed_arg2<span class="Delimiter">;</span> +<span id="L729" class="LineNr"> 729 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L730" class="LineNr"> 730 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> +<span id="L731" class="LineNr"> 731 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L732" class="LineNr"> 732 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L733" class="LineNr"> 733 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L734" class="LineNr"> 734 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L735" class="LineNr"> 735 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L736" class="LineNr"> 736 </span><span class="Delimiter">}</span> <span id="L737" class="LineNr"> 737 </span> @@ -800,8 +800,8 @@ if ('onhashchange' in window) { <span id="L739" class="LineNr"> 739 </span> <span id="L740" class="LineNr"> 740 </span><span class="Delimiter">:(code)</span> <span id="L741" class="LineNr"> 741 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L741'>test_or_imm32_with_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L742" class="LineNr"> 742 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L743" class="LineNr"> 743 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L742" class="LineNr"> 742 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L743" class="LineNr"> 743 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L744" class="LineNr"> 744 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L745" class="LineNr"> 745 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L746" class="LineNr"> 746 </span> <span class="Constant">" 81 0b 0a 0b 0c 0d \n"</span> <span class="Comment">// or 0x0d0c0b0a with *EBX</span> @@ -811,7 +811,7 @@ if ('onhashchange' in window) { <span id="L750" class="LineNr"> 750 </span> <span class="Delimiter">);</span> <span id="L751" class="LineNr"> 751 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L752" class="LineNr"> 752 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L753" class="LineNr"> 753 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> +<span id="L753" class="LineNr"> 753 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> <span id="L754" class="LineNr"> 754 </span> <span class="Constant">"run: imm32 is 0x0d0c0b0a\n"</span> <span id="L755" class="LineNr"> 755 </span> <span class="Constant">"run: subop or\n"</span> <span id="L756" class="LineNr"> 756 </span> <span class="Constant">"run: storing 0xddccbbaa\n"</span> @@ -824,19 +824,19 @@ if ('onhashchange' in window) { <span id="L763" class="LineNr"> 763 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L764" class="LineNr"> 764 </span> <span class="Comment">// difference</span> <span id="L765" class="LineNr"> 765 </span> *signed_arg1 |= signed_arg2<span class="Delimiter">;</span> -<span id="L766" class="LineNr"> 766 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> +<span id="L766" class="LineNr"> 766 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> <span id="L767" class="LineNr"> 767 </span> SF = <span class="Delimiter">(</span>*signed_arg1 >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L768" class="LineNr"> 768 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L769" class="LineNr"> 769 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L770" class="LineNr"> 770 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L771" class="LineNr"> 771 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L768" class="LineNr"> 768 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L769" class="LineNr"> 769 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L770" class="LineNr"> 770 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L771" class="LineNr"> 771 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L772" class="LineNr"> 772 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L773" class="LineNr"> 773 </span><span class="Delimiter">}</span> <span id="L774" class="LineNr"> 774 </span> <span id="L775" class="LineNr"> 775 </span><span class="Delimiter">:(code)</span> <span id="L776" class="LineNr"> 776 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L776'>test_or_imm32_with_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L777" class="LineNr"> 777 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xd0c0b0a0</span><span class="Delimiter">;</span> -<span id="L778" class="LineNr"> 778 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L777" class="LineNr"> 777 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xd0c0b0a0</span><span class="Delimiter">;</span> +<span id="L778" class="LineNr"> 778 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L779" class="LineNr"> 779 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L780" class="LineNr"> 780 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L781" class="LineNr"> 781 </span> <span class="Constant">" 81 cb 0a 0b 0c 0d \n"</span> <span class="Comment">// or 0x0d0c0b0a with EBX</span> @@ -854,12 +854,12 @@ if ('onhashchange' in window) { <span id="L793" class="LineNr"> 793 </span><span class="SalientComment">//:: xor</span> <span id="L794" class="LineNr"> 794 </span> <span id="L795" class="LineNr"> 795 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L796" class="LineNr"> 796 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"35"</span><span class="Delimiter">,</span> <span class="Constant">"EAX = bitwise XOR of imm32 with <a href='010---vm.cc.html#L16'>EAX</a> (xor)"</span><span class="Delimiter">);</span> +<span id="L796" class="LineNr"> 796 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"35"</span><span class="Delimiter">,</span> <span class="Constant">"EAX = bitwise XOR of imm32 with <a href='010---vm.cc.html#L10'>EAX</a> (xor)"</span><span class="Delimiter">);</span> <span id="L797" class="LineNr"> 797 </span> <span id="L798" class="LineNr"> 798 </span><span class="Delimiter">:(code)</span> <span id="L799" class="LineNr"> 799 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L799'>test_xor_EAX_with_imm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L800" class="LineNr"> 800 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xddccb0a0</span><span class="Delimiter">;</span> -<span id="L801" class="LineNr"> 801 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L800" class="LineNr"> 800 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xddccb0a0</span><span class="Delimiter">;</span> +<span id="L801" class="LineNr"> 801 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L802" class="LineNr"> 802 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L803" class="LineNr"> 803 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L804" class="LineNr"> 804 </span> <span class="Constant">" 35 0a 0b 0c 0d \n"</span> <span class="Comment">// xor 0x0d0c0b0a with EAX</span> @@ -874,15 +874,15 @@ if ('onhashchange' in window) { <span id="L813" class="LineNr"> 813 </span><span class="Normal">case</span> <span class="Constant">0x35</span>: <span class="Delimiter">{</span> <span class="Comment">// xor imm32 with EAX</span> <span id="L814" class="LineNr"> 814 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L815" class="LineNr"> 815 </span> <span class="Comment">// difference</span> -<span id="L816" class="LineNr"> 816 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L817" class="LineNr"> 817 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"xor imm32 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << signed_arg2 << <span class="Constant">" with EAX"</span> << end<span class="Delimiter">();</span> -<span id="L818" class="LineNr"> 818 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i ^= signed_arg2<span class="Delimiter">;</span> -<span id="L819" class="LineNr"> 819 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L820" class="LineNr"> 820 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L821" class="LineNr"> 821 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L822" class="LineNr"> 822 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L823" class="LineNr"> 823 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L824" class="LineNr"> 824 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L816" class="LineNr"> 816 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L817" class="LineNr"> 817 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"xor imm32 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << signed_arg2 << <span class="Constant">" with EAX"</span> << end<span class="Delimiter">();</span> +<span id="L818" class="LineNr"> 818 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i ^= signed_arg2<span class="Delimiter">;</span> +<span id="L819" class="LineNr"> 819 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L820" class="LineNr"> 820 </span> SF = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i >> <span class="Constant">31</span><span class="Delimiter">);</span> +<span id="L821" class="LineNr"> 821 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L822" class="LineNr"> 822 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L823" class="LineNr"> 823 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L824" class="LineNr"> 824 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L825" class="LineNr"> 825 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L826" class="LineNr"> 826 </span><span class="Delimiter">}</span> <span id="L827" class="LineNr"> 827 </span> @@ -890,8 +890,8 @@ if ('onhashchange' in window) { <span id="L829" class="LineNr"> 829 </span> <span id="L830" class="LineNr"> 830 </span><span class="Delimiter">:(code)</span> <span id="L831" class="LineNr"> 831 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L831'>test_xor_imm32_with_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L832" class="LineNr"> 832 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L833" class="LineNr"> 833 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L832" class="LineNr"> 832 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L833" class="LineNr"> 833 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L834" class="LineNr"> 834 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L835" class="LineNr"> 835 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L836" class="LineNr"> 836 </span> <span class="Constant">" 81 33 0a 0b 0c 0d \n"</span> <span class="Comment">// xor 0x0d0c0b0a with *EBX</span> @@ -901,7 +901,7 @@ if ('onhashchange' in window) { <span id="L840" class="LineNr"> 840 </span> <span class="Delimiter">);</span> <span id="L841" class="LineNr"> 841 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L842" class="LineNr"> 842 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L843" class="LineNr"> 843 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> +<span id="L843" class="LineNr"> 843 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> <span id="L844" class="LineNr"> 844 </span> <span class="Constant">"run: imm32 is 0x0d0c0b0a\n"</span> <span id="L845" class="LineNr"> 845 </span> <span class="Constant">"run: subop xor\n"</span> <span id="L846" class="LineNr"> 846 </span> <span class="Constant">"run: storing 0xddccbbaa\n"</span> @@ -914,19 +914,19 @@ if ('onhashchange' in window) { <span id="L853" class="LineNr"> 853 </span> <span class="Comment">// bitwise ops technically operate on unsigned numbers, but it makes no</span> <span id="L854" class="LineNr"> 854 </span> <span class="Comment">// difference</span> <span id="L855" class="LineNr"> 855 </span> *signed_arg1 ^= signed_arg2<span class="Delimiter">;</span> -<span id="L856" class="LineNr"> 856 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> +<span id="L856" class="LineNr"> 856 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << *signed_arg1 << end<span class="Delimiter">();</span> <span id="L857" class="LineNr"> 857 </span> SF = <span class="Delimiter">(</span>*signed_arg1 >> <span class="Constant">31</span><span class="Delimiter">);</span> -<span id="L858" class="LineNr"> 858 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L859" class="LineNr"> 859 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L860" class="LineNr"> 860 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L861" class="LineNr"> 861 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L858" class="LineNr"> 858 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>*signed_arg1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L859" class="LineNr"> 859 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L860" class="LineNr"> 860 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L861" class="LineNr"> 861 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L862" class="LineNr"> 862 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L863" class="LineNr"> 863 </span><span class="Delimiter">}</span> <span id="L864" class="LineNr"> 864 </span> <span id="L865" class="LineNr"> 865 </span><span class="Delimiter">:(code)</span> <span id="L866" class="LineNr"> 866 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L866'>test_xor_imm32_with_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L867" class="LineNr"> 867 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xd0c0b0a0</span><span class="Delimiter">;</span> -<span id="L868" class="LineNr"> 868 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L867" class="LineNr"> 867 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xd0c0b0a0</span><span class="Delimiter">;</span> +<span id="L868" class="LineNr"> 868 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L869" class="LineNr"> 869 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L870" class="LineNr"> 870 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L871" class="LineNr"> 871 </span> <span class="Constant">" 81 f3 0a 0b 0c 0d \n"</span> <span class="Comment">// xor 0x0d0c0b0a with EBX</span> @@ -944,103 +944,103 @@ if ('onhashchange' in window) { <span id="L883" class="LineNr"> 883 </span><span class="SalientComment">//:: compare (cmp)</span> <span id="L884" class="LineNr"> 884 </span> <span id="L885" class="LineNr"> 885 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L886" class="LineNr"> 886 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"3d"</span><span class="Delimiter">,</span> <span class="Constant">"compare: set SF if <a href='010---vm.cc.html#L16'>EAX</a> < imm32 (cmp)"</span><span class="Delimiter">);</span> +<span id="L886" class="LineNr"> 886 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"3d"</span><span class="Delimiter">,</span> <span class="Constant">"compare: set SF if <a href='010---vm.cc.html#L10'>EAX</a> < imm32 (cmp)"</span><span class="Delimiter">);</span> <span id="L887" class="LineNr"> 887 </span> <span id="L888" class="LineNr"> 888 </span><span class="Delimiter">:(code)</span> <span id="L889" class="LineNr"> 889 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L889'>test_compare_EAX_with_imm32_greater</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L890" class="LineNr"> 890 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0b0a</span><span class="Delimiter">;</span> -<span id="L891" class="LineNr"> 891 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L890" class="LineNr"> 890 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0b0a</span><span class="Delimiter">;</span> +<span id="L891" class="LineNr"> 891 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L892" class="LineNr"> 892 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L893" class="LineNr"> 893 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L894" class="LineNr"> 894 </span> <span class="Constant">" 3d 07 0b 0c 0d \n"</span> <span class="Comment">// compare EAX with 0x0d0c0b07</span> <span id="L895" class="LineNr"> 895 </span> <span class="Delimiter">);</span> <span id="L896" class="LineNr"> 896 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L897" class="LineNr"> 897 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L16'>EAX</a> with imm32 0x0d0c0b07\n"</span> +<span id="L897" class="LineNr"> 897 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L10'>EAX</a> with imm32 0x0d0c0b07\n"</span> <span id="L898" class="LineNr"> 898 </span> <span class="Constant">"run: SF=0; ZF=0; CF=0; OF=0\n"</span> <span id="L899" class="LineNr"> 899 </span> <span class="Delimiter">);</span> <span id="L900" class="LineNr"> 900 </span><span class="Delimiter">}</span> <span id="L901" class="LineNr"> 901 </span> <span id="L902" class="LineNr"> 902 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L903" class="LineNr"> 903 </span><span class="Normal">case</span> <span class="Constant">0x3d</span>: <span class="Delimiter">{</span> <span class="Comment">// compare EAX with imm32</span> -<span id="L904" class="LineNr"> 904 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg1 = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> -<span id="L905" class="LineNr"> 905 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L906" class="LineNr"> 906 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"compare <a href='010---vm.cc.html#L16'>EAX</a> with imm32 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << signed_arg2 << end<span class="Delimiter">();</span> +<span id="L904" class="LineNr"> 904 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg1 = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i<span class="Delimiter">;</span> +<span id="L905" class="LineNr"> 905 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_arg2 = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L906" class="LineNr"> 906 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"compare <a href='010---vm.cc.html#L10'>EAX</a> with imm32 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << signed_arg2 << end<span class="Delimiter">();</span> <span id="L907" class="LineNr"> 907 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> signed_difference = signed_arg1 - signed_arg2<span class="Delimiter">;</span> <span id="L908" class="LineNr"> 908 </span> SF = <span class="Delimiter">(</span>signed_difference < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L909" class="LineNr"> 909 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>signed_difference == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L909" class="LineNr"> 909 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>signed_difference == <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L910" class="LineNr"> 910 </span> <span class="Normal">const</span> <span class="Normal">int64_t</span> full_signed_difference = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span>signed_arg1<span class="Delimiter">)</span> - signed_arg2<span class="Delimiter">;</span> -<span id="L911" class="LineNr"> 911 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>signed_difference != full_signed_difference<span class="Delimiter">);</span> +<span id="L911" class="LineNr"> 911 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>signed_difference != full_signed_difference<span class="Delimiter">);</span> <span id="L912" class="LineNr"> 912 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_arg1 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>signed_arg1<span class="Delimiter">);</span> <span id="L913" class="LineNr"> 913 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_arg2 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>signed_arg2<span class="Delimiter">);</span> <span id="L914" class="LineNr"> 914 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_difference = unsigned_arg1 - unsigned_arg2<span class="Delimiter">;</span> <span id="L915" class="LineNr"> 915 </span> <span class="Normal">const</span> <span class="Normal">uint64_t</span> full_unsigned_difference = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span>unsigned_arg1<span class="Delimiter">)</span> - unsigned_arg2<span class="Delimiter">;</span> -<span id="L916" class="LineNr"> 916 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>unsigned_difference != full_unsigned_difference<span class="Delimiter">);</span> -<span id="L917" class="LineNr"> 917 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L916" class="LineNr"> 916 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>unsigned_difference != full_unsigned_difference<span class="Delimiter">);</span> +<span id="L917" class="LineNr"> 917 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L918" class="LineNr"> 918 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L919" class="LineNr"> 919 </span><span class="Delimiter">}</span> <span id="L920" class="LineNr"> 920 </span> <span id="L921" class="LineNr"> 921 </span><span class="Delimiter">:(code)</span> <span id="L922" class="LineNr"> 922 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L922'>test_compare_EAX_with_imm32_lesser_unsigned_and_signed</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L923" class="LineNr"> 923 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> -<span id="L924" class="LineNr"> 924 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L923" class="LineNr"> 923 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> +<span id="L924" class="LineNr"> 924 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L925" class="LineNr"> 925 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L926" class="LineNr"> 926 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L927" class="LineNr"> 927 </span> <span class="Constant">" 3d 0d 0c 0b 0a \n"</span> <span class="Comment">// compare EAX with imm32</span> <span id="L928" class="LineNr"> 928 </span> <span class="Delimiter">);</span> <span id="L929" class="LineNr"> 929 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L930" class="LineNr"> 930 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L16'>EAX</a> with imm32 0x0a0b0c0d\n"</span> +<span id="L930" class="LineNr"> 930 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L10'>EAX</a> with imm32 0x0a0b0c0d\n"</span> <span id="L931" class="LineNr"> 931 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=0\n"</span> <span id="L932" class="LineNr"> 932 </span> <span class="Delimiter">);</span> <span id="L933" class="LineNr"> 933 </span><span class="Delimiter">}</span> <span id="L934" class="LineNr"> 934 </span> <span id="L935" class="LineNr"> 935 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L935'>test_compare_EAX_with_imm32_lesser_unsigned_and_signed_due_to_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L936" class="LineNr"> 936 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> -<span id="L937" class="LineNr"> 937 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L936" class="LineNr"> 936 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> +<span id="L937" class="LineNr"> 937 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L938" class="LineNr"> 938 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L939" class="LineNr"> 939 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L940" class="LineNr"> 940 </span> <span class="Constant">" 3d 00 00 00 80\n"</span> <span class="Comment">// compare EAX with smallest negative signed integer</span> <span id="L941" class="LineNr"> 941 </span> <span class="Delimiter">);</span> <span id="L942" class="LineNr"> 942 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L943" class="LineNr"> 943 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L16'>EAX</a> with imm32 0x80000000\n"</span> +<span id="L943" class="LineNr"> 943 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L10'>EAX</a> with imm32 0x80000000\n"</span> <span id="L944" class="LineNr"> 944 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=1\n"</span> <span id="L945" class="LineNr"> 945 </span> <span class="Delimiter">);</span> <span id="L946" class="LineNr"> 946 </span><span class="Delimiter">}</span> <span id="L947" class="LineNr"> 947 </span> <span id="L948" class="LineNr"> 948 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L948'>test_compare_EAX_with_imm32_lesser_signed</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L949" class="LineNr"> 949 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// -1</span> -<span id="L950" class="LineNr"> 950 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L949" class="LineNr"> 949 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// -1</span> +<span id="L950" class="LineNr"> 950 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L951" class="LineNr"> 951 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L952" class="LineNr"> 952 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L953" class="LineNr"> 953 </span> <span class="Constant">" 3d 01 00 00 00\n"</span> <span class="Comment">// compare EAX with 1</span> <span id="L954" class="LineNr"> 954 </span> <span class="Delimiter">);</span> <span id="L955" class="LineNr"> 955 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L956" class="LineNr"> 956 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L16'>EAX</a> with imm32 0x00000001\n"</span> +<span id="L956" class="LineNr"> 956 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L10'>EAX</a> with imm32 0x00000001\n"</span> <span id="L957" class="LineNr"> 957 </span> <span class="Constant">"run: SF=1; ZF=0; CF=0; OF=0\n"</span> <span id="L958" class="LineNr"> 958 </span> <span class="Delimiter">);</span> <span id="L959" class="LineNr"> 959 </span><span class="Delimiter">}</span> <span id="L960" class="LineNr"> 960 </span> <span id="L961" class="LineNr"> 961 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L961'>test_compare_EAX_with_imm32_lesser_unsigned</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L962" class="LineNr"> 962 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x00000001</span><span class="Delimiter">;</span> <span class="Comment">// 1</span> -<span id="L963" class="LineNr"> 963 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L962" class="LineNr"> 962 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x00000001</span><span class="Delimiter">;</span> <span class="Comment">// 1</span> +<span id="L963" class="LineNr"> 963 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L964" class="LineNr"> 964 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L965" class="LineNr"> 965 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L966" class="LineNr"> 966 </span> <span class="Constant">" 3d ff ff ff ff\n"</span> <span class="Comment">// compare EAX with -1</span> <span id="L967" class="LineNr"> 967 </span> <span class="Delimiter">);</span> <span id="L968" class="LineNr"> 968 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L969" class="LineNr"> 969 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L16'>EAX</a> with imm32 0xffffffff\n"</span> +<span id="L969" class="LineNr"> 969 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L10'>EAX</a> with imm32 0xffffffff\n"</span> <span id="L970" class="LineNr"> 970 </span> <span class="Constant">"run: SF=0; ZF=0; CF=1; OF=0\n"</span> <span id="L971" class="LineNr"> 971 </span> <span class="Delimiter">);</span> <span id="L972" class="LineNr"> 972 </span><span class="Delimiter">}</span> <span id="L973" class="LineNr"> 973 </span> <span id="L974" class="LineNr"> 974 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L974'>test_compare_EAX_with_imm32_equal</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L975" class="LineNr"> 975 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0b0a</span><span class="Delimiter">;</span> -<span id="L976" class="LineNr"> 976 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L975" class="LineNr"> 975 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0b0a</span><span class="Delimiter">;</span> +<span id="L976" class="LineNr"> 976 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L977" class="LineNr"> 977 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L978" class="LineNr"> 978 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L979" class="LineNr"> 979 </span> <span class="Constant">" 3d 0a 0b 0c 0d \n"</span> <span class="Comment">// compare 0x0d0c0b0a with EAX</span> <span id="L980" class="LineNr"> 980 </span> <span class="Delimiter">);</span> <span id="L981" class="LineNr"> 981 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L982" class="LineNr"> 982 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L16'>EAX</a> with imm32 0x0d0c0b0a\n"</span> +<span id="L982" class="LineNr"> 982 </span> <span class="Constant">"run: compare <a href='010---vm.cc.html#L10'>EAX</a> with imm32 0x0d0c0b0a\n"</span> <span id="L983" class="LineNr"> 983 </span> <span class="Constant">"run: SF=0; ZF=1; CF=0; OF=0\n"</span> <span id="L984" class="LineNr"> 984 </span> <span class="Delimiter">);</span> <span id="L985" class="LineNr"> 985 </span><span class="Delimiter">}</span> @@ -1048,8 +1048,8 @@ if ('onhashchange' in window) { <span id="L987" class="LineNr"> 987 </span><span class="Comment">//:</span> <span id="L988" class="LineNr"> 988 </span> <span id="L989" class="LineNr"> 989 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L989'>test_compare_imm32_with_r32_greater</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L990" class="LineNr"> 990 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0b0a</span><span class="Delimiter">;</span> -<span id="L991" class="LineNr"> 991 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L990" class="LineNr"> 990 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0b0a</span><span class="Delimiter">;</span> +<span id="L991" class="LineNr"> 991 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L992" class="LineNr"> 992 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L993" class="LineNr"> 993 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L994" class="LineNr"> 994 </span> <span class="Constant">" 81 fb 07 0b 0c 0d \n"</span> <span class="Comment">// compare 0x0d0c0b07 with EBX</span> @@ -1068,22 +1068,22 @@ if ('onhashchange' in window) { <span id="L1007" class="LineNr">1007 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"subop compare"</span> << end<span class="Delimiter">();</span> <span id="L1008" class="LineNr">1008 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> tmp1 = *signed_arg1 - signed_arg2<span class="Delimiter">;</span> <span id="L1009" class="LineNr">1009 </span> SF = <span class="Delimiter">(</span>tmp1 < <span class="Constant">0</span><span class="Delimiter">);</span> -<span id="L1010" class="LineNr">1010 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Delimiter">(</span>tmp1 == <span class="Constant">0</span><span class="Delimiter">);</span> +<span id="L1010" class="LineNr">1010 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Delimiter">(</span>tmp1 == <span class="Constant">0</span><span class="Delimiter">);</span> <span id="L1011" class="LineNr">1011 </span> <span class="Normal">const</span> <span class="Normal">int64_t</span> tmp2 = <span class="Normal">static_cast</span><<span class="Normal">int64_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">)</span> - signed_arg2<span class="Delimiter">;</span> -<span id="L1012" class="LineNr">1012 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Delimiter">(</span>tmp1 != tmp2<span class="Delimiter">);</span> +<span id="L1012" class="LineNr">1012 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Delimiter">(</span>tmp1 != tmp2<span class="Delimiter">);</span> <span id="L1013" class="LineNr">1013 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_arg1 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>*signed_arg1<span class="Delimiter">);</span> <span id="L1014" class="LineNr">1014 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> unsigned_arg2 = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>signed_arg2<span class="Delimiter">);</span> <span id="L1015" class="LineNr">1015 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> tmp3 = unsigned_arg1 - unsigned_arg2<span class="Delimiter">;</span> <span id="L1016" class="LineNr">1016 </span> <span class="Normal">const</span> <span class="Normal">uint64_t</span> tmp4 = <span class="Normal">static_cast</span><<span class="Normal">uint64_t</span>><span class="Delimiter">(</span>unsigned_arg1<span class="Delimiter">)</span> - unsigned_arg2<span class="Delimiter">;</span> -<span id="L1017" class="LineNr">1017 </span> <a href='010---vm.cc.html#L87'>CF</a> = <span class="Delimiter">(</span>tmp3 != tmp4<span class="Delimiter">);</span> -<span id="L1018" class="LineNr">1018 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L86'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L87'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L88'>OF</a> << end<span class="Delimiter">();</span> +<span id="L1017" class="LineNr">1017 </span> <a href='010---vm.cc.html#L81'>CF</a> = <span class="Delimiter">(</span>tmp3 != tmp4<span class="Delimiter">);</span> +<span id="L1018" class="LineNr">1018 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"SF="</span> << SF << <span class="Constant">"; ZF="</span> << <a href='010---vm.cc.html#L80'>ZF</a> << <span class="Constant">"; CF="</span> << <a href='010---vm.cc.html#L81'>CF</a> << <span class="Constant">"; OF="</span> << <a href='010---vm.cc.html#L82'>OF</a> << end<span class="Delimiter">();</span> <span id="L1019" class="LineNr">1019 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1020" class="LineNr">1020 </span><span class="Delimiter">}</span> <span id="L1021" class="LineNr">1021 </span> <span id="L1022" class="LineNr">1022 </span><span class="Delimiter">:(code)</span> <span id="L1023" class="LineNr">1023 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1023'>test_compare_rm32_with_imm32_lesser_unsigned_and_signed</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1024" class="LineNr">1024 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> -<span id="L1025" class="LineNr">1025 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1024" class="LineNr">1024 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x0a0b0c07</span><span class="Delimiter">;</span> +<span id="L1025" class="LineNr">1025 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1026" class="LineNr">1026 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1027" class="LineNr">1027 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1028" class="LineNr">1028 </span> <span class="Constant">" 81 f8 0d 0c 0b 0a \n"</span> <span class="Comment">// compare EAX with imm32</span> @@ -1099,8 +1099,8 @@ if ('onhashchange' in window) { <span id="L1038" class="LineNr">1038 </span><span class="Delimiter">}</span> <span id="L1039" class="LineNr">1039 </span> <span id="L1040" class="LineNr">1040 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1040'>test_compare_rm32_with_imm32_lesser_unsigned_and_signed_due_to_overflow</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1041" class="LineNr">1041 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> -<span id="L1042" class="LineNr">1042 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1041" class="LineNr">1041 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x7fffffff</span><span class="Delimiter">;</span> <span class="Comment">// largest positive signed integer</span> +<span id="L1042" class="LineNr">1042 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1043" class="LineNr">1043 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1044" class="LineNr">1044 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1045" class="LineNr">1045 </span> <span class="Constant">" 81 f8 00 00 00 80\n"</span> <span class="Comment">// compare EAX with smallest negative signed integer</span> @@ -1116,8 +1116,8 @@ if ('onhashchange' in window) { <span id="L1055" class="LineNr">1055 </span><span class="Delimiter">}</span> <span id="L1056" class="LineNr">1056 </span> <span id="L1057" class="LineNr">1057 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1057'>test_compare_rm32_with_imm32_lesser_signed</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1058" class="LineNr">1058 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// -1</span> -<span id="L1059" class="LineNr">1059 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1058" class="LineNr">1058 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0xffffffff</span><span class="Delimiter">;</span> <span class="Comment">// -1</span> +<span id="L1059" class="LineNr">1059 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1060" class="LineNr">1060 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1061" class="LineNr">1061 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1062" class="LineNr">1062 </span> <span class="Constant">" 81 f8 01 00 00 00\n"</span> <span class="Comment">// compare EAX with 1</span> @@ -1133,8 +1133,8 @@ if ('onhashchange' in window) { <span id="L1072" class="LineNr">1072 </span><span class="Delimiter">}</span> <span id="L1073" class="LineNr">1073 </span> <span id="L1074" class="LineNr">1074 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1074'>test_compare_rm32_with_imm32_lesser_unsigned</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1075" class="LineNr">1075 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x00000001</span><span class="Delimiter">;</span> <span class="Comment">// 1</span> -<span id="L1076" class="LineNr">1076 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1075" class="LineNr">1075 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x00000001</span><span class="Delimiter">;</span> <span class="Comment">// 1</span> +<span id="L1076" class="LineNr">1076 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1077" class="LineNr">1077 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1078" class="LineNr">1078 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1079" class="LineNr">1079 </span> <span class="Constant">" 81 f8 ff ff ff ff\n"</span> <span class="Comment">// compare EAX with -1</span> @@ -1151,8 +1151,8 @@ if ('onhashchange' in window) { <span id="L1090" class="LineNr">1090 </span> <span id="L1091" class="LineNr">1091 </span><span class="Delimiter">:(code)</span> <span id="L1092" class="LineNr">1092 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1092'>test_compare_imm32_with_r32_equal</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1093" class="LineNr">1093 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0b0a</span><span class="Delimiter">;</span> -<span id="L1094" class="LineNr">1094 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1093" class="LineNr">1093 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0b0a</span><span class="Delimiter">;</span> +<span id="L1094" class="LineNr">1094 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1095" class="LineNr">1095 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1096" class="LineNr">1096 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1097" class="LineNr">1097 </span> <span class="Constant">" 81 fb 0a 0b 0c 0d \n"</span> <span class="Comment">// compare 0x0d0c0b0a with EBX</span> @@ -1168,8 +1168,8 @@ if ('onhashchange' in window) { <span id="L1107" class="LineNr">1107 </span> <span id="L1108" class="LineNr">1108 </span><span class="Delimiter">:(code)</span> <span id="L1109" class="LineNr">1109 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1109'>test_compare_imm32_with_mem_at_r32_greater</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1110" class="LineNr">1110 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L1111" class="LineNr">1111 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1110" class="LineNr">1110 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L1111" class="LineNr">1111 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1112" class="LineNr">1112 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1113" class="LineNr">1113 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1114" class="LineNr">1114 </span> <span class="Constant">" 81 3b 07 0b 0c 0d \n"</span> <span class="Comment">// compare 0x0d0c0b07 with *EBX</span> @@ -1179,7 +1179,7 @@ if ('onhashchange' in window) { <span id="L1118" class="LineNr">1118 </span> <span class="Delimiter">);</span> <span id="L1119" class="LineNr">1119 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L1120" class="LineNr">1120 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L1121" class="LineNr">1121 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> +<span id="L1121" class="LineNr">1121 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> <span id="L1122" class="LineNr">1122 </span> <span class="Constant">"run: imm32 is 0x0d0c0b07\n"</span> <span id="L1123" class="LineNr">1123 </span> <span class="Constant">"run: SF=0; ZF=0; CF=0; OF=0\n"</span> <span id="L1124" class="LineNr">1124 </span> <span class="Delimiter">);</span> @@ -1187,8 +1187,8 @@ if ('onhashchange' in window) { <span id="L1126" class="LineNr">1126 </span> <span id="L1127" class="LineNr">1127 </span><span class="Delimiter">:(code)</span> <span id="L1128" class="LineNr">1128 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1128'>test_compare_imm32_with_mem_at_r32_lesser</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1129" class="LineNr">1129 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L1130" class="LineNr">1130 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1129" class="LineNr">1129 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L1130" class="LineNr">1130 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1131" class="LineNr">1131 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1132" class="LineNr">1132 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1133" class="LineNr">1133 </span> <span class="Constant">" 81 38 0a 0b 0c 0d \n"</span> <span class="Comment">// compare 0x0d0c0b0a with *EAX</span> @@ -1198,7 +1198,7 @@ if ('onhashchange' in window) { <span id="L1137" class="LineNr">1137 </span> <span class="Delimiter">);</span> <span id="L1138" class="LineNr">1138 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L1139" class="LineNr">1139 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L1140" class="LineNr">1140 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L1140" class="LineNr">1140 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L1141" class="LineNr">1141 </span> <span class="Constant">"run: imm32 is 0x0d0c0b0a\n"</span> <span id="L1142" class="LineNr">1142 </span> <span class="Constant">"run: SF=1; ZF=0; CF=1; OF=0\n"</span> <span id="L1143" class="LineNr">1143 </span> <span class="Delimiter">);</span> @@ -1206,9 +1206,9 @@ if ('onhashchange' in window) { <span id="L1145" class="LineNr">1145 </span> <span id="L1146" class="LineNr">1146 </span><span class="Delimiter">:(code)</span> <span id="L1147" class="LineNr">1147 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1147'>test_compare_imm32_with_mem_at_r32_equal</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1148" class="LineNr">1148 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0b0a</span><span class="Delimiter">;</span> -<span id="L1149" class="LineNr">1149 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L1150" class="LineNr">1150 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1148" class="LineNr">1148 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x0d0c0b0a</span><span class="Delimiter">;</span> +<span id="L1149" class="LineNr">1149 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L1150" class="LineNr">1150 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1151" class="LineNr">1151 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1152" class="LineNr">1152 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1153" class="LineNr">1153 </span> <span class="Constant">" 81 3b 0a 0b 0c 0d \n"</span> <span class="Comment">// compare 0x0d0c0b0a with *EBX</span> @@ -1218,7 +1218,7 @@ if ('onhashchange' in window) { <span id="L1157" class="LineNr">1157 </span> <span class="Delimiter">);</span> <span id="L1158" class="LineNr">1158 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L1159" class="LineNr">1159 </span> <span class="Constant">"run: combine r/m32 with imm32\n"</span> -<span id="L1160" class="LineNr">1160 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> +<span id="L1160" class="LineNr">1160 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> <span id="L1161" class="LineNr">1161 </span> <span class="Constant">"run: imm32 is 0x0d0c0b0a\n"</span> <span id="L1162" class="LineNr">1162 </span> <span class="Constant">"run: SF=0; ZF=1; CF=0; OF=0\n"</span> <span id="L1163" class="LineNr">1163 </span> <span class="Delimiter">);</span> @@ -1228,17 +1228,17 @@ if ('onhashchange' in window) { <span id="L1167" class="LineNr">1167 </span> <span id="L1168" class="LineNr">1168 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> <span id="L1169" class="LineNr">1169 </span><span class="Comment">// b8 defined earlier to copy imm32 to EAX</span> -<span id="L1170" class="LineNr">1170 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"b9"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L17'>ECX</a> (mov)"</span><span class="Delimiter">);</span> -<span id="L1171" class="LineNr">1171 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"ba"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L18'>EDX</a> (mov)"</span><span class="Delimiter">);</span> -<span id="L1172" class="LineNr">1172 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"bb"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L19'>EBX</a> (mov)"</span><span class="Delimiter">);</span> -<span id="L1173" class="LineNr">1173 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"bc"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L20'>ESP</a> (mov)"</span><span class="Delimiter">);</span> -<span id="L1174" class="LineNr">1174 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"bd"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L21'>EBP</a> (mov)"</span><span class="Delimiter">);</span> -<span id="L1175" class="LineNr">1175 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"be"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L22'>ESI</a> (mov)"</span><span class="Delimiter">);</span> -<span id="L1176" class="LineNr">1176 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"bf"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L23'>EDI</a> (mov)"</span><span class="Delimiter">);</span> +<span id="L1170" class="LineNr">1170 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"b9"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L11'>ECX</a> (mov)"</span><span class="Delimiter">);</span> +<span id="L1171" class="LineNr">1171 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"ba"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L12'>EDX</a> (mov)"</span><span class="Delimiter">);</span> +<span id="L1172" class="LineNr">1172 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"bb"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L13'>EBX</a> (mov)"</span><span class="Delimiter">);</span> +<span id="L1173" class="LineNr">1173 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"bc"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L14'>ESP</a> (mov)"</span><span class="Delimiter">);</span> +<span id="L1174" class="LineNr">1174 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"bd"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L15'>EBP</a> (mov)"</span><span class="Delimiter">);</span> +<span id="L1175" class="LineNr">1175 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"be"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L16'>ESI</a> (mov)"</span><span class="Delimiter">);</span> +<span id="L1176" class="LineNr">1176 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"bf"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to <a href='010---vm.cc.html#L17'>EDI</a> (mov)"</span><span class="Delimiter">);</span> <span id="L1177" class="LineNr">1177 </span> <span id="L1178" class="LineNr">1178 </span><span class="Delimiter">:(code)</span> <span id="L1179" class="LineNr">1179 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1179'>test_copy_imm32_to_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1180" class="LineNr">1180 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1180" class="LineNr">1180 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1181" class="LineNr">1181 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1182" class="LineNr">1182 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1183" class="LineNr">1183 </span> <span class="Constant">" bb 0a 0b 0c 0d \n"</span> <span class="Comment">// copy 0x0d0c0b0a to EBX</span> @@ -1257,21 +1257,21 @@ if ('onhashchange' in window) { <span id="L1196" class="LineNr">1196 </span><span class="Normal">case</span> <span class="Constant">0xbe</span>: <span id="L1197" class="LineNr">1197 </span><span class="Normal">case</span> <span class="Constant">0xbf</span>: <span class="Delimiter">{</span> <span class="Comment">// copy imm32 to r32</span> <span id="L1198" class="LineNr">1198 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> rdest = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> -<span id="L1199" class="LineNr">1199 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> src = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L1200" class="LineNr">1200 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy imm32 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << src << <span class="Constant">" to "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rdest<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L1201" class="LineNr">1201 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[rdest]<span class="Delimiter">.</span>i = src<span class="Delimiter">;</span> +<span id="L1199" class="LineNr">1199 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> src = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L1200" class="LineNr">1200 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy imm32 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << src << <span class="Constant">" to "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rdest<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L1201" class="LineNr">1201 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[rdest]<span class="Delimiter">.</span>i = src<span class="Delimiter">;</span> <span id="L1202" class="LineNr">1202 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1203" class="LineNr">1203 </span><span class="Delimiter">}</span> <span id="L1204" class="LineNr">1204 </span> <span id="L1205" class="LineNr">1205 </span><span class="Comment">//:</span> <span id="L1206" class="LineNr">1206 </span> <span id="L1207" class="LineNr">1207 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L1208" class="LineNr">1208 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"c7"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to rm32 with subop 0 (mov)"</span><span class="Delimiter">);</span> +<span id="L1208" class="LineNr">1208 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"c7"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm32 to rm32 with subop 0 (mov)"</span><span class="Delimiter">);</span> <span id="L1209" class="LineNr">1209 </span> <span id="L1210" class="LineNr">1210 </span><span class="Delimiter">:(code)</span> <span id="L1211" class="LineNr">1211 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1211'>test_copy_imm32_to_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1212" class="LineNr">1212 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x60</span><span class="Delimiter">;</span> -<span id="L1213" class="LineNr">1213 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1212" class="LineNr">1212 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x60</span><span class="Delimiter">;</span> +<span id="L1213" class="LineNr">1213 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1214" class="LineNr">1214 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1215" class="LineNr">1215 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1216" class="LineNr">1216 </span> <span class="Constant">" c7 03 0a 0b 0c 0d \n"</span> <span class="Comment">// copy 0x0d0c0b0a to *EBX</span> @@ -1279,23 +1279,23 @@ if ('onhashchange' in window) { <span id="L1218" class="LineNr">1218 </span> <span class="Delimiter">);</span> <span id="L1219" class="LineNr">1219 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L1220" class="LineNr">1220 </span> <span class="Constant">"run: copy imm32 to r/m32\n"</span> -<span id="L1221" class="LineNr">1221 </span> <span class="Constant">"run: effective address is 0x00000060 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> +<span id="L1221" class="LineNr">1221 </span> <span class="Constant">"run: effective address is 0x00000060 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> <span id="L1222" class="LineNr">1222 </span> <span class="Constant">"run: imm32 is 0x0d0c0b0a\n"</span> <span id="L1223" class="LineNr">1223 </span> <span class="Delimiter">);</span> <span id="L1224" class="LineNr">1224 </span><span class="Delimiter">}</span> <span id="L1225" class="LineNr">1225 </span> <span id="L1226" class="LineNr">1226 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L1227" class="LineNr">1227 </span><span class="Normal">case</span> <span class="Constant">0xc7</span>: <span class="Delimiter">{</span> <span class="Comment">// copy imm32 to r32</span> -<span id="L1228" class="LineNr">1228 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L1228" class="LineNr">1228 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L1229" class="LineNr">1229 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy imm32 to r/m32"</span> << end<span class="Delimiter">();</span> <span id="L1230" class="LineNr">1230 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> subop = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span class="Comment">// middle 3 'reg opcode' bits</span> <span id="L1231" class="LineNr">1231 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>subop != <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L1232" class="LineNr">1232 </span> cerr << <span class="Constant">"unrecognized subop for opcode c7: "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="Constant">" (only 0/copy currently implemented)\n"</span><span class="Delimiter">;</span> +<span id="L1232" class="LineNr">1232 </span> cerr << <span class="Constant">"unrecognized subop for opcode c7: "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="Constant">" (only 0/copy currently implemented)\n"</span><span class="Delimiter">;</span> <span id="L1233" class="LineNr">1233 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L1234" class="LineNr">1234 </span> <span class="Delimiter">}</span> <span id="L1235" class="LineNr">1235 </span> <span class="Normal">int32_t</span>* dest = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L1236" class="LineNr">1236 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> src = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L1237" class="LineNr">1237 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"imm32 is 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << src << end<span class="Delimiter">();</span> +<span id="L1236" class="LineNr">1236 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> src = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L1237" class="LineNr">1237 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"imm32 is 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << src << end<span class="Delimiter">();</span> <span id="L1238" class="LineNr">1238 </span> *dest = src<span class="Delimiter">;</span> <span id="L1239" class="LineNr">1239 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1240" class="LineNr">1240 </span><span class="Delimiter">}</span> @@ -1303,32 +1303,32 @@ if ('onhashchange' in window) { <span id="L1242" class="LineNr">1242 </span><span class="SalientComment">//:: push</span> <span id="L1243" class="LineNr">1243 </span> <span id="L1244" class="LineNr">1244 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L1245" class="LineNr">1245 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"68"</span><span class="Delimiter">,</span> <span class="Constant">"push imm32 to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> +<span id="L1245" class="LineNr">1245 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"68"</span><span class="Delimiter">,</span> <span class="Constant">"push imm32 to stack (<a href='012elf.cc.html#L94'>push</a>)"</span><span class="Delimiter">);</span> <span id="L1246" class="LineNr">1246 </span> <span id="L1247" class="LineNr">1247 </span><span class="Delimiter">:(code)</span> <span id="L1248" class="LineNr">1248 </span><span class="Normal">void</span> <a href='015immediate_addressing.cc.html#L1248'>test_push_imm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L1249" class="LineNr">1249 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> -<span id="L1250" class="LineNr">1250 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000014</span><span class="Delimiter">;</span> -<span id="L1251" class="LineNr">1251 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L1249" class="LineNr">1249 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> +<span id="L1250" class="LineNr">1250 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000014</span><span class="Delimiter">;</span> +<span id="L1251" class="LineNr">1251 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L1252" class="LineNr">1252 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L1253" class="LineNr">1253 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L1254" class="LineNr">1254 </span> <span class="Constant">" 68 af 00 00 00 \n"</span> <span class="Comment">// push *EAX to stack</span> <span id="L1255" class="LineNr">1255 </span> <span class="Delimiter">);</span> <span id="L1256" class="LineNr">1256 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L1257" class="LineNr">1257 </span> <span class="Constant">"run: <a href='012elf.cc.html#L94'>push</a> imm32 0x000000af\n"</span> -<span id="L1258" class="LineNr">1258 </span> <span class="Constant">"run: <a href='010---vm.cc.html#L20'>ESP</a> is now 0xbd000010\n"</span> -<span id="L1259" class="LineNr">1259 </span> <span class="Constant">"run: <a href='003trace.cc.html#L117'>contents</a> at <a href='010---vm.cc.html#L20'>ESP</a>: 0x000000af\n"</span> +<span id="L1258" class="LineNr">1258 </span> <span class="Constant">"run: <a href='010---vm.cc.html#L14'>ESP</a> is now 0xbd000010\n"</span> +<span id="L1259" class="LineNr">1259 </span> <span class="Constant">"run: <a href='003trace.cc.html#L117'>contents</a> at <a href='010---vm.cc.html#L14'>ESP</a>: 0x000000af\n"</span> <span id="L1260" class="LineNr">1260 </span> <span class="Delimiter">);</span> <span id="L1261" class="LineNr">1261 </span><span class="Delimiter">}</span> <span id="L1262" class="LineNr">1262 </span> <span id="L1263" class="LineNr">1263 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L1264" class="LineNr">1264 </span><span class="Normal">case</span> <span class="Constant">0x68</span>: <span class="Delimiter">{</span> -<span id="L1265" class="LineNr">1265 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> val = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span><a href='011run.cc.html#L447'>next32</a><span class="Delimiter">());</span> -<span id="L1266" class="LineNr">1266 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"push imm32 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << val << end<span class="Delimiter">();</span> +<span id="L1265" class="LineNr">1265 </span> <span class="Normal">const</span> <span class="Normal">uint32_t</span> val = <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span><a href='011run.cc.html#L433'>next32</a><span class="Delimiter">());</span> +<span id="L1266" class="LineNr">1266 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"push imm32 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << val << end<span class="Delimiter">();</span> <span id="L1267" class="LineNr">1267 </span><span class="CommentedCode">//? cerr << "push: " << val << " => " << Reg[ESP].u << '\n';</span> <span id="L1268" class="LineNr">1268 </span> <a href='012elf.cc.html#L94'>push</a><span class="Delimiter">(</span>val<span class="Delimiter">);</span> -<span id="L1269" class="LineNr">1269 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"ESP is now 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> -<span id="L1270" class="LineNr">1270 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"contents at <a href='010---vm.cc.html#L20'>ESP</a>: 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L1269" class="LineNr">1269 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"ESP is now 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L1270" class="LineNr">1270 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"contents at <a href='010---vm.cc.html#L14'>ESP</a>: 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L1271" class="LineNr">1271 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L1272" class="LineNr">1272 </span><span class="Delimiter">}</span> </pre> diff --git a/html/016index_addressing.cc.html b/html/016index_addressing.cc.html index a50dfd81..e64badfc 100644 --- a/html/016index_addressing.cc.html +++ b/html/016index_addressing.cc.html @@ -60,9 +60,9 @@ if ('onhashchange' in window) { <span id="L2" class="LineNr"> 2 </span> <span id="L3" class="LineNr"> 3 </span><span class="Delimiter">:(code)</span> <span id="L4" class="LineNr"> 4 </span><span class="Normal">void</span> <a href='016index_addressing.cc.html#L4'>test_add_r32_to_mem_at_r32_with_sib</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L5" class="LineNr"> 5 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> -<span id="L6" class="LineNr"> 6 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L7" class="LineNr"> 7 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L5" class="LineNr"> 5 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> +<span id="L6" class="LineNr"> 6 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L7" class="LineNr"> 7 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L8" class="LineNr"> 8 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L9" class="LineNr"> 9 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L10" class="LineNr"> 10 </span> <span class="Constant">" 01 1c 20 \n"</span> <span class="Comment">// add EBX to *EAX</span> @@ -72,8 +72,8 @@ if ('onhashchange' in window) { <span id="L14" class="LineNr"> 14 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L15" class="LineNr"> 15 </span> <span class="Delimiter">);</span> <span id="L16" class="LineNr"> 16 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L17" class="LineNr"> 17 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L18" class="LineNr"> 18 </span> <span class="Constant">"run: effective address is initially 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L17" class="LineNr"> 17 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L18" class="LineNr"> 18 </span> <span class="Constant">"run: effective address is initially 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L19" class="LineNr"> 19 </span> <span class="Constant">"run: effective address is 0x00002000\n"</span> <span id="L20" class="LineNr"> 20 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L21" class="LineNr"> 21 </span> <span class="Delimiter">);</span> @@ -85,37 +85,37 @@ if ('onhashchange' in window) { <span id="L27" class="LineNr"> 27 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L28" class="LineNr"> 28 </span><span class="Delimiter">:(code)</span> <span id="L29" class="LineNr"> 29 </span><span class="Normal">uint32_t</span> <a href='016index_addressing.cc.html#L29'>effective_address_from_sib</a><span class="Delimiter">(</span><span class="Normal">uint8_t</span> mod<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L30" class="LineNr"> 30 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> sib = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L30" class="LineNr"> 30 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> sib = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L31" class="LineNr"> 31 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> base = sib&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L32" class="LineNr"> 32 </span> <span class="Normal">uint32_t</span> addr = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L33" class="LineNr"> 33 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>base != <a href='010---vm.cc.html#L21'>EBP</a> || mod != <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L34" class="LineNr"> 34 </span> addr = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[base]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L35" class="LineNr"> 35 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is initially 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" ("</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>base<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> +<span id="L33" class="LineNr"> 33 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>base != <a href='010---vm.cc.html#L15'>EBP</a> || mod != <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L34" class="LineNr"> 34 </span> addr = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[base]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L35" class="LineNr"> 35 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is initially 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" ("</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>base<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> <span id="L36" class="LineNr"> 36 </span> <span class="Delimiter">}</span> <span id="L37" class="LineNr"> 37 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> <span id="L38" class="LineNr"> 38 </span> <span class="Comment">// base == EBP && mod == 0</span> -<span id="L39" class="LineNr"> 39 </span> addr = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> <span class="Comment">// ignore base</span> -<span id="L40" class="LineNr"> 40 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is initially 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" (<a href='040---tests.cc.html#L84'>disp32</a>)"</span> << end<span class="Delimiter">();</span> +<span id="L39" class="LineNr"> 39 </span> addr = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> <span class="Comment">// ignore base</span> +<span id="L40" class="LineNr"> 40 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is initially 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" (<a href='040---tests.cc.html#L82'>disp32</a>)"</span> << end<span class="Delimiter">();</span> <span id="L41" class="LineNr"> 41 </span> <span class="Delimiter">}</span> <span id="L42" class="LineNr"> 42 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> index = <span class="Delimiter">(</span>sib>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> -<span id="L43" class="LineNr"> 43 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>index == <a href='010---vm.cc.html#L20'>ESP</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L43" class="LineNr"> 43 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>index == <a href='010---vm.cc.html#L14'>ESP</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L44" class="LineNr"> 44 </span> <span class="Comment">// ignore index and scale</span> -<span id="L45" class="LineNr"> 45 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << end<span class="Delimiter">();</span> +<span id="L45" class="LineNr"> 45 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << end<span class="Delimiter">();</span> <span id="L46" class="LineNr"> 46 </span> <span class="Delimiter">}</span> <span id="L47" class="LineNr"> 47 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> <span id="L48" class="LineNr"> 48 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> scale = <span class="Delimiter">(</span><span class="Constant">1</span> << <span class="Delimiter">(</span>sib>><span class="Constant">6</span><span class="Delimiter">));</span> -<span id="L49" class="LineNr"> 49 </span> addr += <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[index]<span class="Delimiter">.</span>i*scale<span class="Delimiter">;</span> <span class="Comment">// treat index register as signed. Maybe base as well? But we'll always ensure it's non-negative.</span> -<span id="L50" class="LineNr"> 50 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" (after adding "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>index<span class="Delimiter">)</span> << <span class="Constant">"*"</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>scale<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> +<span id="L49" class="LineNr"> 49 </span> addr += <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[index]<span class="Delimiter">.</span>i*scale<span class="Delimiter">;</span> <span class="Comment">// treat index register as signed. Maybe base as well? But we'll always ensure it's non-negative.</span> +<span id="L50" class="LineNr"> 50 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"effective address is 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" (after adding "</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>index<span class="Delimiter">)</span> << <span class="Constant">"*"</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>scale<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<span class="Delimiter">();</span> <span id="L51" class="LineNr"> 51 </span> <span class="Delimiter">}</span> <span id="L52" class="LineNr"> 52 </span> <span class="Identifier">return</span> addr<span class="Delimiter">;</span> <span id="L53" class="LineNr"> 53 </span><span class="Delimiter">}</span> <span id="L54" class="LineNr"> 54 </span> <span id="L55" class="LineNr"> 55 </span><span class="Delimiter">:(code)</span> <span id="L56" class="LineNr"> 56 </span><span class="Normal">void</span> <a href='016index_addressing.cc.html#L56'>test_add_r32_to_mem_at_base_r32_index_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L57" class="LineNr"> 57 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> -<span id="L58" class="LineNr"> 58 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x1ffe</span><span class="Delimiter">;</span> <span class="Comment">// dest base</span> -<span id="L59" class="LineNr"> 59 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">0x2</span><span class="Delimiter">;</span> <span class="Comment">// dest index</span> -<span id="L60" class="LineNr"> 60 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L57" class="LineNr"> 57 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> +<span id="L58" class="LineNr"> 58 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x1ffe</span><span class="Delimiter">;</span> <span class="Comment">// dest base</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">0x2</span><span class="Delimiter">;</span> <span class="Comment">// dest index</span> +<span id="L60" class="LineNr"> 60 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L61" class="LineNr"> 61 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L62" class="LineNr"> 62 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L63" class="LineNr"> 63 </span> <span class="Constant">" 01 1c 08 \n"</span> <span class="Comment">// add EBX to *(EAX+ECX)</span> @@ -125,8 +125,8 @@ if ('onhashchange' in window) { <span id="L67" class="LineNr"> 67 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L68" class="LineNr"> 68 </span> <span class="Delimiter">);</span> <span id="L69" class="LineNr"> 69 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L70" class="LineNr"> 70 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L71" class="LineNr"> 71 </span> <span class="Constant">"run: effective address is initially 0x00001ffe (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L70" class="LineNr"> 70 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L71" class="LineNr"> 71 </span> <span class="Constant">"run: effective address is initially 0x00001ffe (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L72" class="LineNr"> 72 </span> <span class="Constant">"run: effective address is 0x00002000 (after adding ECX*1)\n"</span> <span id="L73" class="LineNr"> 73 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L74" class="LineNr"> 74 </span> <span class="Delimiter">);</span> @@ -134,8 +134,8 @@ if ('onhashchange' in window) { <span id="L76" class="LineNr"> 76 </span> <span id="L77" class="LineNr"> 77 </span><span class="Delimiter">:(code)</span> <span id="L78" class="LineNr"> 78 </span><span class="Normal">void</span> <a href='016index_addressing.cc.html#L78'>test_add_r32_to_mem_at_displacement_using_sib</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L79" class="LineNr"> 79 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> -<span id="L80" class="LineNr"> 80 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L79" class="LineNr"> 79 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> +<span id="L80" class="LineNr"> 80 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L81" class="LineNr"> 81 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L82" class="LineNr"> 82 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L83" class="LineNr"> 83 </span> <span class="Constant">" 01 1c 25 00 20 00 00 \n"</span> <span class="Comment">// add EBX to *0x2000</span> @@ -145,8 +145,8 @@ if ('onhashchange' in window) { <span id="L87" class="LineNr"> 87 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L88" class="LineNr"> 88 </span> <span class="Delimiter">);</span> <span id="L89" class="LineNr"> 89 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L90" class="LineNr"> 90 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L91" class="LineNr"> 91 </span> <span class="Constant">"run: effective address is initially 0x00002000 (<a href='040---tests.cc.html#L84'>disp32</a>)\n"</span> +<span id="L90" class="LineNr"> 90 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L91" class="LineNr"> 91 </span> <span class="Constant">"run: effective address is initially 0x00002000 (<a href='040---tests.cc.html#L82'>disp32</a>)\n"</span> <span id="L92" class="LineNr"> 92 </span> <span class="Constant">"run: effective address is 0x00002000\n"</span> <span id="L93" class="LineNr"> 93 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L94" class="LineNr"> 94 </span> <span class="Delimiter">);</span> @@ -156,10 +156,10 @@ if ('onhashchange' in window) { <span id="L98" class="LineNr"> 98 </span> <span id="L99" class="LineNr"> 99 </span><span class="Delimiter">:(code)</span> <span id="L100" class="LineNr">100 </span><span class="Normal">void</span> <a href='016index_addressing.cc.html#L100'>test_add_r32_to_mem_at_base_r32_index_r32_plus_disp8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L101" class="LineNr">101 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> -<span id="L102" class="LineNr">102 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x1ff9</span><span class="Delimiter">;</span> <span class="Comment">// dest base</span> -<span id="L103" class="LineNr">103 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">0x5</span><span class="Delimiter">;</span> <span class="Comment">// dest index</span> -<span id="L104" class="LineNr">104 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L101" class="LineNr">101 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> +<span id="L102" class="LineNr">102 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x1ff9</span><span class="Delimiter">;</span> <span class="Comment">// dest base</span> +<span id="L103" class="LineNr">103 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">0x5</span><span class="Delimiter">;</span> <span class="Comment">// dest index</span> +<span id="L104" class="LineNr">104 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L105" class="LineNr">105 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L106" class="LineNr">106 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L107" class="LineNr">107 </span> <span class="Constant">" 01 5c 08 02 \n"</span> <span class="Comment">// add EBX to *(EAX+ECX+2)</span> @@ -169,8 +169,8 @@ if ('onhashchange' in window) { <span id="L111" class="LineNr">111 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L112" class="LineNr">112 </span> <span class="Delimiter">);</span> <span id="L113" class="LineNr">113 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L114" class="LineNr">114 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L115" class="LineNr">115 </span> <span class="Constant">"run: effective address is initially 0x00001ff9 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L114" class="LineNr">114 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L115" class="LineNr">115 </span> <span class="Constant">"run: effective address is initially 0x00001ff9 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L116" class="LineNr">116 </span> <span class="Constant">"run: effective address is 0x00001ffe (after adding ECX*1)\n"</span> <span id="L117" class="LineNr">117 </span> <span class="Constant">"run: effective address is 0x00002000 (after adding disp8)\n"</span> <span id="L118" class="LineNr">118 </span> <span class="Constant">"run: storing 0x00000011\n"</span> @@ -186,10 +186,10 @@ if ('onhashchange' in window) { <span id="L128" class="LineNr">128 </span> <span id="L129" class="LineNr">129 </span><span class="Delimiter">:(code)</span> <span id="L130" class="LineNr">130 </span><span class="Normal">void</span> <a href='016index_addressing.cc.html#L130'>test_add_r32_to_mem_at_base_r32_index_r32_plus_disp32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L131" class="LineNr">131 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> -<span id="L132" class="LineNr">132 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x1ff9</span><span class="Delimiter">;</span> <span class="Comment">// dest base</span> -<span id="L133" class="LineNr">133 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">0x5</span><span class="Delimiter">;</span> <span class="Comment">// dest index</span> -<span id="L134" class="LineNr">134 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L131" class="LineNr">131 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x10</span><span class="Delimiter">;</span> <span class="Comment">// source</span> +<span id="L132" class="LineNr">132 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x1ff9</span><span class="Delimiter">;</span> <span class="Comment">// dest base</span> +<span id="L133" class="LineNr">133 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>i = <span class="Constant">0x5</span><span class="Delimiter">;</span> <span class="Comment">// dest index</span> +<span id="L134" class="LineNr">134 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L135" class="LineNr">135 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L136" class="LineNr">136 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L137" class="LineNr">137 </span> <span class="Constant">" 01 9c 08 02 00 00 00 \n"</span> <span class="Comment">// add EBX to *(EAX+ECX+2)</span> @@ -199,10 +199,10 @@ if ('onhashchange' in window) { <span id="L141" class="LineNr">141 </span> <span class="Constant">"01 00 00 00\n"</span> <span class="Comment">// 0x00000001</span> <span id="L142" class="LineNr">142 </span> <span class="Delimiter">);</span> <span id="L143" class="LineNr">143 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L144" class="LineNr">144 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L19'>EBX</a> to r/m32\n"</span> -<span id="L145" class="LineNr">145 </span> <span class="Constant">"run: effective address is initially 0x00001ff9 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L144" class="LineNr">144 </span> <span class="Constant">"run: add <a href='010---vm.cc.html#L13'>EBX</a> to r/m32\n"</span> +<span id="L145" class="LineNr">145 </span> <span class="Constant">"run: effective address is initially 0x00001ff9 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L146" class="LineNr">146 </span> <span class="Constant">"run: effective address is 0x00001ffe (after adding ECX*1)\n"</span> -<span id="L147" class="LineNr">147 </span> <span class="Constant">"run: effective address is 0x00002000 (after adding <a href='040---tests.cc.html#L84'>disp32</a>)\n"</span> +<span id="L147" class="LineNr">147 </span> <span class="Constant">"run: effective address is 0x00002000 (after adding <a href='040---tests.cc.html#L82'>disp32</a>)\n"</span> <span id="L148" class="LineNr">148 </span> <span class="Constant">"run: storing 0x00000011\n"</span> <span id="L149" class="LineNr">149 </span> <span class="Delimiter">);</span> <span id="L150" class="LineNr">150 </span><span class="Delimiter">}</span> diff --git a/html/017jump_disp8.cc.html b/html/017jump_disp8.cc.html index e1393a3c..39c3acc3 100644 --- a/html/017jump_disp8.cc.html +++ b/html/017jump_disp8.cc.html @@ -62,11 +62,11 @@ if ('onhashchange' in window) { <span id="L3" class="LineNr"> 3 </span><span class="SalientComment">//:: jump</span> <span id="L4" class="LineNr"> 4 </span> <span id="L5" class="LineNr"> 5 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L6" class="LineNr"> 6 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"eb"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away (jmp)"</span><span class="Delimiter">);</span> +<span id="L6" class="LineNr"> 6 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"eb"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away (jmp)"</span><span class="Delimiter">);</span> <span id="L7" class="LineNr"> 7 </span> <span id="L8" class="LineNr"> 8 </span><span class="Delimiter">:(code)</span> <span id="L9" class="LineNr"> 9 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L9'>test_jump_disp8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L10" class="LineNr"> 10 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L10" class="LineNr"> 10 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L11" class="LineNr"> 11 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L12" class="LineNr"> 12 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L13" class="LineNr"> 13 </span> <span class="Constant">" eb 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -83,21 +83,21 @@ if ('onhashchange' in window) { <span id="L24" class="LineNr"> 24 </span> <span id="L25" class="LineNr"> 25 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L26" class="LineNr"> 26 </span><span class="Normal">case</span> <span class="Constant">0xeb</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8</span> -<span id="L27" class="LineNr"> 27 </span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> -<span id="L28" class="LineNr"> 28 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L29" class="LineNr"> 29 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L27" class="LineNr"> 27 </span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> +<span id="L28" class="LineNr"> 28 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L29" class="LineNr"> 29 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L30" class="LineNr"> 30 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L31" class="LineNr"> 31 </span><span class="Delimiter">}</span> <span id="L32" class="LineNr"> 32 </span> <span id="L33" class="LineNr"> 33 </span><span class="SalientComment">//:: jump if equal/zero</span> <span id="L34" class="LineNr"> 34 </span> <span id="L35" class="LineNr"> 35 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L36" class="LineNr"> 36 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"74"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if equal, if <a href='010---vm.cc.html#L86'>ZF</a> is set (jcc/jz/je)"</span><span class="Delimiter">);</span> +<span id="L36" class="LineNr"> 36 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"74"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if equal, if <a href='010---vm.cc.html#L80'>ZF</a> is set (jcc/jz/je)"</span><span class="Delimiter">);</span> <span id="L37" class="LineNr"> 37 </span> <span id="L38" class="LineNr"> 38 </span><span class="Delimiter">:(code)</span> <span id="L39" class="LineNr"> 39 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L39'>test_je_disp8_success</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L40" class="LineNr"> 40 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L41" class="LineNr"> 41 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L40" class="LineNr"> 40 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L41" class="LineNr"> 41 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L42" class="LineNr"> 42 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L43" class="LineNr"> 43 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L44" class="LineNr"> 44 </span> <span class="Constant">" 74 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -114,18 +114,18 @@ if ('onhashchange' in window) { <span id="L55" class="LineNr"> 55 </span> <span id="L56" class="LineNr"> 56 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L57" class="LineNr"> 57 </span><span class="Normal">case</span> <span class="Constant">0x74</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8 if ZF</span> -<span id="L58" class="LineNr"> 58 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> -<span id="L59" class="LineNr"> 59 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L86'>ZF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L60" class="LineNr"> 60 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L61" class="LineNr"> 61 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L58" class="LineNr"> 58 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L80'>ZF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L60" class="LineNr"> 60 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L61" class="LineNr"> 61 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L62" class="LineNr"> 62 </span> <span class="Delimiter">}</span> <span id="L63" class="LineNr"> 63 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L64" class="LineNr"> 64 </span><span class="Delimiter">}</span> <span id="L65" class="LineNr"> 65 </span> <span id="L66" class="LineNr"> 66 </span><span class="Delimiter">:(code)</span> <span id="L67" class="LineNr"> 67 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L67'>test_je_disp8_fail</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L68" class="LineNr"> 68 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L69" class="LineNr"> 69 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L68" class="LineNr"> 68 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L69" class="LineNr"> 69 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L70" class="LineNr"> 70 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L71" class="LineNr"> 71 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L72" class="LineNr"> 72 </span> <span class="Constant">" 74 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -143,12 +143,12 @@ if ('onhashchange' in window) { <span id="L84" class="LineNr"> 84 </span><span class="SalientComment">//:: jump if not equal/not zero</span> <span id="L85" class="LineNr"> 85 </span> <span id="L86" class="LineNr"> 86 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L87" class="LineNr"> 87 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"75"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if not equal, if <a href='010---vm.cc.html#L86'>ZF</a> is not set (jcc/jnz/jne)"</span><span class="Delimiter">);</span> +<span id="L87" class="LineNr"> 87 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"75"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if not equal, if <a href='010---vm.cc.html#L80'>ZF</a> is not set (jcc/jnz/jne)"</span><span class="Delimiter">);</span> <span id="L88" class="LineNr"> 88 </span> <span id="L89" class="LineNr"> 89 </span><span class="Delimiter">:(code)</span> <span id="L90" class="LineNr"> 90 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L90'>test_jne_disp8_success</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L91" class="LineNr"> 91 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L92" class="LineNr"> 92 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L91" class="LineNr"> 91 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L92" class="LineNr"> 92 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L93" class="LineNr"> 93 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L94" class="LineNr"> 94 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L95" class="LineNr"> 95 </span> <span class="Constant">" 75 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -165,18 +165,18 @@ if ('onhashchange' in window) { <span id="L106" class="LineNr">106 </span> <span id="L107" class="LineNr">107 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L108" class="LineNr">108 </span><span class="Normal">case</span> <span class="Constant">0x75</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8 unless ZF</span> -<span id="L109" class="LineNr">109 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> +<span id="L109" class="LineNr">109 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> <span id="L110" class="LineNr">110 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!ZF<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L111" class="LineNr">111 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L112" class="LineNr">112 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L111" class="LineNr">111 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L112" class="LineNr">112 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L113" class="LineNr">113 </span> <span class="Delimiter">}</span> <span id="L114" class="LineNr">114 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L115" class="LineNr">115 </span><span class="Delimiter">}</span> <span id="L116" class="LineNr">116 </span> <span id="L117" class="LineNr">117 </span><span class="Delimiter">:(code)</span> <span id="L118" class="LineNr">118 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L118'>test_jne_disp8_fail</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L119" class="LineNr">119 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L120" class="LineNr">120 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L119" class="LineNr">119 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L120" class="LineNr">120 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L121" class="LineNr">121 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L122" class="LineNr">122 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L123" class="LineNr">123 </span> <span class="Constant">" 75 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -194,15 +194,15 @@ if ('onhashchange' in window) { <span id="L135" class="LineNr">135 </span><span class="SalientComment">//:: jump if greater</span> <span id="L136" class="LineNr">136 </span> <span id="L137" class="LineNr">137 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L138" class="LineNr">138 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"7f"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if greater (signed), if <a href='010---vm.cc.html#L86'>ZF</a> is unset and SF == <a href='010---vm.cc.html#L88'>OF</a> (jcc/jg/jnle)"</span><span class="Delimiter">);</span> -<span id="L139" class="LineNr">139 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"77"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if greater (unsigned), if <a href='010---vm.cc.html#L86'>ZF</a> is unset and <a href='010---vm.cc.html#L87'>CF</a> is unset (jcc/ja/jnbe)"</span><span class="Delimiter">);</span> +<span id="L138" class="LineNr">138 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"7f"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if greater (signed), if <a href='010---vm.cc.html#L80'>ZF</a> is unset and SF == <a href='010---vm.cc.html#L82'>OF</a> (jcc/jg/jnle)"</span><span class="Delimiter">);</span> +<span id="L139" class="LineNr">139 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"77"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if greater (unsigned), if <a href='010---vm.cc.html#L80'>ZF</a> is unset and <a href='010---vm.cc.html#L81'>CF</a> is unset (jcc/ja/jnbe)"</span><span class="Delimiter">);</span> <span id="L140" class="LineNr">140 </span> <span id="L141" class="LineNr">141 </span><span class="Delimiter">:(code)</span> <span id="L142" class="LineNr">142 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L142'>test_jg_disp8_success</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L143" class="LineNr">143 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L143" class="LineNr">143 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L144" class="LineNr">144 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L145" class="LineNr">145 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L146" class="LineNr">146 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L145" class="LineNr">145 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L146" class="LineNr">146 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L147" class="LineNr">147 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L148" class="LineNr">148 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L149" class="LineNr">149 </span> <span class="Constant">" 7f 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -219,28 +219,28 @@ if ('onhashchange' in window) { <span id="L160" class="LineNr">160 </span> <span id="L161" class="LineNr">161 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L162" class="LineNr">162 </span><span class="Normal">case</span> <span class="Constant">0x7f</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8 if SF == OF and !ZF</span> -<span id="L163" class="LineNr">163 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> -<span id="L164" class="LineNr">164 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>SF == <a href='010---vm.cc.html#L88'>OF</a> && !ZF<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L165" class="LineNr">165 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L166" class="LineNr">166 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L163" class="LineNr">163 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> +<span id="L164" class="LineNr">164 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>SF == <a href='010---vm.cc.html#L82'>OF</a> && !ZF<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L165" class="LineNr">165 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L166" class="LineNr">166 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L167" class="LineNr">167 </span> <span class="Delimiter">}</span> <span id="L168" class="LineNr">168 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L169" class="LineNr">169 </span><span class="Delimiter">}</span> <span id="L170" class="LineNr">170 </span><span class="Normal">case</span> <span class="Constant">0x77</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8 if !CF and !ZF</span> -<span id="L171" class="LineNr">171 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> +<span id="L171" class="LineNr">171 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> <span id="L172" class="LineNr">172 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!CF && !ZF<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L173" class="LineNr">173 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L174" class="LineNr">174 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L173" class="LineNr">173 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L174" class="LineNr">174 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L175" class="LineNr">175 </span> <span class="Delimiter">}</span> <span id="L176" class="LineNr">176 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L177" class="LineNr">177 </span><span class="Delimiter">}</span> <span id="L178" class="LineNr">178 </span> <span id="L179" class="LineNr">179 </span><span class="Delimiter">:(code)</span> <span id="L180" class="LineNr">180 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L180'>test_jg_disp8_fail</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L181" class="LineNr">181 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L181" class="LineNr">181 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L182" class="LineNr">182 </span> SF = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L183" class="LineNr">183 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L184" class="LineNr">184 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L183" class="LineNr">183 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L184" class="LineNr">184 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L185" class="LineNr">185 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L186" class="LineNr">186 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L187" class="LineNr">187 </span> <span class="Constant">" 7f 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -258,14 +258,14 @@ if ('onhashchange' in window) { <span id="L199" class="LineNr">199 </span><span class="SalientComment">//:: jump if greater or equal</span> <span id="L200" class="LineNr">200 </span> <span id="L201" class="LineNr">201 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L202" class="LineNr">202 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"7d"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if greater or equal (signed), if SF == <a href='010---vm.cc.html#L88'>OF</a> (jcc/jge/jnl)"</span><span class="Delimiter">);</span> -<span id="L203" class="LineNr">203 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"73"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if greater or equal (unsigned), if <a href='010---vm.cc.html#L87'>CF</a> is unset (jcc/jae/jnb)"</span><span class="Delimiter">);</span> +<span id="L202" class="LineNr">202 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"7d"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if greater or equal (signed), if SF == <a href='010---vm.cc.html#L82'>OF</a> (jcc/jge/jnl)"</span><span class="Delimiter">);</span> +<span id="L203" class="LineNr">203 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"73"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if greater or equal (unsigned), if <a href='010---vm.cc.html#L81'>CF</a> is unset (jcc/jae/jnb)"</span><span class="Delimiter">);</span> <span id="L204" class="LineNr">204 </span> <span id="L205" class="LineNr">205 </span><span class="Delimiter">:(code)</span> <span id="L206" class="LineNr">206 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L206'>test_jge_disp8_success</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L207" class="LineNr">207 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L208" class="LineNr">208 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L209" class="LineNr">209 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L208" class="LineNr">208 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L209" class="LineNr">209 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L210" class="LineNr">210 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L211" class="LineNr">211 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L212" class="LineNr">212 </span> <span class="Constant">" 7d 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -282,18 +282,18 @@ if ('onhashchange' in window) { <span id="L223" class="LineNr">223 </span> <span id="L224" class="LineNr">224 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L225" class="LineNr">225 </span><span class="Normal">case</span> <span class="Constant">0x7d</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8 if SF == OF</span> -<span id="L226" class="LineNr">226 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> -<span id="L227" class="LineNr">227 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>SF == <a href='010---vm.cc.html#L88'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L228" class="LineNr">228 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L229" class="LineNr">229 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L226" class="LineNr">226 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> +<span id="L227" class="LineNr">227 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>SF == <a href='010---vm.cc.html#L82'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L228" class="LineNr">228 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L229" class="LineNr">229 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L230" class="LineNr">230 </span> <span class="Delimiter">}</span> <span id="L231" class="LineNr">231 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L232" class="LineNr">232 </span><span class="Delimiter">}</span> <span id="L233" class="LineNr">233 </span><span class="Normal">case</span> <span class="Constant">0x73</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8 if !CF</span> -<span id="L234" class="LineNr">234 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> +<span id="L234" class="LineNr">234 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> <span id="L235" class="LineNr">235 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!CF<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L236" class="LineNr">236 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L237" class="LineNr">237 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L236" class="LineNr">236 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L237" class="LineNr">237 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L238" class="LineNr">238 </span> <span class="Delimiter">}</span> <span id="L239" class="LineNr">239 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L240" class="LineNr">240 </span><span class="Delimiter">}</span> @@ -301,8 +301,8 @@ if ('onhashchange' in window) { <span id="L242" class="LineNr">242 </span><span class="Delimiter">:(code)</span> <span id="L243" class="LineNr">243 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L243'>test_jge_disp8_fail</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L244" class="LineNr">244 </span> SF = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L245" class="LineNr">245 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L246" class="LineNr">246 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L245" class="LineNr">245 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L246" class="LineNr">246 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L247" class="LineNr">247 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L248" class="LineNr">248 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L249" class="LineNr">249 </span> <span class="Constant">" 7d 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -320,15 +320,15 @@ if ('onhashchange' in window) { <span id="L261" class="LineNr">261 </span><span class="SalientComment">//:: jump if lesser</span> <span id="L262" class="LineNr">262 </span> <span id="L263" class="LineNr">263 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L264" class="LineNr">264 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"7c"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if lesser (signed), if SF != <a href='010---vm.cc.html#L88'>OF</a> (jcc/jl/jnge)"</span><span class="Delimiter">);</span> -<span id="L265" class="LineNr">265 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"72"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if lesser (unsigned), if <a href='010---vm.cc.html#L87'>CF</a> is set (jcc/jb/jnae)"</span><span class="Delimiter">);</span> +<span id="L264" class="LineNr">264 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"7c"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if lesser (signed), if SF != <a href='010---vm.cc.html#L82'>OF</a> (jcc/jl/jnge)"</span><span class="Delimiter">);</span> +<span id="L265" class="LineNr">265 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"72"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if lesser (unsigned), if <a href='010---vm.cc.html#L81'>CF</a> is set (jcc/jb/jnae)"</span><span class="Delimiter">);</span> <span id="L266" class="LineNr">266 </span> <span id="L267" class="LineNr">267 </span><span class="Delimiter">:(code)</span> <span id="L268" class="LineNr">268 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L268'>test_jl_disp8_success</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L269" class="LineNr">269 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L269" class="LineNr">269 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L270" class="LineNr">270 </span> SF = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L271" class="LineNr">271 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L272" class="LineNr">272 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L271" class="LineNr">271 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L272" class="LineNr">272 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L273" class="LineNr">273 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L274" class="LineNr">274 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L275" class="LineNr">275 </span> <span class="Constant">" 7c 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -345,28 +345,28 @@ if ('onhashchange' in window) { <span id="L286" class="LineNr">286 </span> <span id="L287" class="LineNr">287 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L288" class="LineNr">288 </span><span class="Normal">case</span> <span class="Constant">0x7c</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8 if SF != OF</span> -<span id="L289" class="LineNr">289 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> -<span id="L290" class="LineNr">290 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>SF != <a href='010---vm.cc.html#L88'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L291" class="LineNr">291 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L292" class="LineNr">292 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L289" class="LineNr">289 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> +<span id="L290" class="LineNr">290 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>SF != <a href='010---vm.cc.html#L82'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L291" class="LineNr">291 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L292" class="LineNr">292 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L293" class="LineNr">293 </span> <span class="Delimiter">}</span> <span id="L294" class="LineNr">294 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L295" class="LineNr">295 </span><span class="Delimiter">}</span> <span id="L296" class="LineNr">296 </span><span class="Normal">case</span> <span class="Constant">0x72</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8 if CF</span> -<span id="L297" class="LineNr">297 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> -<span id="L298" class="LineNr">298 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L87'>CF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L299" class="LineNr">299 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L300" class="LineNr">300 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L297" class="LineNr">297 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> +<span id="L298" class="LineNr">298 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L81'>CF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L299" class="LineNr">299 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L300" class="LineNr">300 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L301" class="LineNr">301 </span> <span class="Delimiter">}</span> <span id="L302" class="LineNr">302 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L303" class="LineNr">303 </span><span class="Delimiter">}</span> <span id="L304" class="LineNr">304 </span> <span id="L305" class="LineNr">305 </span><span class="Delimiter">:(code)</span> <span id="L306" class="LineNr">306 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L306'>test_jl_disp8_fail</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L307" class="LineNr">307 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L307" class="LineNr">307 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L308" class="LineNr">308 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L309" class="LineNr">309 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L310" class="LineNr">310 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L309" class="LineNr">309 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L310" class="LineNr">310 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L311" class="LineNr">311 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L312" class="LineNr">312 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L313" class="LineNr">313 </span> <span class="Constant">" 7c 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -384,15 +384,15 @@ if ('onhashchange' in window) { <span id="L325" class="LineNr">325 </span><span class="SalientComment">//:: jump if lesser or equal</span> <span id="L326" class="LineNr">326 </span> <span id="L327" class="LineNr">327 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L328" class="LineNr">328 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"7e"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if lesser or equal (signed), if <a href='010---vm.cc.html#L86'>ZF</a> is set or SF != <a href='010---vm.cc.html#L88'>OF</a> (jcc/jle/jng)"</span><span class="Delimiter">);</span> -<span id="L329" class="LineNr">329 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"76"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if lesser or equal (unsigned), if <a href='010---vm.cc.html#L86'>ZF</a> is set or <a href='010---vm.cc.html#L87'>CF</a> is set (jcc/jbe/jna)"</span><span class="Delimiter">);</span> +<span id="L328" class="LineNr">328 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"7e"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if lesser or equal (signed), if <a href='010---vm.cc.html#L80'>ZF</a> is set or SF != <a href='010---vm.cc.html#L82'>OF</a> (jcc/jle/jng)"</span><span class="Delimiter">);</span> +<span id="L329" class="LineNr">329 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"76"</span><span class="Delimiter">,</span> <span class="Constant">"jump disp8 bytes away if lesser or equal (unsigned), if <a href='010---vm.cc.html#L80'>ZF</a> is set or <a href='010---vm.cc.html#L81'>CF</a> is set (jcc/jbe/jna)"</span><span class="Delimiter">);</span> <span id="L330" class="LineNr">330 </span> <span id="L331" class="LineNr">331 </span><span class="Delimiter">:(code)</span> <span id="L332" class="LineNr">332 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L332'>test_jle_disp8_equal</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L333" class="LineNr">333 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L333" class="LineNr">333 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L334" class="LineNr">334 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L335" class="LineNr">335 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L336" class="LineNr">336 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L335" class="LineNr">335 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L336" class="LineNr">336 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L337" class="LineNr">337 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L338" class="LineNr">338 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L339" class="LineNr">339 </span> <span class="Constant">" 7e 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -409,10 +409,10 @@ if ('onhashchange' in window) { <span id="L350" class="LineNr">350 </span> <span id="L351" class="LineNr">351 </span><span class="Delimiter">:(code)</span> <span id="L352" class="LineNr">352 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L352'>test_jle_disp8_lesser</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L353" class="LineNr">353 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L353" class="LineNr">353 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L354" class="LineNr">354 </span> SF = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L355" class="LineNr">355 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L356" class="LineNr">356 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L355" class="LineNr">355 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L356" class="LineNr">356 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L357" class="LineNr">357 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L358" class="LineNr">358 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L359" class="LineNr">359 </span> <span class="Constant">" 7e 05 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -429,28 +429,28 @@ if ('onhashchange' in window) { <span id="L370" class="LineNr">370 </span> <span id="L371" class="LineNr">371 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L372" class="LineNr">372 </span><span class="Normal">case</span> <span class="Constant">0x7e</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8 if ZF or SF != OF</span> -<span id="L373" class="LineNr">373 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> -<span id="L374" class="LineNr">374 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L86'>ZF</a> || SF != <a href='010---vm.cc.html#L88'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L375" class="LineNr">375 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L376" class="LineNr">376 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L373" class="LineNr">373 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> +<span id="L374" class="LineNr">374 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L80'>ZF</a> || SF != <a href='010---vm.cc.html#L82'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L375" class="LineNr">375 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L376" class="LineNr">376 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L377" class="LineNr">377 </span> <span class="Delimiter">}</span> <span id="L378" class="LineNr">378 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L379" class="LineNr">379 </span><span class="Delimiter">}</span> <span id="L380" class="LineNr">380 </span><span class="Normal">case</span> <span class="Constant">0x76</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp8 if ZF or CF</span> -<span id="L381" class="LineNr">381 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">());</span> -<span id="L382" class="LineNr">382 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L86'>ZF</a> || <a href='010---vm.cc.html#L87'>CF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L383" class="LineNr">383 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L384" class="LineNr">384 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L381" class="LineNr">381 </span> <span class="Normal">const</span> <span class="Normal">int8_t</span> offset = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span><a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">());</span> +<span id="L382" class="LineNr">382 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L80'>ZF</a> || <a href='010---vm.cc.html#L81'>CF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L383" class="LineNr">383 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L384" class="LineNr">384 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L385" class="LineNr">385 </span> <span class="Delimiter">}</span> <span id="L386" class="LineNr">386 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L387" class="LineNr">387 </span><span class="Delimiter">}</span> <span id="L388" class="LineNr">388 </span> <span id="L389" class="LineNr">389 </span><span class="Delimiter">:(code)</span> <span id="L390" class="LineNr">390 </span><span class="Normal">void</span> <a href='017jump_disp8.cc.html#L390'>test_jle_disp8_greater</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L391" class="LineNr">391 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L391" class="LineNr">391 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L392" class="LineNr">392 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L393" class="LineNr">393 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L394" class="LineNr">394 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L393" class="LineNr">393 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L394" class="LineNr">394 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L395" class="LineNr">395 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L396" class="LineNr">396 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L397" class="LineNr">397 </span> <span class="Constant">" 7e 05 \n"</span> <span class="Comment">// skip 1 instruction</span> diff --git a/html/018jump_disp32.cc.html b/html/018jump_disp32.cc.html index abdccaa3..fe7ef115 100644 --- a/html/018jump_disp32.cc.html +++ b/html/018jump_disp32.cc.html @@ -62,11 +62,11 @@ if ('onhashchange' in window) { <span id="L3" class="LineNr"> 3 </span><span class="SalientComment">//:: jump</span> <span id="L4" class="LineNr"> 4 </span> <span id="L5" class="LineNr"> 5 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L6" class="LineNr"> 6 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"e9"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away (jmp)"</span><span class="Delimiter">);</span> +<span id="L6" class="LineNr"> 6 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"e9"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away (jmp)"</span><span class="Delimiter">);</span> <span id="L7" class="LineNr"> 7 </span> <span id="L8" class="LineNr"> 8 </span><span class="Delimiter">:(code)</span> <span id="L9" class="LineNr"> 9 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L9'>test_jump_disp32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L10" class="LineNr"> 10 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L10" class="LineNr"> 10 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L11" class="LineNr"> 11 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L12" class="LineNr"> 12 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L13" class="LineNr"> 13 </span> <span class="Constant">" e9 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -83,21 +83,21 @@ if ('onhashchange' in window) { <span id="L24" class="LineNr"> 24 </span> <span id="L25" class="LineNr"> 25 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L26" class="LineNr"> 26 </span><span class="Normal">case</span> <span class="Constant">0xe9</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32</span> -<span id="L27" class="LineNr"> 27 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> +<span id="L27" class="LineNr"> 27 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> <span id="L28" class="LineNr"> 28 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L29" class="LineNr"> 29 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L29" class="LineNr"> 29 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L30" class="LineNr"> 30 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L31" class="LineNr"> 31 </span><span class="Delimiter">}</span> <span id="L32" class="LineNr"> 32 </span> <span id="L33" class="LineNr"> 33 </span><span class="SalientComment">//:: jump if equal/zero</span> <span id="L34" class="LineNr"> 34 </span> <span id="L35" class="LineNr"> 35 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L36" class="LineNr"> 36 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"84"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if equal, if <a href='010---vm.cc.html#L86'>ZF</a> is set (jcc/jz/je)"</span><span class="Delimiter">);</span> +<span id="L36" class="LineNr"> 36 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"84"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if equal, if <a href='010---vm.cc.html#L80'>ZF</a> is set (jcc/jz/je)"</span><span class="Delimiter">);</span> <span id="L37" class="LineNr"> 37 </span> <span id="L38" class="LineNr"> 38 </span><span class="Delimiter">:(code)</span> <span id="L39" class="LineNr"> 39 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L39'>test_je_disp32_success</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L40" class="LineNr"> 40 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L41" class="LineNr"> 41 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L40" class="LineNr"> 40 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L41" class="LineNr"> 41 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L42" class="LineNr"> 42 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L43" class="LineNr"> 43 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L44" class="LineNr"> 44 </span> <span class="Constant">" 0f 84 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -114,18 +114,18 @@ if ('onhashchange' in window) { <span id="L55" class="LineNr"> 55 </span> <span id="L56" class="LineNr"> 56 </span><span class="Delimiter">:(before "End Two-Byte Opcodes Starting With 0f")</span> <span id="L57" class="LineNr"> 57 </span><span class="Normal">case</span> <span class="Constant">0x84</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 if ZF</span> -<span id="L58" class="LineNr"> 58 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L59" class="LineNr"> 59 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L86'>ZF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L58" class="LineNr"> 58 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L80'>ZF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L60" class="LineNr"> 60 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L61" class="LineNr"> 61 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L61" class="LineNr"> 61 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L62" class="LineNr"> 62 </span> <span class="Delimiter">}</span> <span id="L63" class="LineNr"> 63 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L64" class="LineNr"> 64 </span><span class="Delimiter">}</span> <span id="L65" class="LineNr"> 65 </span> <span id="L66" class="LineNr"> 66 </span><span class="Delimiter">:(code)</span> <span id="L67" class="LineNr"> 67 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L67'>test_je_disp32_fail</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L68" class="LineNr"> 68 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L69" class="LineNr"> 69 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L68" class="LineNr"> 68 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L69" class="LineNr"> 69 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L70" class="LineNr"> 70 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L71" class="LineNr"> 71 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L72" class="LineNr"> 72 </span> <span class="Constant">" 0f 84 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -143,12 +143,12 @@ if ('onhashchange' in window) { <span id="L84" class="LineNr"> 84 </span><span class="SalientComment">//:: jump if not equal/not zero</span> <span id="L85" class="LineNr"> 85 </span> <span id="L86" class="LineNr"> 86 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L87" class="LineNr"> 87 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"85"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if not equal, if <a href='010---vm.cc.html#L86'>ZF</a> is not set (jcc/jnz/jne)"</span><span class="Delimiter">);</span> +<span id="L87" class="LineNr"> 87 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"85"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if not equal, if <a href='010---vm.cc.html#L80'>ZF</a> is not set (jcc/jnz/jne)"</span><span class="Delimiter">);</span> <span id="L88" class="LineNr"> 88 </span> <span id="L89" class="LineNr"> 89 </span><span class="Delimiter">:(code)</span> <span id="L90" class="LineNr"> 90 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L90'>test_jne_disp32_success</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L91" class="LineNr"> 91 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L92" class="LineNr"> 92 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L91" class="LineNr"> 91 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L92" class="LineNr"> 92 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L93" class="LineNr"> 93 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L94" class="LineNr"> 94 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L95" class="LineNr"> 95 </span> <span class="Constant">" 0f 85 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -165,18 +165,18 @@ if ('onhashchange' in window) { <span id="L106" class="LineNr">106 </span> <span id="L107" class="LineNr">107 </span><span class="Delimiter">:(before "End Two-Byte Opcodes Starting With 0f")</span> <span id="L108" class="LineNr">108 </span><span class="Normal">case</span> <span class="Constant">0x85</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 unless ZF</span> -<span id="L109" class="LineNr">109 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> +<span id="L109" class="LineNr">109 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> <span id="L110" class="LineNr">110 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!ZF<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L111" class="LineNr">111 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L112" class="LineNr">112 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L112" class="LineNr">112 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L113" class="LineNr">113 </span> <span class="Delimiter">}</span> <span id="L114" class="LineNr">114 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L115" class="LineNr">115 </span><span class="Delimiter">}</span> <span id="L116" class="LineNr">116 </span> <span id="L117" class="LineNr">117 </span><span class="Delimiter">:(code)</span> <span id="L118" class="LineNr">118 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L118'>test_jne_disp32_fail</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L119" class="LineNr">119 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L120" class="LineNr">120 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L119" class="LineNr">119 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L120" class="LineNr">120 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L121" class="LineNr">121 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L122" class="LineNr">122 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L123" class="LineNr">123 </span> <span class="Constant">" 0f 85 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -194,15 +194,15 @@ if ('onhashchange' in window) { <span id="L135" class="LineNr">135 </span><span class="SalientComment">//:: jump if greater</span> <span id="L136" class="LineNr">136 </span> <span id="L137" class="LineNr">137 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L138" class="LineNr">138 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8f"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if greater (signed), if <a href='010---vm.cc.html#L86'>ZF</a> is unset and SF == <a href='010---vm.cc.html#L88'>OF</a> (jcc/jg/jnle)"</span><span class="Delimiter">);</span> -<span id="L139" class="LineNr">139 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"87"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if greater (unsigned), if <a href='010---vm.cc.html#L86'>ZF</a> is unset and <a href='010---vm.cc.html#L87'>CF</a> is unset (jcc/ja/jnbe)"</span><span class="Delimiter">);</span> +<span id="L138" class="LineNr">138 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8f"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if greater (signed), if <a href='010---vm.cc.html#L80'>ZF</a> is unset and SF == <a href='010---vm.cc.html#L82'>OF</a> (jcc/jg/jnle)"</span><span class="Delimiter">);</span> +<span id="L139" class="LineNr">139 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"87"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if greater (unsigned), if <a href='010---vm.cc.html#L80'>ZF</a> is unset and <a href='010---vm.cc.html#L81'>CF</a> is unset (jcc/ja/jnbe)"</span><span class="Delimiter">);</span> <span id="L140" class="LineNr">140 </span> <span id="L141" class="LineNr">141 </span><span class="Delimiter">:(code)</span> <span id="L142" class="LineNr">142 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L142'>test_jg_disp32_success</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L143" class="LineNr">143 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L143" class="LineNr">143 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L144" class="LineNr">144 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L145" class="LineNr">145 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L146" class="LineNr">146 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L145" class="LineNr">145 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L146" class="LineNr">146 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L147" class="LineNr">147 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L148" class="LineNr">148 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L149" class="LineNr">149 </span> <span class="Constant">" 0f 8f 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -219,28 +219,28 @@ if ('onhashchange' in window) { <span id="L160" class="LineNr">160 </span> <span id="L161" class="LineNr">161 </span><span class="Delimiter">:(before "End Two-Byte Opcodes Starting With 0f")</span> <span id="L162" class="LineNr">162 </span><span class="Normal">case</span> <span class="Constant">0x8f</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 if !SF and !ZF</span> -<span id="L163" class="LineNr">163 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L164" class="LineNr">164 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!ZF && SF == <a href='010---vm.cc.html#L88'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L163" class="LineNr">163 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L164" class="LineNr">164 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!ZF && SF == <a href='010---vm.cc.html#L82'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L165" class="LineNr">165 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L166" class="LineNr">166 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L166" class="LineNr">166 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L167" class="LineNr">167 </span> <span class="Delimiter">}</span> <span id="L168" class="LineNr">168 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L169" class="LineNr">169 </span><span class="Delimiter">}</span> <span id="L170" class="LineNr">170 </span><span class="Normal">case</span> <span class="Constant">0x87</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 if !CF and !ZF</span> -<span id="L171" class="LineNr">171 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L171" class="LineNr">171 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L172" class="LineNr">172 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!CF && !ZF<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L173" class="LineNr">173 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L174" class="LineNr">174 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L174" class="LineNr">174 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L175" class="LineNr">175 </span> <span class="Delimiter">}</span> <span id="L176" class="LineNr">176 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L177" class="LineNr">177 </span><span class="Delimiter">}</span> <span id="L178" class="LineNr">178 </span> <span id="L179" class="LineNr">179 </span><span class="Delimiter">:(code)</span> <span id="L180" class="LineNr">180 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L180'>test_jg_disp32_fail</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L181" class="LineNr">181 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L181" class="LineNr">181 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L182" class="LineNr">182 </span> SF = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L183" class="LineNr">183 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L184" class="LineNr">184 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L183" class="LineNr">183 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L184" class="LineNr">184 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L185" class="LineNr">185 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L186" class="LineNr">186 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L187" class="LineNr">187 </span> <span class="Constant">" 0f 8f 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -258,14 +258,14 @@ if ('onhashchange' in window) { <span id="L199" class="LineNr">199 </span><span class="SalientComment">//:: jump if greater or equal</span> <span id="L200" class="LineNr">200 </span> <span id="L201" class="LineNr">201 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L202" class="LineNr">202 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8d"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if greater or equal (signed), if SF == <a href='010---vm.cc.html#L88'>OF</a> (jcc/jge/jnl)"</span><span class="Delimiter">);</span> -<span id="L203" class="LineNr">203 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"83"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if greater or equal (unsigned), if <a href='010---vm.cc.html#L87'>CF</a> is unset (jcc/jae/jnb)"</span><span class="Delimiter">);</span> +<span id="L202" class="LineNr">202 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8d"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if greater or equal (signed), if SF == <a href='010---vm.cc.html#L82'>OF</a> (jcc/jge/jnl)"</span><span class="Delimiter">);</span> +<span id="L203" class="LineNr">203 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"83"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if greater or equal (unsigned), if <a href='010---vm.cc.html#L81'>CF</a> is unset (jcc/jae/jnb)"</span><span class="Delimiter">);</span> <span id="L204" class="LineNr">204 </span> <span id="L205" class="LineNr">205 </span><span class="Delimiter">:(code)</span> <span id="L206" class="LineNr">206 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L206'>test_jge_disp32_success</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L207" class="LineNr">207 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L208" class="LineNr">208 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L209" class="LineNr">209 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L208" class="LineNr">208 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L209" class="LineNr">209 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L210" class="LineNr">210 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L211" class="LineNr">211 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L212" class="LineNr">212 </span> <span class="Constant">" 0f 8d 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -282,18 +282,18 @@ if ('onhashchange' in window) { <span id="L223" class="LineNr">223 </span> <span id="L224" class="LineNr">224 </span><span class="Delimiter">:(before "End Two-Byte Opcodes Starting With 0f")</span> <span id="L225" class="LineNr">225 </span><span class="Normal">case</span> <span class="Constant">0x8d</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 if !SF</span> -<span id="L226" class="LineNr">226 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L227" class="LineNr">227 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>SF == <a href='010---vm.cc.html#L88'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L226" class="LineNr">226 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L227" class="LineNr">227 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>SF == <a href='010---vm.cc.html#L82'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L228" class="LineNr">228 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L229" class="LineNr">229 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L229" class="LineNr">229 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L230" class="LineNr">230 </span> <span class="Delimiter">}</span> <span id="L231" class="LineNr">231 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L232" class="LineNr">232 </span><span class="Delimiter">}</span> <span id="L233" class="LineNr">233 </span><span class="Normal">case</span> <span class="Constant">0x83</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 if !CF</span> -<span id="L234" class="LineNr">234 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> +<span id="L234" class="LineNr">234 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> <span id="L235" class="LineNr">235 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!CF<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L236" class="LineNr">236 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L237" class="LineNr">237 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L237" class="LineNr">237 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L238" class="LineNr">238 </span> <span class="Delimiter">}</span> <span id="L239" class="LineNr">239 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L240" class="LineNr">240 </span><span class="Delimiter">}</span> @@ -301,8 +301,8 @@ if ('onhashchange' in window) { <span id="L242" class="LineNr">242 </span><span class="Delimiter">:(code)</span> <span id="L243" class="LineNr">243 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L243'>test_jge_disp32_fail</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L244" class="LineNr">244 </span> SF = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L245" class="LineNr">245 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L246" class="LineNr">246 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L245" class="LineNr">245 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L246" class="LineNr">246 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L247" class="LineNr">247 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L248" class="LineNr">248 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L249" class="LineNr">249 </span> <span class="Constant">" 0f 8d 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -320,15 +320,15 @@ if ('onhashchange' in window) { <span id="L261" class="LineNr">261 </span><span class="SalientComment">//:: jump if lesser</span> <span id="L262" class="LineNr">262 </span> <span id="L263" class="LineNr">263 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L264" class="LineNr">264 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8c"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if lesser (signed), if SF != <a href='010---vm.cc.html#L88'>OF</a> (jcc/jl/jnge)"</span><span class="Delimiter">);</span> -<span id="L265" class="LineNr">265 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"82"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if lesser (unsigned), if <a href='010---vm.cc.html#L87'>CF</a> is set (jcc/jb/jnae)"</span><span class="Delimiter">);</span> +<span id="L264" class="LineNr">264 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8c"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if lesser (signed), if SF != <a href='010---vm.cc.html#L82'>OF</a> (jcc/jl/jnge)"</span><span class="Delimiter">);</span> +<span id="L265" class="LineNr">265 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"82"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if lesser (unsigned), if <a href='010---vm.cc.html#L81'>CF</a> is set (jcc/jb/jnae)"</span><span class="Delimiter">);</span> <span id="L266" class="LineNr">266 </span> <span id="L267" class="LineNr">267 </span><span class="Delimiter">:(code)</span> <span id="L268" class="LineNr">268 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L268'>test_jl_disp32_success</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L269" class="LineNr">269 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L269" class="LineNr">269 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L270" class="LineNr">270 </span> SF = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L271" class="LineNr">271 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L272" class="LineNr">272 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L271" class="LineNr">271 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L272" class="LineNr">272 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L273" class="LineNr">273 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L274" class="LineNr">274 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L275" class="LineNr">275 </span> <span class="Constant">" 0f 8c 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -345,28 +345,28 @@ if ('onhashchange' in window) { <span id="L286" class="LineNr">286 </span> <span id="L287" class="LineNr">287 </span><span class="Delimiter">:(before "End Two-Byte Opcodes Starting With 0f")</span> <span id="L288" class="LineNr">288 </span><span class="Normal">case</span> <span class="Constant">0x8c</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 if SF and !ZF</span> -<span id="L289" class="LineNr">289 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L290" class="LineNr">290 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>SF != <a href='010---vm.cc.html#L88'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L289" class="LineNr">289 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L290" class="LineNr">290 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>SF != <a href='010---vm.cc.html#L82'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L291" class="LineNr">291 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L292" class="LineNr">292 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L292" class="LineNr">292 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L293" class="LineNr">293 </span> <span class="Delimiter">}</span> <span id="L294" class="LineNr">294 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L295" class="LineNr">295 </span><span class="Delimiter">}</span> -<span id="L296" class="LineNr">296 </span><span class="Normal">case</span> <span class="Constant">0x72</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 if CF</span> -<span id="L297" class="LineNr">297 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L298" class="LineNr">298 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L87'>CF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L296" class="LineNr">296 </span><span class="Normal">case</span> <span class="Constant">0x82</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 if CF</span> +<span id="L297" class="LineNr">297 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L298" class="LineNr">298 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L81'>CF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L299" class="LineNr">299 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L300" class="LineNr">300 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L300" class="LineNr">300 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L301" class="LineNr">301 </span> <span class="Delimiter">}</span> <span id="L302" class="LineNr">302 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L303" class="LineNr">303 </span><span class="Delimiter">}</span> <span id="L304" class="LineNr">304 </span> <span id="L305" class="LineNr">305 </span><span class="Delimiter">:(code)</span> <span id="L306" class="LineNr">306 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L306'>test_jl_disp32_fail</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L307" class="LineNr">307 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L307" class="LineNr">307 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L308" class="LineNr">308 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L309" class="LineNr">309 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L310" class="LineNr">310 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L309" class="LineNr">309 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L310" class="LineNr">310 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L311" class="LineNr">311 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L312" class="LineNr">312 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L313" class="LineNr">313 </span> <span class="Constant">" 0f 8c 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -384,15 +384,15 @@ if ('onhashchange' in window) { <span id="L325" class="LineNr">325 </span><span class="SalientComment">//:: jump if lesser or equal</span> <span id="L326" class="LineNr">326 </span> <span id="L327" class="LineNr">327 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L328" class="LineNr">328 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8e"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if lesser or equal (signed), if <a href='010---vm.cc.html#L86'>ZF</a> is set or SF != <a href='010---vm.cc.html#L88'>OF</a> (jcc/jle/jng)"</span><span class="Delimiter">);</span> -<span id="L329" class="LineNr">329 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"86"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if lesser or equal (unsigned), if <a href='010---vm.cc.html#L86'>ZF</a> is set or <a href='010---vm.cc.html#L87'>CF</a> is set (jcc/jbe/jna)"</span><span class="Delimiter">);</span> +<span id="L328" class="LineNr">328 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8e"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if lesser or equal (signed), if <a href='010---vm.cc.html#L80'>ZF</a> is set or SF != <a href='010---vm.cc.html#L82'>OF</a> (jcc/jle/jng)"</span><span class="Delimiter">);</span> +<span id="L329" class="LineNr">329 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"86"</span><span class="Delimiter">,</span> <span class="Constant">"jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if lesser or equal (unsigned), if <a href='010---vm.cc.html#L80'>ZF</a> is set or <a href='010---vm.cc.html#L81'>CF</a> is set (jcc/jbe/jna)"</span><span class="Delimiter">);</span> <span id="L330" class="LineNr">330 </span> <span id="L331" class="LineNr">331 </span><span class="Delimiter">:(code)</span> <span id="L332" class="LineNr">332 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L332'>test_jle_disp32_equal</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L333" class="LineNr">333 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L333" class="LineNr">333 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L334" class="LineNr">334 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L335" class="LineNr">335 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L336" class="LineNr">336 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L335" class="LineNr">335 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L336" class="LineNr">336 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L337" class="LineNr">337 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L338" class="LineNr">338 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L339" class="LineNr">339 </span> <span class="Constant">" 0f 8e 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -409,10 +409,10 @@ if ('onhashchange' in window) { <span id="L350" class="LineNr">350 </span> <span id="L351" class="LineNr">351 </span><span class="Delimiter">:(code)</span> <span id="L352" class="LineNr">352 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L352'>test_jle_disp32_lesser</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L353" class="LineNr">353 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L353" class="LineNr">353 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L354" class="LineNr">354 </span> SF = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L355" class="LineNr">355 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L356" class="LineNr">356 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L355" class="LineNr">355 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L356" class="LineNr">356 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L357" class="LineNr">357 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L358" class="LineNr">358 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L359" class="LineNr">359 </span> <span class="Constant">" 0f 8e 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> @@ -429,28 +429,28 @@ if ('onhashchange' in window) { <span id="L370" class="LineNr">370 </span> <span id="L371" class="LineNr">371 </span><span class="Delimiter">:(before "End Two-Byte Opcodes Starting With 0f")</span> <span id="L372" class="LineNr">372 </span><span class="Normal">case</span> <span class="Constant">0x8e</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 if SF or ZF</span> -<span id="L373" class="LineNr">373 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L374" class="LineNr">374 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L86'>ZF</a> || SF != <a href='010---vm.cc.html#L88'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L373" class="LineNr">373 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L374" class="LineNr">374 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L80'>ZF</a> || SF != <a href='010---vm.cc.html#L82'>OF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L375" class="LineNr">375 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L376" class="LineNr">376 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L376" class="LineNr">376 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L377" class="LineNr">377 </span> <span class="Delimiter">}</span> <span id="L378" class="LineNr">378 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L379" class="LineNr">379 </span><span class="Delimiter">}</span> <span id="L380" class="LineNr">380 </span><span class="Normal">case</span> <span class="Constant">0x86</span>: <span class="Delimiter">{</span> <span class="Comment">// jump disp32 if ZF or CF</span> -<span id="L381" class="LineNr">381 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> -<span id="L382" class="LineNr">382 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L86'>ZF</a> || <a href='010---vm.cc.html#L87'>CF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L381" class="LineNr">381 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> +<span id="L382" class="LineNr">382 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='010---vm.cc.html#L80'>ZF</a> || <a href='010---vm.cc.html#L81'>CF</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L383" class="LineNr">383 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jump "</span> << offset << end<span class="Delimiter">();</span> -<span id="L384" class="LineNr">384 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L384" class="LineNr">384 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> <span id="L385" class="LineNr">385 </span> <span class="Delimiter">}</span> <span id="L386" class="LineNr">386 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L387" class="LineNr">387 </span><span class="Delimiter">}</span> <span id="L388" class="LineNr">388 </span> <span id="L389" class="LineNr">389 </span><span class="Delimiter">:(code)</span> <span id="L390" class="LineNr">390 </span><span class="Normal">void</span> <a href='018jump_disp32.cc.html#L390'>test_jle_disp32_greater</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L391" class="LineNr">391 </span> <a href='010---vm.cc.html#L86'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L391" class="LineNr">391 </span> <a href='010---vm.cc.html#L80'>ZF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L392" class="LineNr">392 </span> SF = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L393" class="LineNr">393 </span> <a href='010---vm.cc.html#L88'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L394" class="LineNr">394 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L393" class="LineNr">393 </span> <a href='010---vm.cc.html#L82'>OF</a> = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L394" class="LineNr">394 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L395" class="LineNr">395 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L396" class="LineNr">396 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L397" class="LineNr">397 </span> <span class="Constant">" 0f 8e 05 00 00 00 \n"</span> <span class="Comment">// skip 1 instruction</span> diff --git a/html/019functions.cc.html b/html/019functions.cc.html index f4fc7096..bcb16130 100644 --- a/html/019functions.cc.html +++ b/html/019functions.cc.html @@ -61,13 +61,13 @@ if ('onhashchange' in window) { <span id="L1" class="LineNr"> 1 </span><span class="SalientComment">//:: call</span> <span id="L2" class="LineNr"> 2 </span> <span id="L3" class="LineNr"> 3 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L4" class="LineNr"> 4 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"e8"</span><span class="Delimiter">,</span> <span class="Constant">"call <a href='040---tests.cc.html#L84'>disp32</a> (call)"</span><span class="Delimiter">);</span> +<span id="L4" class="LineNr"> 4 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"e8"</span><span class="Delimiter">,</span> <span class="Constant">"call <a href='040---tests.cc.html#L82'>disp32</a> (call)"</span><span class="Delimiter">);</span> <span id="L5" class="LineNr"> 5 </span> <span id="L6" class="LineNr"> 6 </span><span class="Delimiter">:(code)</span> <span id="L7" class="LineNr"> 7 </span><span class="Normal">void</span> <a href='019functions.cc.html#L7'>test_call_disp32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L8" class="LineNr"> 8 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> -<span id="L9" class="LineNr"> 9 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000064</span><span class="Delimiter">;</span> -<span id="L10" class="LineNr"> 10 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L8" class="LineNr"> 8 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> +<span id="L9" class="LineNr"> 9 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000064</span><span class="Delimiter">;</span> +<span id="L10" class="LineNr"> 10 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L11" class="LineNr"> 11 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L12" class="LineNr"> 12 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L13" class="LineNr"> 13 </span> <span class="Constant">" e8 a0 00 00 00 \n"</span> <span class="Comment">// call function offset at 0x000000a0</span> @@ -75,7 +75,7 @@ if ('onhashchange' in window) { <span id="L15" class="LineNr"> 15 </span> <span class="Delimiter">);</span> <span id="L16" class="LineNr"> 16 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L17" class="LineNr"> 17 </span> <span class="Constant">"run: call imm32 0x000000a0\n"</span> -<span id="L18" class="LineNr"> 18 </span> <span class="Constant">"run: decrementing <a href='010---vm.cc.html#L20'>ESP</a> to 0xbd000060\n"</span> +<span id="L18" class="LineNr"> 18 </span> <span class="Constant">"run: decrementing <a href='010---vm.cc.html#L14'>ESP</a> to 0xbd000060\n"</span> <span id="L19" class="LineNr"> 19 </span> <span class="Constant">"run: pushing value 0x00000006\n"</span> <span id="L20" class="LineNr"> 20 </span> <span class="Constant">"run: jumping to 0x000000a6\n"</span> <span id="L21" class="LineNr"> 21 </span> <span class="Delimiter">);</span> @@ -83,13 +83,13 @@ if ('onhashchange' in window) { <span id="L23" class="LineNr"> 23 </span> <span id="L24" class="LineNr"> 24 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L25" class="LineNr"> 25 </span><span class="Normal">case</span> <span class="Constant">0xe8</span>: <span class="Delimiter">{</span> <span class="Comment">// call disp32 relative to next EIP</span> -<span id="L26" class="LineNr"> 26 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L447'>next32</a><span class="Delimiter">();</span> +<span id="L26" class="LineNr"> 26 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> offset = <a href='011run.cc.html#L433'>next32</a><span class="Delimiter">();</span> <span id="L27" class="LineNr"> 27 </span> ++<span class="Special">Callstack_depth</span><span class="Delimiter">;</span> -<span id="L28" class="LineNr"> 28 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"call imm32 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << offset << end<span class="Delimiter">();</span> +<span id="L28" class="LineNr"> 28 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"call imm32 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << offset << end<span class="Delimiter">();</span> <span id="L29" class="LineNr"> 29 </span><span class="CommentedCode">//? cerr << "push: EIP: " << EIP << " => " << Reg[ESP].u << '\n';</span> -<span id="L30" class="LineNr"> 30 </span> <a href='012elf.cc.html#L94'>push</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">);</span> -<span id="L31" class="LineNr"> 31 </span> <a href='010---vm.cc.html#L32'>EIP</a> += offset<span class="Delimiter">;</span> -<span id="L32" class="LineNr"> 32 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jumping to 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L32'>EIP</a> << end<span class="Delimiter">();</span> +<span id="L30" class="LineNr"> 30 </span> <a href='012elf.cc.html#L94'>push</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">);</span> +<span id="L31" class="LineNr"> 31 </span> <a href='010---vm.cc.html#L26'>EIP</a> += offset<span class="Delimiter">;</span> +<span id="L32" class="LineNr"> 32 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jumping to 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L26'>EIP</a> << end<span class="Delimiter">();</span> <span id="L33" class="LineNr"> 33 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L34" class="LineNr"> 34 </span><span class="Delimiter">}</span> <span id="L35" class="LineNr"> 35 </span> @@ -97,10 +97,10 @@ if ('onhashchange' in window) { <span id="L37" class="LineNr"> 37 </span> <span id="L38" class="LineNr"> 38 </span><span class="Delimiter">:(code)</span> <span id="L39" class="LineNr"> 39 </span><span class="Normal">void</span> <a href='019functions.cc.html#L39'>test_call_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L40" class="LineNr"> 40 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> -<span id="L41" class="LineNr"> 41 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000064</span><span class="Delimiter">;</span> -<span id="L42" class="LineNr"> 42 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x000000a0</span><span class="Delimiter">;</span> -<span id="L43" class="LineNr"> 43 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L40" class="LineNr"> 40 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> +<span id="L41" class="LineNr"> 41 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000064</span><span class="Delimiter">;</span> +<span id="L42" class="LineNr"> 42 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x000000a0</span><span class="Delimiter">;</span> +<span id="L43" class="LineNr"> 43 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L44" class="LineNr"> 44 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L45" class="LineNr"> 45 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L46" class="LineNr"> 46 </span> <span class="Constant">" ff d3 \n"</span> <span class="Comment">// call function offset at EBX</span> @@ -109,7 +109,7 @@ if ('onhashchange' in window) { <span id="L49" class="LineNr"> 49 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L50" class="LineNr"> 50 </span> <span class="Constant">"run: call to r/m32\n"</span> <span id="L51" class="LineNr"> 51 </span> <span class="Constant">"run: r/m32 is EBX\n"</span> -<span id="L52" class="LineNr"> 52 </span> <span class="Constant">"run: decrementing <a href='010---vm.cc.html#L20'>ESP</a> to 0xbd000060\n"</span> +<span id="L52" class="LineNr"> 52 </span> <span class="Constant">"run: decrementing <a href='010---vm.cc.html#L14'>ESP</a> to 0xbd000060\n"</span> <span id="L53" class="LineNr"> 53 </span> <span class="Constant">"run: pushing value 0x00000003\n"</span> <span id="L54" class="LineNr"> 54 </span> <span class="Constant">"run: jumping to 0x000000a3\n"</span> <span id="L55" class="LineNr"> 55 </span> <span class="Delimiter">);</span> @@ -119,19 +119,19 @@ if ('onhashchange' in window) { <span id="L59" class="LineNr"> 59 </span><span class="Normal">case</span> <span class="Constant">2</span>: <span class="Delimiter">{</span> <span class="Comment">// call function pointer at r/m32</span> <span id="L60" class="LineNr"> 60 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"call to r/m32"</span> << end<span class="Delimiter">();</span> <span id="L61" class="LineNr"> 61 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* offset = <a href='013direct_addressing.cc.html#L101'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L62" class="LineNr"> 62 </span> <a href='012elf.cc.html#L94'>push</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">);</span> -<span id="L63" class="LineNr"> 63 </span> <a href='010---vm.cc.html#L32'>EIP</a> += *offset<span class="Delimiter">;</span> -<span id="L64" class="LineNr"> 64 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jumping to 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L32'>EIP</a> << end<span class="Delimiter">();</span> +<span id="L62" class="LineNr"> 62 </span> <a href='012elf.cc.html#L94'>push</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">);</span> +<span id="L63" class="LineNr"> 63 </span> <a href='010---vm.cc.html#L26'>EIP</a> += *offset<span class="Delimiter">;</span> +<span id="L64" class="LineNr"> 64 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jumping to 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L26'>EIP</a> << end<span class="Delimiter">();</span> <span id="L65" class="LineNr"> 65 </span> ++<span class="Special">Callstack_depth</span><span class="Delimiter">;</span> <span id="L66" class="LineNr"> 66 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L67" class="LineNr"> 67 </span><span class="Delimiter">}</span> <span id="L68" class="LineNr"> 68 </span> <span id="L69" class="LineNr"> 69 </span><span class="Delimiter">:(code)</span> <span id="L70" class="LineNr"> 70 </span><span class="Normal">void</span> <a href='019functions.cc.html#L70'>test_call_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L71" class="LineNr"> 71 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> -<span id="L72" class="LineNr"> 72 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000064</span><span class="Delimiter">;</span> -<span id="L73" class="LineNr"> 73 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L74" class="LineNr"> 74 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L71" class="LineNr"> 71 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> +<span id="L72" class="LineNr"> 72 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000064</span><span class="Delimiter">;</span> +<span id="L73" class="LineNr"> 73 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L74" class="LineNr"> 74 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L75" class="LineNr"> 75 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L76" class="LineNr"> 76 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L77" class="LineNr"> 77 </span> <span class="Constant">" ff 13 \n"</span> <span class="Comment">// call function offset at *EBX</span> @@ -141,8 +141,8 @@ if ('onhashchange' in window) { <span id="L81" class="LineNr"> 81 </span> <span class="Delimiter">);</span> <span id="L82" class="LineNr"> 82 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L83" class="LineNr"> 83 </span> <span class="Constant">"run: call to r/m32\n"</span> -<span id="L84" class="LineNr"> 84 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L19'>EBX</a>)\n"</span> -<span id="L85" class="LineNr"> 85 </span> <span class="Constant">"run: decrementing <a href='010---vm.cc.html#L20'>ESP</a> to 0xbd000060\n"</span> +<span id="L84" class="LineNr"> 84 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L13'>EBX</a>)\n"</span> +<span id="L85" class="LineNr"> 85 </span> <span class="Constant">"run: decrementing <a href='010---vm.cc.html#L14'>ESP</a> to 0xbd000060\n"</span> <span id="L86" class="LineNr"> 86 </span> <span class="Constant">"run: pushing value 0x00000003\n"</span> <span id="L87" class="LineNr"> 87 </span> <span class="Constant">"run: jumping to 0x000000a3\n"</span> <span id="L88" class="LineNr"> 88 </span> <span class="Delimiter">);</span> @@ -151,14 +151,14 @@ if ('onhashchange' in window) { <span id="L91" class="LineNr"> 91 </span><span class="SalientComment">//:: ret</span> <span id="L92" class="LineNr"> 92 </span> <span id="L93" class="LineNr"> 93 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L94" class="LineNr"> 94 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"c3"</span><span class="Delimiter">,</span> <span class="Constant">"return from most recent unfinished call (<a href='040---tests.cc.html#L91'>ret</a>)"</span><span class="Delimiter">);</span> +<span id="L94" class="LineNr"> 94 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"c3"</span><span class="Delimiter">,</span> <span class="Constant">"return from most recent unfinished call (<a href='040---tests.cc.html#L89'>ret</a>)"</span><span class="Delimiter">);</span> <span id="L95" class="LineNr"> 95 </span> <span id="L96" class="LineNr"> 96 </span><span class="Delimiter">:(code)</span> <span id="L97" class="LineNr"> 97 </span><span class="Normal">void</span> <a href='019functions.cc.html#L97'>test_ret</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L98" class="LineNr"> 98 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> -<span id="L99" class="LineNr"> 99 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000064</span><span class="Delimiter">;</span> -<span id="L100" class="LineNr">100 </span> <a href='010---vm.cc.html#L245'>write_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> -<span id="L101" class="LineNr">101 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L98" class="LineNr"> 98 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> +<span id="L99" class="LineNr"> 99 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000064</span><span class="Delimiter">;</span> +<span id="L100" class="LineNr">100 </span> <a href='010---vm.cc.html#L239'>write_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L101" class="LineNr">101 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L102" class="LineNr">102 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L103" class="LineNr">103 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L104" class="LineNr">104 </span> <span class="Constant">" c3 \n"</span> <span class="Comment">// return</span> @@ -176,8 +176,8 @@ if ('onhashchange' in window) { <span id="L116" class="LineNr">116 </span><span class="Normal">case</span> <span class="Constant">0xc3</span>: <span class="Delimiter">{</span> <span class="Comment">// return from a call</span> <span id="L117" class="LineNr">117 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"return"</span> << end<span class="Delimiter">();</span> <span id="L118" class="LineNr">118 </span> --<span class="Special">Callstack_depth</span><span class="Delimiter">;</span> -<span id="L119" class="LineNr">119 </span> <a href='010---vm.cc.html#L32'>EIP</a> = <a href='013direct_addressing.cc.html#L1272'>pop</a><span class="Delimiter">();</span> -<span id="L120" class="LineNr">120 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jumping to 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L32'>EIP</a> << end<span class="Delimiter">();</span> +<span id="L119" class="LineNr">119 </span> <a href='010---vm.cc.html#L26'>EIP</a> = <a href='013direct_addressing.cc.html#L1272'>pop</a><span class="Delimiter">();</span> +<span id="L120" class="LineNr">120 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"jumping to 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L26'>EIP</a> << end<span class="Delimiter">();</span> <span id="L121" class="LineNr">121 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L122" class="LineNr">122 </span><span class="Delimiter">}</span> </pre> diff --git a/html/020syscalls.cc.html b/html/020syscalls.cc.html index b903c5b8..ae1ee687 100644 --- a/html/020syscalls.cc.html +++ b/html/020syscalls.cc.html @@ -59,14 +59,14 @@ if ('onhashchange' in window) { <a href='https://github.com/akkartik/mu/blob/master/020syscalls.cc'>https://github.com/akkartik/mu/blob/master/020syscalls.cc</a> <pre id='vimCodeElement'> <span id="L1" class="LineNr"> 1 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L2" class="LineNr"> 2 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"cd"</span><span class="Delimiter">,</span> <span class="Constant">"software interrupt (int)"</span><span class="Delimiter">);</span> +<span id="L2" class="LineNr"> 2 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"cd"</span><span class="Delimiter">,</span> <span class="Constant">"software interrupt (int)"</span><span class="Delimiter">);</span> <span id="L3" class="LineNr"> 3 </span> <span id="L4" class="LineNr"> 4 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L5" class="LineNr"> 5 </span><span class="Normal">case</span> <span class="Constant">0xcd</span>: <span class="Delimiter">{</span> <span class="Comment">// int imm8 (software interrupt)</span> <span id="L6" class="LineNr"> 6 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"syscall"</span> << end<span class="Delimiter">();</span> -<span id="L7" class="LineNr"> 7 </span> <span class="Normal">uint8_t</span> code = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L7" class="LineNr"> 7 </span> <span class="Normal">uint8_t</span> code = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L8" class="LineNr"> 8 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>code != <span class="Constant">0x80</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L9" class="LineNr"> 9 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"Unimplemented interrupt code "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << code << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L9" class="LineNr"> 9 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"Unimplemented interrupt code "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << code << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L10" class="LineNr"> 10 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">" Only `int 80h` supported for now.\n"</span> << end<span class="Delimiter">();</span> <span id="L11" class="LineNr"> 11 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L12" class="LineNr"> 12 </span> <span class="Delimiter">}</span> @@ -76,91 +76,91 @@ if ('onhashchange' in window) { <span id="L16" class="LineNr"> 16 </span> <span id="L17" class="LineNr"> 17 </span><span class="Delimiter">:(code)</span> <span id="L18" class="LineNr"> 18 </span><span class="Normal">void</span> <a href='020syscalls.cc.html#L18'>process_int80</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L19" class="LineNr"> 19 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L19" class="LineNr"> 19 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L20" class="LineNr"> 20 </span> <span class="Normal">case</span> <span class="Constant">1</span>: -<span id="L21" class="LineNr"> 21 </span> exit<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">exit code</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> +<span id="L21" class="LineNr"> 21 </span> exit<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">exit code</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> <span id="L22" class="LineNr"> 22 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L23" class="LineNr"> 23 </span> <span class="Normal">case</span> <span class="Constant">3</span>: -<span id="L24" class="LineNr"> 24 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"read: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">' '</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << <span class="Constant">' '</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> -<span id="L25" class="LineNr"> 25 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = read<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">file descriptor</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">memory buffer</span><span class="Comment">*/</span><a href='010---vm.cc.html#L186'>mem_addr_u8</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">size</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> -<span id="L26" class="LineNr"> 26 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L27" class="LineNr"> 27 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"read: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L24" class="LineNr"> 24 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"read: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">' '</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << <span class="Constant">' '</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L25" class="LineNr"> 25 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = read<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">file descriptor</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">memory buffer</span><span class="Comment">*/</span><a href='010---vm.cc.html#L180'>mem_addr_u8</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">size</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> +<span id="L26" class="LineNr"> 26 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L27" class="LineNr"> 27 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"read: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L28" class="LineNr"> 28 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L29" class="LineNr"> 29 </span> <span class="Normal">case</span> <span class="Constant">4</span>: -<span id="L30" class="LineNr"> 30 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"write: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">' '</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << <span class="Constant">' '</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> -<span id="L31" class="LineNr"> 31 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L229'>mem_addr_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L32" class="LineNr"> 32 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = write<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">file descriptor</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">memory buffer</span><span class="Comment">*/</span><a href='010---vm.cc.html#L186'>mem_addr_u8</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">size</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> -<span id="L33" class="LineNr"> 33 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L34" class="LineNr"> 34 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"write: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L30" class="LineNr"> 30 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"write: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">' '</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << <span class="Constant">' '</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L31" class="LineNr"> 31 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L223'>mem_addr_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L32" class="LineNr"> 32 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = write<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">file descriptor</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">memory buffer</span><span class="Comment">*/</span><a href='010---vm.cc.html#L180'>mem_addr_u8</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">size</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> +<span id="L33" class="LineNr"> 33 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L34" class="LineNr"> 34 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"write: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L35" class="LineNr"> 35 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L36" class="LineNr"> 36 </span> <span class="Normal">case</span> <span class="Constant">5</span>: <span class="Delimiter">{</span> -<span id="L37" class="LineNr"> 37 </span> <a href='020syscalls.cc.html#L89'>check_flags</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L17'>ECX</a><span class="Delimiter">);</span> -<span id="L38" class="LineNr"> 38 </span> <a href='020syscalls.cc.html#L101'>check_mode</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L18'>EDX</a><span class="Delimiter">);</span> -<span id="L39" class="LineNr"> 39 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"open: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">' '</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> -<span id="L40" class="LineNr"> 40 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L41" class="LineNr"> 41 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = open<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">filename</span><span class="Comment">*/</span><a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">flags</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">mode</span><span class="Comment">*/</span><span class="PreProc">0</span><span class="Constant">640</span><span class="Delimiter">);</span> -<span id="L42" class="LineNr"> 42 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L43" class="LineNr"> 43 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"open: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L37" class="LineNr"> 37 </span> <a href='020syscalls.cc.html#L89'>check_flags</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L11'>ECX</a><span class="Delimiter">);</span> +<span id="L38" class="LineNr"> 38 </span> <a href='020syscalls.cc.html#L101'>check_mode</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L12'>EDX</a><span class="Delimiter">);</span> +<span id="L39" class="LineNr"> 39 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"open: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">' '</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L40" class="LineNr"> 40 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L41" class="LineNr"> 41 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = open<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">filename</span><span class="Comment">*/</span><a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">flags</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Comment">/*</span><span class="Comment">mode</span><span class="Comment">*/</span><span class="PreProc">0</span><span class="Constant">640</span><span class="Delimiter">);</span> +<span id="L42" class="LineNr"> 42 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L43" class="LineNr"> 43 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"open: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L44" class="LineNr"> 44 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L45" class="LineNr"> 45 </span> <span class="Delimiter">}</span> <span id="L46" class="LineNr"> 46 </span> <span class="Normal">case</span> <span class="Constant">6</span>: -<span id="L47" class="LineNr"> 47 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"close: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> -<span id="L48" class="LineNr"> 48 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = close<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">file descriptor</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> -<span id="L49" class="LineNr"> 49 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L50" class="LineNr"> 50 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"close: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L47" class="LineNr"> 47 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"close: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L48" class="LineNr"> 48 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = close<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">file descriptor</span><span class="Comment">*/</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> +<span id="L49" class="LineNr"> 49 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L50" class="LineNr"> 50 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"close: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L51" class="LineNr"> 51 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L52" class="LineNr"> 52 </span> <span class="Normal">case</span> <span class="Constant">8</span>: -<span id="L53" class="LineNr"> 53 </span> <a href='020syscalls.cc.html#L101'>check_mode</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L17'>ECX</a><span class="Delimiter">);</span> -<span id="L54" class="LineNr"> 54 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"creat: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> -<span id="L55" class="LineNr"> 55 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L56" class="LineNr"> 56 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = creat<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">filename</span><span class="Comment">*/</span><a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">mode</span><span class="Comment">*/</span><span class="PreProc">0</span><span class="Constant">640</span><span class="Delimiter">);</span> -<span id="L57" class="LineNr"> 57 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L58" class="LineNr"> 58 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"creat: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L53" class="LineNr"> 53 </span> <a href='020syscalls.cc.html#L101'>check_mode</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L11'>ECX</a><span class="Delimiter">);</span> +<span id="L54" class="LineNr"> 54 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"creat: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L55" class="LineNr"> 55 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L56" class="LineNr"> 56 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = creat<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">filename</span><span class="Comment">*/</span><a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">mode</span><span class="Comment">*/</span><span class="PreProc">0</span><span class="Constant">640</span><span class="Delimiter">);</span> +<span id="L57" class="LineNr"> 57 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L58" class="LineNr"> 58 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"creat: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L59" class="LineNr"> 59 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L60" class="LineNr"> 60 </span> <span class="Normal">case</span> <span class="Constant">10</span>: -<span id="L61" class="LineNr"> 61 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"unlink: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> -<span id="L62" class="LineNr"> 62 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L63" class="LineNr"> 63 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = unlink<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">filename</span><span class="Comment">*/</span><a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">));</span> -<span id="L64" class="LineNr"> 64 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L65" class="LineNr"> 65 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"unlink: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L61" class="LineNr"> 61 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"unlink: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L62" class="LineNr"> 62 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L63" class="LineNr"> 63 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = unlink<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">filename</span><span class="Comment">*/</span><a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">));</span> +<span id="L64" class="LineNr"> 64 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L65" class="LineNr"> 65 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"unlink: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L66" class="LineNr"> 66 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L67" class="LineNr"> 67 </span> <span class="Normal">case</span> <span class="Constant">38</span>: -<span id="L68" class="LineNr"> 68 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"rename: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">" -> "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> -<span id="L69" class="LineNr"> 69 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L70" class="LineNr"> 70 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L71" class="LineNr"> 71 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = rename<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">old filename</span><span class="Comment">*/</span><a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">new filename</span><span class="Comment">*/</span><a href='010---vm.cc.html#L226'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">));</span> -<span id="L72" class="LineNr"> 72 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> -<span id="L73" class="LineNr"> 73 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"rename: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L68" class="LineNr"> 68 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"rename: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">" -> "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L69" class="LineNr"> 69 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L70" class="LineNr"> 70 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u << <span class="Constant">" => "</span> << <a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L71" class="LineNr"> 71 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = rename<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">old filename</span><span class="Comment">*/</span><a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">new filename</span><span class="Comment">*/</span><a href='010---vm.cc.html#L220'>mem_addr_kernel_string</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ECX]<span class="Delimiter">.</span>u<span class="Delimiter">));</span> +<span id="L72" class="LineNr"> 72 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i << end<span class="Delimiter">();</span> +<span id="L73" class="LineNr"> 73 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i == -<span class="Constant">1</span><span class="Delimiter">)</span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"rename: "</span> << strerror<span class="Delimiter">(</span>errno<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L74" class="LineNr"> 74 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L75" class="LineNr"> 75 </span> <span class="Normal">case</span> <span class="Constant">90</span>: <span class="Comment">// mmap: allocate memory outside existing segment allocations</span> <span id="L76" class="LineNr"> 76 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"mmap: allocate new segment"</span> << end<span class="Delimiter">();</span> <span id="L77" class="LineNr"> 77 </span> <span class="Comment">// Ignore most arguments for now: address hint, protection flags, sharing flags, fd, offset.</span> <span id="L78" class="LineNr"> 78 </span> <span class="Comment">// We only support anonymous maps.</span> -<span id="L79" class="LineNr"> 79 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <a href='020syscalls.cc.html#L113'>new_segment</a><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">length</span><span class="Comment">*/</span><a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u+<span class="Constant">0x4</span><span class="Delimiter">));</span> -<span id="L80" class="LineNr"> 80 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L79" class="LineNr"> 79 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <a href='020syscalls.cc.html#L113'>new_segment</a><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">length</span><span class="Comment">*/</span><a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u+<span class="Constant">0x4</span><span class="Delimiter">));</span> +<span id="L80" class="LineNr"> 80 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result: "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> <span id="L81" class="LineNr"> 81 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L82" class="LineNr"> 82 </span> <span class="Normal">default</span>: -<span id="L83" class="LineNr"> 83 </span> <a href='003trace.cc.html#L228'>raise</a> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L32'>EIP</a> << <span class="Constant">": unimplemented syscall "</span> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L83" class="LineNr"> 83 </span> <a href='003trace.cc.html#L228'>raise</a> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L26'>EIP</a> << <span class="Constant">": unimplemented syscall "</span> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L84" class="LineNr"> 84 </span> <span class="Delimiter">}</span> <span id="L85" class="LineNr"> 85 </span><span class="Delimiter">}</span> <span id="L86" class="LineNr"> 86 </span> <span id="L87" class="LineNr"> 87 </span><span class="Comment">// SubX is oblivious to file permissions, directories, symbolic links, terminals, and much else besides.</span> <span id="L88" class="LineNr"> 88 </span><span class="Comment">// Also ignoring any concurrency considerations for now.</span> -<span id="L89" class="LineNr"> 89 </span><span class="Normal">void</span> <a href='020syscalls.cc.html#L89'>check_flags</a><span class="Delimiter">(</span><span class="Normal">int</span> <a href='010---vm.cc.html#L26'>reg</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L90" class="LineNr"> 90 </span> <span class="Normal">uint32_t</span> flags = <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> +<span id="L89" class="LineNr"> 89 </span><span class="Normal">void</span> <a href='020syscalls.cc.html#L89'>check_flags</a><span class="Delimiter">(</span><span class="Normal">int</span> <a href='010---vm.cc.html#L20'>reg</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L90" class="LineNr"> 90 </span> <span class="Normal">uint32_t</span> flags = <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> <span id="L91" class="LineNr"> 91 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>flags != <span class="Delimiter">((</span>flags & O_RDONLY<span class="Delimiter">)</span> | <span class="Delimiter">(</span>flags & O_WRONLY<span class="Delimiter">)))</span> <span class="Delimiter">{</span> -<span id="L92" class="LineNr"> 92 </span> cerr << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L32'>EIP</a> << <span class="Constant">": most POSIX flags to the open() syscall are not supported. Just O_RDONLY and O_WRONLY for now. Zero concurrent access support.\n"</span><span class="Delimiter">;</span> +<span id="L92" class="LineNr"> 92 </span> cerr << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L26'>EIP</a> << <span class="Constant">": most POSIX flags to the open() syscall are not supported. Just O_RDONLY and O_WRONLY for now. Zero concurrent access support.\n"</span><span class="Delimiter">;</span> <span id="L93" class="LineNr"> 93 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L94" class="LineNr"> 94 </span> <span class="Delimiter">}</span> <span id="L95" class="LineNr"> 95 </span> <span class="Normal">if</span> <span class="Delimiter">((</span>flags & O_RDONLY<span class="Delimiter">)</span> && <span class="Delimiter">(</span>flags & O_WRONLY<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L96" class="LineNr"> 96 </span> cerr << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L32'>EIP</a> << <span class="Constant">": can't open a file for both reading and writing at once. See <a href="http://man7.org/linux/man-pages/man2/open.2.html">http://man7.org/linux/man-pages/man2/open.2.html</a>.\n"</span><span class="Delimiter">;</span> +<span id="L96" class="LineNr"> 96 </span> cerr << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L26'>EIP</a> << <span class="Constant">": can't open a file for both reading and writing at once. See <a href="http://man7.org/linux/man-pages/man2/open.2.html">http://man7.org/linux/man-pages/man2/open.2.html</a>.\n"</span><span class="Delimiter">;</span> <span id="L97" class="LineNr"> 97 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L98" class="LineNr"> 98 </span> <span class="Delimiter">}</span> <span id="L99" class="LineNr"> 99 </span><span class="Delimiter">}</span> <span id="L100" class="LineNr">100 </span> -<span id="L101" class="LineNr">101 </span><span class="Normal">void</span> <a href='020syscalls.cc.html#L101'>check_mode</a><span class="Delimiter">(</span><span class="Normal">int</span> <a href='010---vm.cc.html#L26'>reg</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L102" class="LineNr">102 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[reg]<span class="Delimiter">.</span>u != <span class="PreProc">0</span><span class="Constant">600</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L103" class="LineNr">103 </span> cerr << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L32'>EIP</a> << <span class="Constant">": SubX is oblivious to file permissions; register "</span> << <a href='010---vm.cc.html#L26'>reg</a> << <span class="Constant">" must be 0.\n"</span><span class="Delimiter">;</span> +<span id="L101" class="LineNr">101 </span><span class="Normal">void</span> <a href='020syscalls.cc.html#L101'>check_mode</a><span class="Delimiter">(</span><span class="Normal">int</span> <a href='010---vm.cc.html#L20'>reg</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L102" class="LineNr">102 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[reg]<span class="Delimiter">.</span>u != <span class="PreProc">0</span><span class="Constant">600</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L103" class="LineNr">103 </span> cerr << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L26'>EIP</a> << <span class="Constant">": SubX is oblivious to file permissions; register "</span> << <a href='010---vm.cc.html#L20'>reg</a> << <span class="Constant">" must be 0.\n"</span><span class="Delimiter">;</span> <span id="L104" class="LineNr">104 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L105" class="LineNr">105 </span> <span class="Delimiter">}</span> <span id="L106" class="LineNr">106 </span><span class="Delimiter">}</span> @@ -175,9 +175,9 @@ if ('onhashchange' in window) { <span id="L115" class="LineNr">115 </span> <span class="Normal">uint32_t</span> result = <span class="Delimiter">(</span><span class="Special"><a href='020syscalls.cc.html#L110'>Segments_allocated_above</a></span> - length<span class="Delimiter">)</span> & <span class="Constant">0xff000000</span><span class="Delimiter">;</span> <span class="Comment">// same number of zeroes as SEGMENT_ALIGNMENT</span> <span id="L116" class="LineNr">116 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result <= <a href='012elf.cc.html#L150'>START_HEAP</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L117" class="LineNr">117 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"Allocated too many segments; the VM ran out of memory. "</span> -<span id="L118" class="LineNr">118 </span> << <span class="Constant">"Maybe <a href='010---vm.cc.html#L95'>SEGMENT_ALIGNMENT</a> can be smaller?\n"</span> << <a href='003trace.cc.html#L173'>die</a><span class="Delimiter">();</span> +<span id="L118" class="LineNr">118 </span> << <span class="Constant">"Maybe <a href='010---vm.cc.html#L89'>SEGMENT_ALIGNMENT</a> can be smaller?\n"</span> << <a href='003trace.cc.html#L173'>die</a><span class="Delimiter">();</span> <span id="L119" class="LineNr">119 </span> <span class="Delimiter">}</span> -<span id="L120" class="LineNr">120 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span>result<span class="Delimiter">,</span> result+length<span class="Delimiter">));</span> +<span id="L120" class="LineNr">120 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span>result<span class="Delimiter">,</span> result+length<span class="Delimiter">));</span> <span id="L121" class="LineNr">121 </span> <span class="Special"><a href='020syscalls.cc.html#L110'>Segments_allocated_above</a></span> = result<span class="Delimiter">;</span> <span id="L122" class="LineNr">122 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span id="L123" class="LineNr">123 </span><span class="Delimiter">}</span> diff --git a/html/021byte_addressing.cc.html b/html/021byte_addressing.cc.html index c8e11d91..7ba3f488 100644 --- a/html/021byte_addressing.cc.html +++ b/html/021byte_addressing.cc.html @@ -86,24 +86,24 @@ if ('onhashchange' in window) { <span id="L27" class="LineNr"> 27 </span> <span class="Identifier">return</span> <a href='021byte_addressing.cc.html#L33'>reg_8bit</a><span class="Delimiter">(</span>rm<span class="Delimiter">);</span> <span id="L28" class="LineNr"> 28 </span> <span class="Delimiter">}</span> <span id="L29" class="LineNr"> 29 </span> <span class="Comment">// the rest is as usual</span> -<span id="L30" class="LineNr"> 30 </span> <span class="Identifier">return</span> <a href='010---vm.cc.html#L186'>mem_addr_u8</a><span class="Delimiter">(</span><a href='013direct_addressing.cc.html#L116'>effective_address_number</a><span class="Delimiter">(</span>modrm<span class="Delimiter">));</span> +<span id="L30" class="LineNr"> 30 </span> <span class="Identifier">return</span> <a href='010---vm.cc.html#L180'>mem_addr_u8</a><span class="Delimiter">(</span><a href='013direct_addressing.cc.html#L116'>effective_address_number</a><span class="Delimiter">(</span>modrm<span class="Delimiter">));</span> <span id="L31" class="LineNr"> 31 </span><span class="Delimiter">}</span> <span id="L32" class="LineNr"> 32 </span> <span id="L33" class="LineNr"> 33 </span><span class="Normal">uint8_t</span>* <a href='021byte_addressing.cc.html#L33'>reg_8bit</a><span class="Delimiter">(</span><span class="Normal">uint8_t</span> rm<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L34" class="LineNr"> 34 </span> <span class="Normal">uint8_t</span>* result = <span class="Normal">reinterpret_cast</span><<span class="Normal">uint8_t</span>*><span class="Delimiter">(</span>&<span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[rm & <span class="Constant">0x3</span>]<span class="Delimiter">.</span>i<span class="Delimiter">);</span> <span class="Comment">// _L register</span> +<span id="L34" class="LineNr"> 34 </span> <span class="Normal">uint8_t</span>* result = <span class="Normal">reinterpret_cast</span><<span class="Normal">uint8_t</span>*><span class="Delimiter">(</span>&<span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[rm & <span class="Constant">0x3</span>]<span class="Delimiter">.</span>i<span class="Delimiter">);</span> <span class="Comment">// _L register</span> <span id="L35" class="LineNr"> 35 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>rm & <span class="Constant">0x4</span><span class="Delimiter">)</span> <span id="L36" class="LineNr"> 36 </span> ++result<span class="Delimiter">;</span> <span class="Comment">// _H register; assumes host is little-endian</span> <span id="L37" class="LineNr"> 37 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span id="L38" class="LineNr"> 38 </span><span class="Delimiter">}</span> <span id="L39" class="LineNr"> 39 </span> <span id="L40" class="LineNr"> 40 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L41" class="LineNr"> 41 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"88"</span><span class="Delimiter">,</span> <span class="Constant">"copy r8 to r8/m8-at-r32"</span><span class="Delimiter">);</span> +<span id="L41" class="LineNr"> 41 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"88"</span><span class="Delimiter">,</span> <span class="Constant">"copy r8 to r8/m8-at-r32"</span><span class="Delimiter">);</span> <span id="L42" class="LineNr"> 42 </span> <span id="L43" class="LineNr"> 43 </span><span class="Delimiter">:(code)</span> <span id="L44" class="LineNr"> 44 </span><span class="Normal">void</span> <a href='021byte_addressing.cc.html#L44'>test_copy_r8_to_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L45" class="LineNr"> 45 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x224488ab</span><span class="Delimiter">;</span> -<span id="L46" class="LineNr"> 46 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L47" class="LineNr"> 47 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L45" class="LineNr"> 45 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0x224488ab</span><span class="Delimiter">;</span> +<span id="L46" class="LineNr"> 46 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L47" class="LineNr"> 47 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L48" class="LineNr"> 48 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L49" class="LineNr"> 49 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L50" class="LineNr"> 50 </span> <span class="Constant">" 88 18 \n"</span> <span class="Comment">// copy BL to the byte at *EAX</span> @@ -113,35 +113,35 @@ if ('onhashchange' in window) { <span id="L54" class="LineNr"> 54 </span> <span class="Delimiter">);</span> <span id="L55" class="LineNr"> 55 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L56" class="LineNr"> 56 </span> <span class="Constant">"run: copy BL to r8/m8-at-r32\n"</span> -<span id="L57" class="LineNr"> 57 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L57" class="LineNr"> 57 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L58" class="LineNr"> 58 </span> <span class="Constant">"run: storing 0xab\n"</span> <span id="L59" class="LineNr"> 59 </span> <span class="Delimiter">);</span> -<span id="L60" class="LineNr"> 60 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">0xaabbccab</span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span><span class="Constant">0x2000</span><span class="Delimiter">));</span> +<span id="L60" class="LineNr"> 60 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">0xaabbccab</span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span><span class="Constant">0x2000</span><span class="Delimiter">));</span> <span id="L61" class="LineNr"> 61 </span><span class="Delimiter">}</span> <span id="L62" class="LineNr"> 62 </span> <span id="L63" class="LineNr"> 63 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L64" class="LineNr"> 64 </span><span class="Normal">case</span> <span class="Constant">0x88</span>: <span class="Delimiter">{</span> <span class="Comment">// copy r8 to r/m8</span> -<span id="L65" class="LineNr"> 65 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L65" class="LineNr"> 65 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L66" class="LineNr"> 66 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> rsrc = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L67" class="LineNr"> 67 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy "</span> << <a href='021byte_addressing.cc.html#L7'>rname_8bit</a><span class="Delimiter">(</span>rsrc<span class="Delimiter">)</span> << <span class="Constant">" to r8/m8-at-r32"</span> << end<span class="Delimiter">();</span> <span id="L68" class="LineNr"> 68 </span> <span class="Comment">// use unsigned to zero-extend 8-bit value to 32 bits</span> <span id="L69" class="LineNr"> 69 </span> <span class="Normal">uint8_t</span>* dest = <span class="Normal">reinterpret_cast</span><<span class="Normal">uint8_t</span>*><span class="Delimiter">(</span><a href='021byte_addressing.cc.html#L21'>effective_byte_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">));</span> <span id="L70" class="LineNr"> 70 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span>* src = <a href='021byte_addressing.cc.html#L33'>reg_8bit</a><span class="Delimiter">(</span>rsrc<span class="Delimiter">);</span> <span id="L71" class="LineNr"> 71 </span> *dest = *src<span class="Delimiter">;</span> -<span id="L72" class="LineNr"> 72 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>*dest<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L72" class="LineNr"> 72 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>*dest<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L73" class="LineNr"> 73 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L74" class="LineNr"> 74 </span><span class="Delimiter">}</span> <span id="L75" class="LineNr"> 75 </span> <span id="L76" class="LineNr"> 76 </span><span class="Comment">//:</span> <span id="L77" class="LineNr"> 77 </span> <span id="L78" class="LineNr"> 78 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L79" class="LineNr"> 79 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"8a"</span><span class="Delimiter">,</span> <span class="Constant">"copy r8/m8-at-r32 to r8"</span><span class="Delimiter">);</span> +<span id="L79" class="LineNr"> 79 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"8a"</span><span class="Delimiter">,</span> <span class="Constant">"copy r8/m8-at-r32 to r8"</span><span class="Delimiter">);</span> <span id="L80" class="LineNr"> 80 </span> <span id="L81" class="LineNr"> 81 </span><span class="Delimiter">:(code)</span> <span id="L82" class="LineNr"> 82 </span><span class="Normal">void</span> <a href='021byte_addressing.cc.html#L82'>test_copy_mem_at_r32_to_r8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L83" class="LineNr"> 83 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xaabbcc0f</span><span class="Delimiter">;</span> <span class="Comment">// one nibble each of lowest byte set to all 0s and all 1s, to maximize value of this test</span> -<span id="L84" class="LineNr"> 84 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L85" class="LineNr"> 85 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L83" class="LineNr"> 83 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>i = <span class="Constant">0xaabbcc0f</span><span class="Delimiter">;</span> <span class="Comment">// one nibble each of lowest byte set to all 0s and all 1s, to maximize value of this test</span> +<span id="L84" class="LineNr"> 84 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L85" class="LineNr"> 85 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L86" class="LineNr"> 86 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L87" class="LineNr"> 87 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L88" class="LineNr"> 88 </span> <span class="Constant">" 8a 18 \n"</span> <span class="Comment">// copy just the byte at *EAX to BL</span> @@ -151,33 +151,33 @@ if ('onhashchange' in window) { <span id="L92" class="LineNr"> 92 </span> <span class="Delimiter">);</span> <span id="L93" class="LineNr"> 93 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L94" class="LineNr"> 94 </span> <span class="Constant">"run: copy r8/m8-at-r32 to BL\n"</span> -<span id="L95" class="LineNr"> 95 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L95" class="LineNr"> 95 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L96" class="LineNr"> 96 </span> <span class="Constant">"run: storing 0xab\n"</span> <span id="L97" class="LineNr"> 97 </span> <span class="Comment">// remaining bytes of EBX are *not* cleared</span> -<span id="L98" class="LineNr"> 98 </span> <span class="Constant">"run: <a href='010---vm.cc.html#L19'>EBX</a> now contains 0xaabbccab\n"</span> +<span id="L98" class="LineNr"> 98 </span> <span class="Constant">"run: <a href='010---vm.cc.html#L13'>EBX</a> now contains 0xaabbccab\n"</span> <span id="L99" class="LineNr"> 99 </span> <span class="Delimiter">);</span> <span id="L100" class="LineNr">100 </span><span class="Delimiter">}</span> <span id="L101" class="LineNr">101 </span> <span id="L102" class="LineNr">102 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L103" class="LineNr">103 </span><span class="Normal">case</span> <span class="Constant">0x8a</span>: <span class="Delimiter">{</span> <span class="Comment">// copy r/m8 to r8</span> -<span id="L104" class="LineNr">104 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L104" class="LineNr">104 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L105" class="LineNr">105 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> rdest = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span id="L106" class="LineNr">106 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy r8/m8-at-r32 to "</span> << <a href='021byte_addressing.cc.html#L7'>rname_8bit</a><span class="Delimiter">(</span>rdest<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L107" class="LineNr">107 </span> <span class="Comment">// use unsigned to zero-extend 8-bit value to 32 bits</span> <span id="L108" class="LineNr">108 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span>* src = <span class="Normal">reinterpret_cast</span><<span class="Normal">uint8_t</span>*><span class="Delimiter">(</span><a href='021byte_addressing.cc.html#L21'>effective_byte_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">));</span> <span id="L109" class="LineNr">109 </span> <span class="Normal">uint8_t</span>* dest = <a href='021byte_addressing.cc.html#L33'>reg_8bit</a><span class="Delimiter">(</span>rdest<span class="Delimiter">);</span> -<span id="L110" class="LineNr">110 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>*src<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L110" class="LineNr">110 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>*src<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L111" class="LineNr">111 </span> *dest = *src<span class="Delimiter">;</span> <span id="L112" class="LineNr">112 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> rdest_32bit = rdest & <span class="Constant">0x3</span><span class="Delimiter">;</span> -<span id="L113" class="LineNr">113 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rdest_32bit<span class="Delimiter">)</span> << <span class="Constant">" now contains 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[rdest_32bit]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L113" class="LineNr">113 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <a href='013direct_addressing.cc.html#L136'>rname</a><span class="Delimiter">(</span>rdest_32bit<span class="Delimiter">)</span> << <span class="Constant">" now contains 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[rdest_32bit]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> <span id="L114" class="LineNr">114 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L115" class="LineNr">115 </span><span class="Delimiter">}</span> <span id="L116" class="LineNr">116 </span> <span id="L117" class="LineNr">117 </span><span class="Delimiter">:(code)</span> <span id="L118" class="LineNr">118 </span><span class="Normal">void</span> <a href='021byte_addressing.cc.html#L118'>test_cannot_copy_byte_to_ESP_EBP_ESI_EDI</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L119" class="LineNr">119 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESI]<span class="Delimiter">.</span>u = <span class="Constant">0xaabbccdd</span><span class="Delimiter">;</span> -<span id="L120" class="LineNr">120 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x11223344</span><span class="Delimiter">;</span> -<span id="L121" class="LineNr">121 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L119" class="LineNr">119 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESI]<span class="Delimiter">.</span>u = <span class="Constant">0xaabbccdd</span><span class="Delimiter">;</span> +<span id="L120" class="LineNr">120 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EBX]<span class="Delimiter">.</span>u = <span class="Constant">0x11223344</span><span class="Delimiter">;</span> +<span id="L121" class="LineNr">121 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L122" class="LineNr">122 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L123" class="LineNr">123 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L124" class="LineNr">124 </span> <span class="Constant">" 8a f3 \n"</span> <span class="Comment">// copy just the byte at *EBX to 8-bit register '6'</span> @@ -189,18 +189,18 @@ if ('onhashchange' in window) { <span id="L130" class="LineNr">130 </span> <span class="Constant">"run: storing 0x44\n"</span> <span id="L131" class="LineNr">131 </span> <span class="Delimiter">);</span> <span id="L132" class="LineNr">132 </span> <span class="Comment">// ensure ESI is unchanged</span> -<span id="L133" class="LineNr">133 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESI]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Constant">0xaabbccdd</span><span class="Delimiter">);</span> +<span id="L133" class="LineNr">133 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESI]<span class="Delimiter">.</span>u<span class="Delimiter">,</span> <span class="Constant">0xaabbccdd</span><span class="Delimiter">);</span> <span id="L134" class="LineNr">134 </span><span class="Delimiter">}</span> <span id="L135" class="LineNr">135 </span> <span id="L136" class="LineNr">136 </span><span class="Comment">//:</span> <span id="L137" class="LineNr">137 </span> <span id="L138" class="LineNr">138 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L139" class="LineNr">139 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"c6"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm8 to r8/m8-at-r32 (mov)"</span><span class="Delimiter">);</span> +<span id="L139" class="LineNr">139 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"c6"</span><span class="Delimiter">,</span> <span class="Constant">"copy imm8 to r8/m8-at-r32 (mov)"</span><span class="Delimiter">);</span> <span id="L140" class="LineNr">140 </span> <span id="L141" class="LineNr">141 </span><span class="Delimiter">:(code)</span> <span id="L142" class="LineNr">142 </span><span class="Normal">void</span> <a href='021byte_addressing.cc.html#L142'>test_copy_imm8_to_mem_at_r32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L143" class="LineNr">143 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> -<span id="L144" class="LineNr">144 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L143" class="LineNr">143 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">0x2000</span><span class="Delimiter">;</span> +<span id="L144" class="LineNr">144 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L145" class="LineNr">145 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L146" class="LineNr">146 </span> <span class="Comment">// op ModR/M SIB displacement immediate</span> <span id="L147" class="LineNr">147 </span> <span class="Constant">" c6 00 dd \n"</span> <span class="Comment">// copy to the byte at *EAX</span> @@ -210,27 +210,27 @@ if ('onhashchange' in window) { <span id="L151" class="LineNr">151 </span> <span class="Delimiter">);</span> <span id="L152" class="LineNr">152 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L153" class="LineNr">153 </span> <span class="Constant">"run: copy imm8 to r8/m8-at-r32\n"</span> -<span id="L154" class="LineNr">154 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L16'>EAX</a>)\n"</span> +<span id="L154" class="LineNr">154 </span> <span class="Constant">"run: effective address is 0x00002000 (<a href='010---vm.cc.html#L10'>EAX</a>)\n"</span> <span id="L155" class="LineNr">155 </span> <span class="Constant">"run: storing 0xdd\n"</span> <span id="L156" class="LineNr">156 </span> <span class="Delimiter">);</span> -<span id="L157" class="LineNr">157 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">0xaabbccdd</span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span><span class="Constant">0x2000</span><span class="Delimiter">));</span> +<span id="L157" class="LineNr">157 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">0xaabbccdd</span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span><span class="Constant">0x2000</span><span class="Delimiter">));</span> <span id="L158" class="LineNr">158 </span><span class="Delimiter">}</span> <span id="L159" class="LineNr">159 </span> <span id="L160" class="LineNr">160 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L161" class="LineNr">161 </span><span class="Normal">case</span> <span class="Constant">0xc6</span>: <span class="Delimiter">{</span> <span class="Comment">// copy imm8 to r/m8</span> -<span id="L162" class="LineNr">162 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> -<span id="L163" class="LineNr">163 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> src = <a href='010---vm.cc.html#L331'>next</a><span class="Delimiter">();</span> +<span id="L162" class="LineNr">162 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> modrm = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> +<span id="L163" class="LineNr">163 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> src = <a href='010---vm.cc.html#L325'>next</a><span class="Delimiter">();</span> <span id="L164" class="LineNr">164 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"copy imm8 to r8/m8-at-r32"</span> << end<span class="Delimiter">();</span> -<span id="L165" class="LineNr">165 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"imm8 is 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>src<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L165" class="LineNr">165 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"imm8 is 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>src<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L166" class="LineNr">166 </span> <span class="Normal">const</span> <span class="Normal">uint8_t</span> subop = <span class="Delimiter">(</span>modrm>><span class="Constant">3</span><span class="Delimiter">)</span>&<span class="Constant">0x7</span><span class="Delimiter">;</span> <span class="Comment">// middle 3 'reg opcode' bits</span> <span id="L167" class="LineNr">167 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>subop != <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L168" class="LineNr">168 </span> cerr << <span class="Constant">"unrecognized subop for opcode c6: "</span> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="Constant">" (only 0/copy currently implemented)\n"</span><span class="Delimiter">;</span> +<span id="L168" class="LineNr">168 </span> cerr << <span class="Constant">"unrecognized subop for opcode c6: "</span> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>subop<span class="Delimiter">)</span> << <span class="Constant">" (only 0/copy currently implemented)\n"</span><span class="Delimiter">;</span> <span id="L169" class="LineNr">169 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L170" class="LineNr">170 </span> <span class="Delimiter">}</span> <span id="L171" class="LineNr">171 </span> <span class="Comment">// use unsigned to zero-extend 8-bit value to 32 bits</span> <span id="L172" class="LineNr">172 </span> <span class="Normal">uint8_t</span>* dest = <span class="Normal">reinterpret_cast</span><<span class="Normal">uint8_t</span>*><span class="Delimiter">(</span><a href='021byte_addressing.cc.html#L21'>effective_byte_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">));</span> <span id="L173" class="LineNr">173 </span> *dest = src<span class="Delimiter">;</span> -<span id="L174" class="LineNr">174 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>*dest<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L174" class="LineNr">174 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>*dest<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L175" class="LineNr">175 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L176" class="LineNr">176 </span><span class="Delimiter">}</span> </pre> diff --git a/html/022div.cc.html b/html/022div.cc.html index 5fa65b16..256cb1be 100644 --- a/html/022div.cc.html +++ b/html/022div.cc.html @@ -59,39 +59,39 @@ if ('onhashchange' in window) { <span id="L1" class="LineNr"> 1 </span><span class="Comment">//: helper for division operations: sign-extend EAX into EDX</span> <span id="L2" class="LineNr"> 2 </span> <span id="L3" class="LineNr"> 3 </span><span class="Delimiter">:(before "End Initialize Op Names")</span> -<span id="L4" class="LineNr"> 4 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"99"</span><span class="Delimiter">,</span> <span class="Constant">"sign-extend <a href='010---vm.cc.html#L16'>EAX</a> into <a href='010---vm.cc.html#L18'>EDX</a> (cdq)"</span><span class="Delimiter">);</span> +<span id="L4" class="LineNr"> 4 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> <span class="Constant">"99"</span><span class="Delimiter">,</span> <span class="Constant">"sign-extend <a href='010---vm.cc.html#L10'>EAX</a> into <a href='010---vm.cc.html#L12'>EDX</a> (cdq)"</span><span class="Delimiter">);</span> <span id="L5" class="LineNr"> 5 </span> <span id="L6" class="LineNr"> 6 </span><span class="Delimiter">:(code)</span> <span id="L7" class="LineNr"> 7 </span><span class="Normal">void</span> <a href='022div.cc.html#L7'>test_cdq</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L8" class="LineNr"> 8 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">10</span><span class="Delimiter">;</span> -<span id="L9" class="LineNr"> 9 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L8" class="LineNr"> 8 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = <span class="Constant">10</span><span class="Delimiter">;</span> +<span id="L9" class="LineNr"> 9 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L10" class="LineNr">10 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L11" class="LineNr">11 </span> <span class="Constant">"99\n"</span> <span id="L12" class="LineNr">12 </span> <span class="Delimiter">);</span> <span id="L13" class="LineNr">13 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L14" class="LineNr">14 </span> <span class="Constant">"run: sign-extend <a href='010---vm.cc.html#L16'>EAX</a> into EDX\n"</span> -<span id="L15" class="LineNr">15 </span> <span class="Constant">"run: <a href='010---vm.cc.html#L18'>EDX</a> is now 0x00000000\n"</span> +<span id="L14" class="LineNr">14 </span> <span class="Constant">"run: sign-extend <a href='010---vm.cc.html#L10'>EAX</a> into EDX\n"</span> +<span id="L15" class="LineNr">15 </span> <span class="Constant">"run: <a href='010---vm.cc.html#L12'>EDX</a> is now 0x00000000\n"</span> <span id="L16" class="LineNr">16 </span> <span class="Delimiter">);</span> <span id="L17" class="LineNr">17 </span><span class="Delimiter">}</span> <span id="L18" class="LineNr">18 </span> <span id="L19" class="LineNr">19 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> <span id="L20" class="LineNr">20 </span><span class="Normal">case</span> <span class="Constant">0x99</span>: <span class="Delimiter">{</span> <span class="Comment">// sign-extend EAX into EDX</span> -<span id="L21" class="LineNr">21 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"sign-extend <a href='010---vm.cc.html#L16'>EAX</a> into EDX"</span> << end<span class="Delimiter">();</span> -<span id="L22" class="LineNr">22 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>i = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i < <span class="Constant">0</span><span class="Delimiter">)</span> ? -<span class="Constant">1</span> : <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L23" class="LineNr">23 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"EDX is now 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> +<span id="L21" class="LineNr">21 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"sign-extend <a href='010---vm.cc.html#L10'>EAX</a> into EDX"</span> << end<span class="Delimiter">();</span> +<span id="L22" class="LineNr">22 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>i = <span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i < <span class="Constant">0</span><span class="Delimiter">)</span> ? -<span class="Constant">1</span> : <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L23" class="LineNr">23 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span>+<span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"EDX is now 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EDX]<span class="Delimiter">.</span>u << end<span class="Delimiter">();</span> <span id="L24" class="LineNr">24 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L25" class="LineNr">25 </span><span class="Delimiter">}</span> <span id="L26" class="LineNr">26 </span> <span id="L27" class="LineNr">27 </span><span class="Delimiter">:(code)</span> <span id="L28" class="LineNr">28 </span><span class="Normal">void</span> <a href='022div.cc.html#L28'>test_cdq_negative</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L29" class="LineNr">29 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = -<span class="Constant">10</span><span class="Delimiter">;</span> -<span id="L30" class="LineNr">30 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L29" class="LineNr">29 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>i = -<span class="Constant">10</span><span class="Delimiter">;</span> +<span id="L30" class="LineNr">30 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L31" class="LineNr">31 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L32" class="LineNr">32 </span> <span class="Constant">"99\n"</span> <span id="L33" class="LineNr">33 </span> <span class="Delimiter">);</span> <span id="L34" class="LineNr">34 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L35" class="LineNr">35 </span> <span class="Constant">"run: sign-extend <a href='010---vm.cc.html#L16'>EAX</a> into EDX\n"</span> -<span id="L36" class="LineNr">36 </span> <span class="Constant">"run: <a href='010---vm.cc.html#L18'>EDX</a> is now 0xffffffff\n"</span> +<span id="L35" class="LineNr">35 </span> <span class="Constant">"run: sign-extend <a href='010---vm.cc.html#L10'>EAX</a> into EDX\n"</span> +<span id="L36" class="LineNr">36 </span> <span class="Constant">"run: <a href='010---vm.cc.html#L12'>EDX</a> is now 0xffffffff\n"</span> <span id="L37" class="LineNr">37 </span> <span class="Delimiter">);</span> <span id="L38" class="LineNr">38 </span><span class="Delimiter">}</span> </pre> diff --git a/html/030---translate.cc.html b/html/030---translate.cc.html index c2f9e993..0055f063 100644 --- a/html/030---translate.cc.html +++ b/html/030---translate.cc.html @@ -59,219 +59,212 @@ if ('onhashchange' in window) { <body onload='JumpToLine();'> <a href='https://github.com/akkartik/mu/blob/master/030---translate.cc'>https://github.com/akkartik/mu/blob/master/030---translate.cc</a> <pre id='vimCodeElement'> -<span id="L1" class="LineNr"> 1 </span><span class="Comment">//: The bedrock level 1 of abstraction is now done, and we're going to start</span> -<span id="L2" class="LineNr"> 2 </span><span class="Comment">//: building levels above it that make programming in x86 machine code a</span> -<span id="L3" class="LineNr"> 3 </span><span class="Comment">//: little more ergonomic.</span> -<span id="L4" class="LineNr"> 4 </span><span class="Comment">//:</span> -<span id="L5" class="LineNr"> 5 </span><span class="Comment">//: All levels will be "pass through by default". Whatever they don't</span> -<span id="L6" class="LineNr"> 6 </span><span class="Comment">//: understand they will silently pass through to lower levels.</span> -<span id="L7" class="LineNr"> 7 </span><span class="Comment">//:</span> -<span id="L8" class="LineNr"> 8 </span><span class="Comment">//: Since raw hex bytes of machine code are always possible to inject, SubX is</span> -<span id="L9" class="LineNr"> 9 </span><span class="Comment">//: not a language, and we aren't building a compiler. This is something</span> -<span id="L10" class="LineNr"> 10 </span><span class="Comment">//: deliberately leakier. Levels are more for improving auditing, checks and</span> -<span id="L11" class="LineNr"> 11 </span><span class="Comment">//: error messages rather than for hiding low-level details.</span> -<span id="L12" class="LineNr"> 12 </span> -<span id="L13" class="LineNr"> 13 </span><span class="Comment">//: Translator workflow: read 'source' file. Run a series of transforms on it,</span> -<span id="L14" class="LineNr"> 14 </span><span class="Comment">//: each passing through what it doesn't understand. The final program should</span> -<span id="L15" class="LineNr"> 15 </span><span class="Comment">//: be just machine code, suitable to write to an ELF binary.</span> -<span id="L16" class="LineNr"> 16 </span><span class="Comment">//:</span> -<span id="L17" class="LineNr"> 17 </span><span class="Comment">//: Higher levels usually transform code on the basis of metadata.</span> -<span id="L18" class="LineNr"> 18 </span> -<span id="L19" class="LineNr"> 19 </span><span class="Delimiter">:(before "End Main")</span> -<span id="L20" class="LineNr"> 20 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L101'>is_equal</a><span class="Delimiter">(</span>argv[<span class="Constant">1</span>]<span class="Delimiter">,</span> <span class="Constant">"translate"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L21" class="LineNr"> 21 </span> <span class="Comment">// Outside of tests, traces must be explicitly requested.</span> -<span id="L22" class="LineNr"> 22 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">.</span>is_open<span class="Delimiter">())</span> <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span> = <span class="Normal">new</span> trace_stream<span class="Delimiter">;</span> -<span id="L23" class="LineNr"> 23 </span> <a href='000organization.cc.html#L150'>reset</a><span class="Delimiter">();</span> -<span id="L24" class="LineNr"> 24 </span> <span class="Comment">// Begin subx translate</span> -<span id="L25" class="LineNr"> 25 </span> program p<span class="Delimiter">;</span> -<span id="L26" class="LineNr"> 26 </span> string output_filename<span class="Delimiter">;</span> -<span id="L27" class="LineNr"> 27 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Comment">/*</span><span class="Comment">skip 'subx translate'</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">;</span> i < argc<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L28" class="LineNr"> 28 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L101'>is_equal</a><span class="Delimiter">(</span>argv[i]<span class="Delimiter">,</span> <span class="Constant">"-o"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L29" class="LineNr"> 29 </span> ++i<span class="Delimiter">;</span> -<span id="L30" class="LineNr"> 30 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i >= argc<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L31" class="LineNr"> 31 </span> <a href='030---translate.cc.html#L72'>print_translate_usage</a><span class="Delimiter">();</span> -<span id="L32" class="LineNr"> 32 </span> cerr << <span class="Constant">"'-o' must be followed by a filename to write results to\n"</span><span class="Delimiter">;</span> -<span id="L33" class="LineNr"> 33 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L34" class="LineNr"> 34 </span> <span class="Delimiter">}</span> -<span id="L35" class="LineNr"> 35 </span> output_filename = argv[i]<span class="Delimiter">;</span> -<span id="L36" class="LineNr"> 36 </span> <span class="Delimiter">}</span> -<span id="L37" class="LineNr"> 37 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L38" class="LineNr"> 38 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << argv[i] << end<span class="Delimiter">();</span> -<span id="L39" class="LineNr"> 39 </span> ifstream fin<span class="Delimiter">(</span>argv[i]<span class="Delimiter">);</span> -<span id="L40" class="LineNr"> 40 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!fin<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L41" class="LineNr"> 41 </span> cerr << <span class="Constant">"could not open "</span> << argv[i] << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L42" class="LineNr"> 42 </span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L43" class="LineNr"> 43 </span> <span class="Delimiter">}</span> -<span id="L44" class="LineNr"> 44 </span> parse<span class="Delimiter">(</span>fin<span class="Delimiter">,</span> p<span class="Delimiter">);</span> -<span id="L45" class="LineNr"> 45 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L46" class="LineNr"> 46 </span> <span class="Delimiter">}</span> -<span id="L47" class="LineNr"> 47 </span> <span class="Delimiter">}</span> -<span id="L48" class="LineNr"> 48 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L49" class="LineNr"> 49 </span> <a href='030---translate.cc.html#L72'>print_translate_usage</a><span class="Delimiter">();</span> -<span id="L50" class="LineNr"> 50 </span> cerr << <span class="Constant">"nothing to do; must provide at least one file to read\n"</span><span class="Delimiter">;</span> -<span id="L51" class="LineNr"> 51 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L52" class="LineNr"> 52 </span> <span class="Delimiter">}</span> -<span id="L53" class="LineNr"> 53 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>output_filename<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L54" class="LineNr"> 54 </span> <a href='030---translate.cc.html#L72'>print_translate_usage</a><span class="Delimiter">();</span> -<span id="L55" class="LineNr"> 55 </span> cerr << <span class="Constant">"must provide a filename to write to using '-o'\n"</span><span class="Delimiter">;</span> -<span id="L56" class="LineNr"> 56 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L57" class="LineNr"> 57 </span> <span class="Delimiter">}</span> -<span id="L58" class="LineNr"> 58 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"begin"</span> << end<span class="Delimiter">();</span> -<span id="L59" class="LineNr"> 59 </span> transform<span class="Delimiter">(</span>p<span class="Delimiter">);</span> -<span id="L60" class="LineNr"> 60 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L61" class="LineNr"> 61 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"translate"</span><span class="Delimiter">)</span> << <span class="Constant">"begin"</span> << end<span class="Delimiter">();</span> -<span id="L62" class="LineNr"> 62 </span> save_elf<span class="Delimiter">(</span>p<span class="Delimiter">,</span> output_filename<span class="Delimiter">);</span> -<span id="L63" class="LineNr"> 63 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L64" class="LineNr"> 64 </span> unlink<span class="Delimiter">(</span>output_filename<span class="Delimiter">.</span>c_str<span class="Delimiter">());</span> -<span id="L65" class="LineNr"> 65 </span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L66" class="LineNr"> 66 </span> <span class="Delimiter">}</span> -<span id="L67" class="LineNr"> 67 </span> <span class="Comment">// End subx translate</span> -<span id="L68" class="LineNr"> 68 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L69" class="LineNr"> 69 </span><span class="Delimiter">}</span> -<span id="L70" class="LineNr"> 70 </span> -<span id="L71" class="LineNr"> 71 </span><span class="Delimiter">:(code)</span> -<span id="L72" class="LineNr"> 72 </span><span class="Normal">void</span> <a href='030---translate.cc.html#L72'>print_translate_usage</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L73" class="LineNr"> 73 </span> cerr << <span class="Constant">"Usage: subx translate file1 file2 ... -o output\n"</span><span class="Delimiter">;</span> +<span id="L1" class="LineNr"> 1 </span><span class="Comment">//: After that lengthy prelude to define an x86 emulator, we are now ready to</span> +<span id="L2" class="LineNr"> 2 </span><span class="Comment">//: start translating SubX notation.</span> +<span id="L3" class="LineNr"> 3 </span> +<span id="L4" class="LineNr"> 4 </span><span class="Comment">//: Translator workflow: read 'source' file. Run a series of transforms on it,</span> +<span id="L5" class="LineNr"> 5 </span><span class="Comment">//: each passing through what it doesn't understand. The final program should</span> +<span id="L6" class="LineNr"> 6 </span><span class="Comment">//: be just machine code, suitable to emulate, or to write to an ELF binary.</span> +<span id="L7" class="LineNr"> 7 </span> +<span id="L8" class="LineNr"> 8 </span><span class="Delimiter">:(before "End Main")</span> +<span id="L9" class="LineNr"> 9 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L102'>is_equal</a><span class="Delimiter">(</span>argv[<span class="Constant">1</span>]<span class="Delimiter">,</span> <span class="Constant">"translate"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L10" class="LineNr"> 10 </span> <span class="Comment">// Outside of tests, traces must be explicitly requested.</span> +<span id="L11" class="LineNr"> 11 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='003trace.cc.html#L448'>Trace_file</a></span><span class="Delimiter">.</span>is_open<span class="Delimiter">())</span> <span class="Special"><a href='003trace.cc.html#L72'>Trace_stream</a></span> = <span class="Normal">new</span> trace_stream<span class="Delimiter">;</span> +<span id="L12" class="LineNr"> 12 </span> <a href='000organization.cc.html#L150'>reset</a><span class="Delimiter">();</span> +<span id="L13" class="LineNr"> 13 </span> <span class="Comment">// Begin bootstrap translate</span> +<span id="L14" class="LineNr"> 14 </span> program p<span class="Delimiter">;</span> +<span id="L15" class="LineNr"> 15 </span> string output_filename<span class="Delimiter">;</span> +<span id="L16" class="LineNr"> 16 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Comment">/*</span><span class="Comment">skip 'bootstrap translate'</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">;</span> i < argc<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L17" class="LineNr"> 17 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L102'>is_equal</a><span class="Delimiter">(</span>argv[i]<span class="Delimiter">,</span> <span class="Constant">"-o"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L18" class="LineNr"> 18 </span> ++i<span class="Delimiter">;</span> +<span id="L19" class="LineNr"> 19 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i >= argc<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L20" class="LineNr"> 20 </span> <a href='030---translate.cc.html#L65'>print_translate_usage</a><span class="Delimiter">();</span> +<span id="L21" class="LineNr"> 21 </span> cerr << <span class="Constant">"'-o' must be followed by a filename to write results to\n"</span><span class="Delimiter">;</span> +<span id="L22" class="LineNr"> 22 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L23" class="LineNr"> 23 </span> <span class="Delimiter">}</span> +<span id="L24" class="LineNr"> 24 </span> output_filename = argv[i]<span class="Delimiter">;</span> +<span id="L25" class="LineNr"> 25 </span> <span class="Delimiter">}</span> +<span id="L26" class="LineNr"> 26 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> +<span id="L27" class="LineNr"> 27 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"parse"</span><span class="Delimiter">)</span> << argv[i] << end<span class="Delimiter">();</span> +<span id="L28" class="LineNr"> 28 </span> ifstream fin<span class="Delimiter">(</span>argv[i]<span class="Delimiter">);</span> +<span id="L29" class="LineNr"> 29 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!fin<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L30" class="LineNr"> 30 </span> cerr << <span class="Constant">"could not open "</span> << argv[i] << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L31" class="LineNr"> 31 </span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L32" class="LineNr"> 32 </span> <span class="Delimiter">}</span> +<span id="L33" class="LineNr"> 33 </span> parse<span class="Delimiter">(</span>fin<span class="Delimiter">,</span> p<span class="Delimiter">);</span> +<span id="L34" class="LineNr"> 34 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L35" class="LineNr"> 35 </span> <span class="Delimiter">}</span> +<span id="L36" class="LineNr"> 36 </span> <span class="Delimiter">}</span> +<span id="L37" class="LineNr"> 37 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L38" class="LineNr"> 38 </span> <a href='030---translate.cc.html#L65'>print_translate_usage</a><span class="Delimiter">();</span> +<span id="L39" class="LineNr"> 39 </span> cerr << <span class="Constant">"nothing to do; must provide at least one file to read\n"</span><span class="Delimiter">;</span> +<span id="L40" class="LineNr"> 40 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L41" class="LineNr"> 41 </span> <span class="Delimiter">}</span> +<span id="L42" class="LineNr"> 42 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>output_filename<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L43" class="LineNr"> 43 </span> <a href='030---translate.cc.html#L65'>print_translate_usage</a><span class="Delimiter">();</span> +<span id="L44" class="LineNr"> 44 </span> cerr << <span class="Constant">"must provide a filename to write to using '-o'\n"</span><span class="Delimiter">;</span> +<span id="L45" class="LineNr"> 45 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L46" class="LineNr"> 46 </span> <span class="Delimiter">}</span> +<span id="L47" class="LineNr"> 47 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"begin"</span> << end<span class="Delimiter">();</span> +<span id="L48" class="LineNr"> 48 </span> transform<span class="Delimiter">(</span>p<span class="Delimiter">);</span> +<span id="L49" class="LineNr"> 49 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L50" class="LineNr"> 50 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"translate"</span><span class="Delimiter">)</span> << <span class="Constant">"begin"</span> << end<span class="Delimiter">();</span> +<span id="L51" class="LineNr"> 51 </span> save_elf<span class="Delimiter">(</span>p<span class="Delimiter">,</span> output_filename<span class="Delimiter">);</span> +<span id="L52" class="LineNr"> 52 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L53" class="LineNr"> 53 </span> unlink<span class="Delimiter">(</span>output_filename<span class="Delimiter">.</span>c_str<span class="Delimiter">());</span> +<span id="L54" class="LineNr"> 54 </span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L55" class="LineNr"> 55 </span> <span class="Delimiter">}</span> +<span id="L56" class="LineNr"> 56 </span> <span class="Comment">// End bootstrap translate</span> +<span id="L57" class="LineNr"> 57 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L58" class="LineNr"> 58 </span><span class="Delimiter">}</span> +<span id="L59" class="LineNr"> 59 </span> +<span id="L60" class="LineNr"> 60 </span><span class="Delimiter">:(code)</span> +<span id="L61" class="LineNr"> 61 </span><span class="Normal">void</span> transform<span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L62" class="LineNr"> 62 </span> <span class="Comment">// End transform(program& p)</span> +<span id="L63" class="LineNr"> 63 </span><span class="Delimiter">}</span> +<span id="L64" class="LineNr"> 64 </span> +<span id="L65" class="LineNr"> 65 </span><span class="Normal">void</span> <a href='030---translate.cc.html#L65'>print_translate_usage</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L66" class="LineNr"> 66 </span> cerr << <span class="Constant">"Usage: bootstrap translate file1 file2 ... -o output\n"</span><span class="Delimiter">;</span> +<span id="L67" class="LineNr"> 67 </span><span class="Delimiter">}</span> +<span id="L68" class="LineNr"> 68 </span> +<span id="L69" class="LineNr"> 69 </span><span class="Comment">// write out a program to a bare-bones ELF file</span> +<span id="L70" class="LineNr"> 70 </span><span class="Normal">void</span> save_elf<span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">,</span> <span class="Normal">const</span> string& filename<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L71" class="LineNr"> 71 </span> ofstream out<span class="Delimiter">(</span>filename<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> ios::binary<span class="Delimiter">);</span> +<span id="L72" class="LineNr"> 72 </span> save_elf<span class="Delimiter">(</span>p<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L73" class="LineNr"> 73 </span> out<span class="Delimiter">.</span>close<span class="Delimiter">();</span> <span id="L74" class="LineNr"> 74 </span><span class="Delimiter">}</span> <span id="L75" class="LineNr"> 75 </span> -<span id="L76" class="LineNr"> 76 </span><span class="Comment">// write out a program to a bare-bones ELF file</span> -<span id="L77" class="LineNr"> 77 </span><span class="Normal">void</span> save_elf<span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">,</span> <span class="Normal">const</span> string& filename<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L78" class="LineNr"> 78 </span> ofstream out<span class="Delimiter">(</span>filename<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> ios::binary<span class="Delimiter">);</span> -<span id="L79" class="LineNr"> 79 </span> save_elf<span class="Delimiter">(</span>p<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L80" class="LineNr"> 80 </span> out<span class="Delimiter">.</span>close<span class="Delimiter">();</span> -<span id="L81" class="LineNr"> 81 </span><span class="Delimiter">}</span> -<span id="L82" class="LineNr"> 82 </span> -<span id="L83" class="LineNr"> 83 </span><span class="Normal">void</span> save_elf<span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L84" class="LineNr"> 84 </span> <span class="Comment">// validation: stay consistent with the self-hosted translator</span> -<span id="L85" class="LineNr"> 85 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>entry</a> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L86" class="LineNr"> 86 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"no 'Entry' label found\n"</span> << end<span class="Delimiter">();</span> -<span id="L87" class="LineNr"> 87 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L88" class="LineNr"> 88 </span> <span class="Delimiter">}</span> -<span id="L89" class="LineNr"> 89 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"data"</span><span class="Delimiter">)</span> == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L90" class="LineNr"> 90 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"must include a 'data' segment\n"</span> << end<span class="Delimiter">();</span> -<span id="L91" class="LineNr"> 91 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L92" class="LineNr"> 92 </span> <span class="Delimiter">}</span> -<span id="L93" class="LineNr"> 93 </span> <span class="Comment">// processing</span> -<span id="L94" class="LineNr"> 94 </span> <a href='030---translate.cc.html#L99'>write_elf_header</a><span class="Delimiter">(</span>out<span class="Delimiter">,</span> p<span class="Delimiter">);</span> -<span id="L95" class="LineNr"> 95 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> -<span id="L96" class="LineNr"> 96 </span> <a href='030---translate.cc.html#L195'>write_segment</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> out<span class="Delimiter">);</span> -<span id="L97" class="LineNr"> 97 </span><span class="Delimiter">}</span> -<span id="L98" class="LineNr"> 98 </span> -<span id="L99" class="LineNr"> 99 </span><span class="Normal">void</span> <a href='030---translate.cc.html#L99'>write_elf_header</a><span class="Delimiter">(</span>ostream& out<span class="Delimiter">,</span> <span class="Normal">const</span> program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L100" class="LineNr">100 </span> <span class="Normal">char</span> c = <span class="cSpecial">'\0'</span><span class="Delimiter">;</span> -<span id="L101" class="LineNr">101 </span><span class="PreProc">#define </span><span class="Special">O</span><span class="PreProc">(</span><span class="Special">X</span><span class="PreProc">) c = (</span><span class="Special">X</span><span class="PreProc">)</span><span class="Delimiter">;</span><span class="PreProc"> out</span><span class="Delimiter">.</span><span class="PreProc">write(&c</span><span class="Delimiter">,</span><span class="PreProc"> </span><span class="Normal">sizeof</span><span class="PreProc">(c))</span> -<span id="L102" class="LineNr">102 </span><span class="Comment">// host is required to be little-endian</span> -<span id="L103" class="LineNr">103 </span><span class="PreProc">#define emit(</span><span class="Special">X</span><span class="PreProc">) out</span><span class="Delimiter">.</span><span class="PreProc">write(</span><span class="Normal">reinterpret_cast</span><span class="PreProc"><</span><span class="Normal">const</span><span class="PreProc"> </span><span class="Normal">char</span><span class="PreProc">*>(&</span><span class="Special">X</span><span class="PreProc">)</span><span class="Delimiter">,</span><span class="PreProc"> </span><span class="Normal">sizeof</span><span class="PreProc">(</span><span class="Special">X</span><span class="PreProc">))</span> -<span id="L104" class="LineNr">104 </span> <span class="SalientComment">//// ehdr</span> -<span id="L105" class="LineNr">105 </span> <span class="Comment">// e_ident</span> -<span id="L106" class="LineNr">106 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x7f</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">E</span><span class="Comment">*/</span><span class="Constant">0x45</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">L</span><span class="Comment">*/</span><span class="Constant">0x4c</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">F</span><span class="Comment">*/</span><span class="Constant">0x46</span><span class="Delimiter">);</span> -<span id="L107" class="LineNr">107 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Comment">// 32-bit format</span> -<span id="L108" class="LineNr">108 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Comment">// little-endian</span> -<span id="L109" class="LineNr">109 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x0</span><span class="Delimiter">);</span> -<span id="L110" class="LineNr">110 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <span class="Constant">8</span><span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span id="L111" class="LineNr">111 </span> <span class="Comment">// e_type</span> -<span id="L112" class="LineNr">112 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x02</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L113" class="LineNr">113 </span> <span class="Comment">// e_machine</span> -<span id="L114" class="LineNr">114 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L115" class="LineNr">115 </span> <span class="Comment">// e_version</span> -<span id="L116" class="LineNr">116 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x01</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L117" class="LineNr">117 </span> <span class="Comment">// e_entry</span> -<span id="L118" class="LineNr">118 </span> <span class="Normal">uint32_t</span> e_entry = p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>entry</a><span class="Delimiter">;</span> -<span id="L119" class="LineNr">119 </span> <span class="Comment">// Override e_entry</span> -<span id="L120" class="LineNr">120 </span> emit<span class="Delimiter">(</span>e_entry<span class="Delimiter">);</span> -<span id="L121" class="LineNr">121 </span> <span class="Comment">// e_phoff -- immediately after ELF header</span> -<span id="L122" class="LineNr">122 </span> <span class="Normal">uint32_t</span> e_phoff = <span class="Constant">0x34</span><span class="Delimiter">;</span> -<span id="L123" class="LineNr">123 </span> emit<span class="Delimiter">(</span>e_phoff<span class="Delimiter">);</span> -<span id="L124" class="LineNr">124 </span> <span class="Comment">// e_shoff; unused</span> -<span id="L125" class="LineNr">125 </span> <span class="Normal">uint32_t</span> dummy32 = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L126" class="LineNr">126 </span> emit<span class="Delimiter">(</span>dummy32<span class="Delimiter">);</span> -<span id="L127" class="LineNr">127 </span> <span class="Comment">// e_flags; unused</span> -<span id="L128" class="LineNr">128 </span> emit<span class="Delimiter">(</span>dummy32<span class="Delimiter">);</span> -<span id="L129" class="LineNr">129 </span> <span class="Comment">// e_ehsize</span> -<span id="L130" class="LineNr">130 </span> <span class="Normal">uint16_t</span> e_ehsize = <span class="Constant">0x34</span><span class="Delimiter">;</span> -<span id="L131" class="LineNr">131 </span> emit<span class="Delimiter">(</span>e_ehsize<span class="Delimiter">);</span> -<span id="L132" class="LineNr">132 </span> <span class="Comment">// e_phentsize</span> -<span id="L133" class="LineNr">133 </span> <span class="Normal">uint16_t</span> e_phentsize = <span class="Constant">0x20</span><span class="Delimiter">;</span> -<span id="L134" class="LineNr">134 </span> emit<span class="Delimiter">(</span>e_phentsize<span class="Delimiter">);</span> -<span id="L135" class="LineNr">135 </span> <span class="Comment">// e_phnum</span> -<span id="L136" class="LineNr">136 </span> <span class="Normal">uint16_t</span> e_phnum = <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">);</span> -<span id="L137" class="LineNr">137 </span> emit<span class="Delimiter">(</span>e_phnum<span class="Delimiter">);</span> -<span id="L138" class="LineNr">138 </span> <span class="Comment">// e_shentsize</span> -<span id="L139" class="LineNr">139 </span> <span class="Normal">uint16_t</span> dummy16 = <span class="Constant">0x0</span><span class="Delimiter">;</span> -<span id="L140" class="LineNr">140 </span> emit<span class="Delimiter">(</span>dummy16<span class="Delimiter">);</span> -<span id="L141" class="LineNr">141 </span> <span class="Comment">// e_shnum</span> -<span id="L142" class="LineNr">142 </span> emit<span class="Delimiter">(</span>dummy16<span class="Delimiter">);</span> -<span id="L143" class="LineNr">143 </span> <span class="Comment">// e_shstrndx</span> -<span id="L144" class="LineNr">144 </span> emit<span class="Delimiter">(</span>dummy16<span class="Delimiter">);</span> -<span id="L145" class="LineNr">145 </span> -<span id="L146" class="LineNr">146 </span> <span class="Normal">uint32_t</span> p_offset = <span class="Comment">/*</span><span class="Comment">size of ehdr</span><span class="Comment">*/</span><span class="Constant">0x34</span> + <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">)</span>*<span class="Constant">0x20</span><span class="Comment">/*</span><span class="Comment">size of each phdr</span><span class="Comment">*/</span><span class="Delimiter">;</span> -<span id="L147" class="LineNr">147 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L148" class="LineNr">148 </span> <span class="Normal">const</span> segment& curr = p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L149" class="LineNr">149 </span> <span class="SalientComment">//// phdr</span> -<span id="L150" class="LineNr">150 </span> <span class="Comment">// p_type</span> -<span id="L151" class="LineNr">151 </span> <span class="Normal">uint32_t</span> p_type = <span class="Constant">0x1</span><span class="Delimiter">;</span> -<span id="L152" class="LineNr">152 </span> emit<span class="Delimiter">(</span>p_type<span class="Delimiter">);</span> -<span id="L153" class="LineNr">153 </span> <span class="Comment">// p_offset</span> -<span id="L154" class="LineNr">154 </span> emit<span class="Delimiter">(</span>p_offset<span class="Delimiter">);</span> -<span id="L155" class="LineNr">155 </span> <span class="Comment">// p_vaddr</span> -<span id="L156" class="LineNr">156 </span> <span class="Normal">uint32_t</span> p_start = curr<span class="Delimiter">.</span>start<span class="Delimiter">;</span> -<span id="L157" class="LineNr">157 </span> emit<span class="Delimiter">(</span>p_start<span class="Delimiter">);</span> -<span id="L158" class="LineNr">158 </span> <span class="Comment">// p_paddr</span> -<span id="L159" class="LineNr">159 </span> emit<span class="Delimiter">(</span>p_start<span class="Delimiter">);</span> -<span id="L160" class="LineNr">160 </span> <span class="Comment">// p_filesz</span> -<span id="L161" class="LineNr">161 </span> <span class="Normal">uint32_t</span> size = <a href='030---translate.cc.html#L205'>num_words</a><span class="Delimiter">(</span>curr<span class="Delimiter">);</span> -<span id="L162" class="LineNr">162 </span> assert<span class="Delimiter">(</span>p_offset + size < <a href='010---vm.cc.html#L95'>SEGMENT_ALIGNMENT</a><span class="Delimiter">);</span> -<span id="L163" class="LineNr">163 </span> emit<span class="Delimiter">(</span>size<span class="Delimiter">);</span> -<span id="L164" class="LineNr">164 </span> <span class="Comment">// p_memsz</span> -<span id="L165" class="LineNr">165 </span> emit<span class="Delimiter">(</span>size<span class="Delimiter">);</span> -<span id="L166" class="LineNr">166 </span> <span class="Comment">// p_flags</span> -<span id="L167" class="LineNr">167 </span> <span class="Normal">uint32_t</span> p_flags = <span class="Delimiter">(</span>curr<span class="Delimiter">.</span><a href='011run.cc.html#L112'>name</a> == <span class="Constant">"code"</span><span class="Delimiter">)</span> ? <span class="Comment">/*</span><span class="Comment">r-x</span><span class="Comment">*/</span><span class="Constant">0x5</span> : <span class="Comment">/*</span><span class="Comment">rw-</span><span class="Comment">*/</span><span class="Constant">0x6</span><span class="Delimiter">;</span> -<span id="L168" class="LineNr">168 </span> emit<span class="Delimiter">(</span>p_flags<span class="Delimiter">);</span> -<span id="L169" class="LineNr">169 </span> -<span id="L170" class="LineNr">170 </span> <span class="Comment">// p_align</span> -<span id="L171" class="LineNr">171 </span> <span class="Comment">// "As the system creates or augments a process image, it logically copies</span> -<span id="L172" class="LineNr">172 </span> <span class="Comment">// a file's segment to a virtual memory segment. When—and if— the system</span> -<span id="L173" class="LineNr">173 </span> <span class="Comment">// physically reads the file depends on the program's execution behavior,</span> -<span id="L174" class="LineNr">174 </span> <span class="Comment">// system load, and so on. A process does not require a physical page</span> -<span id="L175" class="LineNr">175 </span> <span class="Comment">// unless it references the logical page during execution, and processes</span> -<span id="L176" class="LineNr">176 </span> <span class="Comment">// commonly leave many pages unreferenced. Therefore delaying physical</span> -<span id="L177" class="LineNr">177 </span> <span class="Comment">// reads frequently obviates them, improving system performance. To obtain</span> -<span id="L178" class="LineNr">178 </span> <span class="Comment">// this efficiency in practice, executable and shared object files must</span> -<span id="L179" class="LineNr">179 </span> <span class="Comment">// have segment images whose file offsets and virtual addresses are</span> -<span id="L180" class="LineNr">180 </span> <span class="Comment">// congruent, modulo the page size." -- <a href="http://refspecs.linuxbase.org/elf/elf.pdf">http://refspecs.linuxbase.org/elf/elf.pdf</a> (page 95)</span> -<span id="L181" class="LineNr">181 </span> <span class="Normal">uint32_t</span> p_align = <span class="Constant">0x1000</span><span class="Delimiter">;</span> <span class="Comment">// default page size on linux</span> -<span id="L182" class="LineNr">182 </span> emit<span class="Delimiter">(</span>p_align<span class="Delimiter">);</span> -<span id="L183" class="LineNr">183 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p_offset % p_align != p_start % p_align<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L184" class="LineNr">184 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"segment starting at 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << p_start << <span class="Constant">" is improperly aligned; alignment for p_offset "</span> << p_offset << <span class="Constant">" should be "</span> << <span class="Delimiter">(</span>p_offset % p_align<span class="Delimiter">)</span> << <span class="Constant">" but is "</span> << <span class="Delimiter">(</span>p_start % p_align<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> -<span id="L185" class="LineNr">185 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L186" class="LineNr">186 </span> <span class="Delimiter">}</span> +<span id="L76" class="LineNr"> 76 </span><span class="Normal">void</span> save_elf<span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L77" class="LineNr"> 77 </span> <span class="Comment">// validation: stay consistent with the self-hosted translator</span> +<span id="L78" class="LineNr"> 78 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L105'>entry</a> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L79" class="LineNr"> 79 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"no 'Entry' label found\n"</span> << end<span class="Delimiter">();</span> +<span id="L80" class="LineNr"> 80 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L81" class="LineNr"> 81 </span> <span class="Delimiter">}</span> +<span id="L82" class="LineNr"> 82 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"data"</span><span class="Delimiter">)</span> == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L83" class="LineNr"> 83 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"must include a 'data' segment\n"</span> << end<span class="Delimiter">();</span> +<span id="L84" class="LineNr"> 84 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L85" class="LineNr"> 85 </span> <span class="Delimiter">}</span> +<span id="L86" class="LineNr"> 86 </span> <span class="Comment">// processing</span> +<span id="L87" class="LineNr"> 87 </span> <a href='030---translate.cc.html#L92'>write_elf_header</a><span class="Delimiter">(</span>out<span class="Delimiter">,</span> p<span class="Delimiter">);</span> +<span id="L88" class="LineNr"> 88 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> +<span id="L89" class="LineNr"> 89 </span> <a href='030---translate.cc.html#L188'>write_segment</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> out<span class="Delimiter">);</span> +<span id="L90" class="LineNr"> 90 </span><span class="Delimiter">}</span> +<span id="L91" class="LineNr"> 91 </span> +<span id="L92" class="LineNr"> 92 </span><span class="Normal">void</span> <a href='030---translate.cc.html#L92'>write_elf_header</a><span class="Delimiter">(</span>ostream& out<span class="Delimiter">,</span> <span class="Normal">const</span> program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L93" class="LineNr"> 93 </span> <span class="Normal">char</span> c = <span class="cSpecial">'\0'</span><span class="Delimiter">;</span> +<span id="L94" class="LineNr"> 94 </span><span class="PreProc">#define </span><span class="Special">O</span><span class="PreProc">(</span><span class="Special">X</span><span class="PreProc">) c = (</span><span class="Special">X</span><span class="PreProc">)</span><span class="Delimiter">;</span><span class="PreProc"> out</span><span class="Delimiter">.</span><span class="PreProc">write(&c</span><span class="Delimiter">,</span><span class="PreProc"> </span><span class="Normal">sizeof</span><span class="PreProc">(c))</span> +<span id="L95" class="LineNr"> 95 </span><span class="Comment">// host is required to be little-endian</span> +<span id="L96" class="LineNr"> 96 </span><span class="PreProc">#define emit(</span><span class="Special">X</span><span class="PreProc">) out</span><span class="Delimiter">.</span><span class="PreProc">write(</span><span class="Normal">reinterpret_cast</span><span class="PreProc"><</span><span class="Normal">const</span><span class="PreProc"> </span><span class="Normal">char</span><span class="PreProc">*>(&</span><span class="Special">X</span><span class="PreProc">)</span><span class="Delimiter">,</span><span class="PreProc"> </span><span class="Normal">sizeof</span><span class="PreProc">(</span><span class="Special">X</span><span class="PreProc">))</span> +<span id="L97" class="LineNr"> 97 </span> <span class="SalientComment">//// ehdr</span> +<span id="L98" class="LineNr"> 98 </span> <span class="Comment">// e_ident</span> +<span id="L99" class="LineNr"> 99 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x7f</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">E</span><span class="Comment">*/</span><span class="Constant">0x45</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">L</span><span class="Comment">*/</span><span class="Constant">0x4c</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">F</span><span class="Comment">*/</span><span class="Constant">0x46</span><span class="Delimiter">);</span> +<span id="L100" class="LineNr">100 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Comment">// 32-bit format</span> +<span id="L101" class="LineNr">101 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Comment">// little-endian</span> +<span id="L102" class="LineNr">102 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x0</span><span class="Delimiter">);</span> +<span id="L103" class="LineNr">103 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <span class="Constant">8</span><span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> +<span id="L104" class="LineNr">104 </span> <span class="Comment">// e_type</span> +<span id="L105" class="LineNr">105 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x02</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L106" class="LineNr">106 </span> <span class="Comment">// e_machine</span> +<span id="L107" class="LineNr">107 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L108" class="LineNr">108 </span> <span class="Comment">// e_version</span> +<span id="L109" class="LineNr">109 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x01</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L110" class="LineNr">110 </span> <span class="Comment">// e_entry</span> +<span id="L111" class="LineNr">111 </span> <span class="Normal">uint32_t</span> e_entry = p<span class="Delimiter">.</span><a href='011run.cc.html#L105'>entry</a><span class="Delimiter">;</span> +<span id="L112" class="LineNr">112 </span> <span class="Comment">// Override e_entry</span> +<span id="L113" class="LineNr">113 </span> emit<span class="Delimiter">(</span>e_entry<span class="Delimiter">);</span> +<span id="L114" class="LineNr">114 </span> <span class="Comment">// e_phoff -- immediately after ELF header</span> +<span id="L115" class="LineNr">115 </span> <span class="Normal">uint32_t</span> e_phoff = <span class="Constant">0x34</span><span class="Delimiter">;</span> +<span id="L116" class="LineNr">116 </span> emit<span class="Delimiter">(</span>e_phoff<span class="Delimiter">);</span> +<span id="L117" class="LineNr">117 </span> <span class="Comment">// e_shoff; unused</span> +<span id="L118" class="LineNr">118 </span> <span class="Normal">uint32_t</span> dummy32 = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L119" class="LineNr">119 </span> emit<span class="Delimiter">(</span>dummy32<span class="Delimiter">);</span> +<span id="L120" class="LineNr">120 </span> <span class="Comment">// e_flags; unused</span> +<span id="L121" class="LineNr">121 </span> emit<span class="Delimiter">(</span>dummy32<span class="Delimiter">);</span> +<span id="L122" class="LineNr">122 </span> <span class="Comment">// e_ehsize</span> +<span id="L123" class="LineNr">123 </span> <span class="Normal">uint16_t</span> e_ehsize = <span class="Constant">0x34</span><span class="Delimiter">;</span> +<span id="L124" class="LineNr">124 </span> emit<span class="Delimiter">(</span>e_ehsize<span class="Delimiter">);</span> +<span id="L125" class="LineNr">125 </span> <span class="Comment">// e_phentsize</span> +<span id="L126" class="LineNr">126 </span> <span class="Normal">uint16_t</span> e_phentsize = <span class="Constant">0x20</span><span class="Delimiter">;</span> +<span id="L127" class="LineNr">127 </span> emit<span class="Delimiter">(</span>e_phentsize<span class="Delimiter">);</span> +<span id="L128" class="LineNr">128 </span> <span class="Comment">// e_phnum</span> +<span id="L129" class="LineNr">129 </span> <span class="Normal">uint16_t</span> e_phnum = <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">);</span> +<span id="L130" class="LineNr">130 </span> emit<span class="Delimiter">(</span>e_phnum<span class="Delimiter">);</span> +<span id="L131" class="LineNr">131 </span> <span class="Comment">// e_shentsize</span> +<span id="L132" class="LineNr">132 </span> <span class="Normal">uint16_t</span> dummy16 = <span class="Constant">0x0</span><span class="Delimiter">;</span> +<span id="L133" class="LineNr">133 </span> emit<span class="Delimiter">(</span>dummy16<span class="Delimiter">);</span> +<span id="L134" class="LineNr">134 </span> <span class="Comment">// e_shnum</span> +<span id="L135" class="LineNr">135 </span> emit<span class="Delimiter">(</span>dummy16<span class="Delimiter">);</span> +<span id="L136" class="LineNr">136 </span> <span class="Comment">// e_shstrndx</span> +<span id="L137" class="LineNr">137 </span> emit<span class="Delimiter">(</span>dummy16<span class="Delimiter">);</span> +<span id="L138" class="LineNr">138 </span> +<span id="L139" class="LineNr">139 </span> <span class="Normal">uint32_t</span> p_offset = <span class="Comment">/*</span><span class="Comment">size of ehdr</span><span class="Comment">*/</span><span class="Constant">0x34</span> + <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">)</span>*<span class="Constant">0x20</span><span class="Comment">/*</span><span class="Comment">size of each phdr</span><span class="Comment">*/</span><span class="Delimiter">;</span> +<span id="L140" class="LineNr">140 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L141" class="LineNr">141 </span> <span class="Normal">const</span> segment& curr = p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L142" class="LineNr">142 </span> <span class="SalientComment">//// phdr</span> +<span id="L143" class="LineNr">143 </span> <span class="Comment">// p_type</span> +<span id="L144" class="LineNr">144 </span> <span class="Normal">uint32_t</span> p_type = <span class="Constant">0x1</span><span class="Delimiter">;</span> +<span id="L145" class="LineNr">145 </span> emit<span class="Delimiter">(</span>p_type<span class="Delimiter">);</span> +<span id="L146" class="LineNr">146 </span> <span class="Comment">// p_offset</span> +<span id="L147" class="LineNr">147 </span> emit<span class="Delimiter">(</span>p_offset<span class="Delimiter">);</span> +<span id="L148" class="LineNr">148 </span> <span class="Comment">// p_vaddr</span> +<span id="L149" class="LineNr">149 </span> <span class="Normal">uint32_t</span> p_start = curr<span class="Delimiter">.</span>start<span class="Delimiter">;</span> +<span id="L150" class="LineNr">150 </span> emit<span class="Delimiter">(</span>p_start<span class="Delimiter">);</span> +<span id="L151" class="LineNr">151 </span> <span class="Comment">// p_paddr</span> +<span id="L152" class="LineNr">152 </span> emit<span class="Delimiter">(</span>p_start<span class="Delimiter">);</span> +<span id="L153" class="LineNr">153 </span> <span class="Comment">// p_filesz</span> +<span id="L154" class="LineNr">154 </span> <span class="Normal">uint32_t</span> size = <a href='030---translate.cc.html#L198'>num_words</a><span class="Delimiter">(</span>curr<span class="Delimiter">);</span> +<span id="L155" class="LineNr">155 </span> assert<span class="Delimiter">(</span>p_offset + size < <a href='010---vm.cc.html#L89'>SEGMENT_ALIGNMENT</a><span class="Delimiter">);</span> +<span id="L156" class="LineNr">156 </span> emit<span class="Delimiter">(</span>size<span class="Delimiter">);</span> +<span id="L157" class="LineNr">157 </span> <span class="Comment">// p_memsz</span> +<span id="L158" class="LineNr">158 </span> emit<span class="Delimiter">(</span>size<span class="Delimiter">);</span> +<span id="L159" class="LineNr">159 </span> <span class="Comment">// p_flags</span> +<span id="L160" class="LineNr">160 </span> <span class="Normal">uint32_t</span> p_flags = <span class="Delimiter">(</span>curr<span class="Delimiter">.</span><a href='011run.cc.html#L111'>name</a> == <span class="Constant">"code"</span><span class="Delimiter">)</span> ? <span class="Comment">/*</span><span class="Comment">r-x</span><span class="Comment">*/</span><span class="Constant">0x5</span> : <span class="Comment">/*</span><span class="Comment">rw-</span><span class="Comment">*/</span><span class="Constant">0x6</span><span class="Delimiter">;</span> +<span id="L161" class="LineNr">161 </span> emit<span class="Delimiter">(</span>p_flags<span class="Delimiter">);</span> +<span id="L162" class="LineNr">162 </span> +<span id="L163" class="LineNr">163 </span> <span class="Comment">// p_align</span> +<span id="L164" class="LineNr">164 </span> <span class="Comment">// "As the system creates or augments a process image, it logically copies</span> +<span id="L165" class="LineNr">165 </span> <span class="Comment">// a file's segment to a virtual memory segment. When—and if— the system</span> +<span id="L166" class="LineNr">166 </span> <span class="Comment">// physically reads the file depends on the program's execution behavior,</span> +<span id="L167" class="LineNr">167 </span> <span class="Comment">// system load, and so on. A process does not require a physical page</span> +<span id="L168" class="LineNr">168 </span> <span class="Comment">// unless it references the logical page during execution, and processes</span> +<span id="L169" class="LineNr">169 </span> <span class="Comment">// commonly leave many pages unreferenced. Therefore delaying physical</span> +<span id="L170" class="LineNr">170 </span> <span class="Comment">// reads frequently obviates them, improving system performance. To obtain</span> +<span id="L171" class="LineNr">171 </span> <span class="Comment">// this efficiency in practice, executable and shared object files must</span> +<span id="L172" class="LineNr">172 </span> <span class="Comment">// have segment images whose file offsets and virtual addresses are</span> +<span id="L173" class="LineNr">173 </span> <span class="Comment">// congruent, modulo the page size." -- <a href="http://refspecs.linuxbase.org/elf/elf.pdf">http://refspecs.linuxbase.org/elf/elf.pdf</a> (page 95)</span> +<span id="L174" class="LineNr">174 </span> <span class="Normal">uint32_t</span> p_align = <span class="Constant">0x1000</span><span class="Delimiter">;</span> <span class="Comment">// default page size on linux</span> +<span id="L175" class="LineNr">175 </span> emit<span class="Delimiter">(</span>p_align<span class="Delimiter">);</span> +<span id="L176" class="LineNr">176 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p_offset % p_align != p_start % p_align<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L177" class="LineNr">177 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"segment starting at 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << p_start << <span class="Constant">" is improperly aligned; alignment for p_offset "</span> << p_offset << <span class="Constant">" should be "</span> << <span class="Delimiter">(</span>p_offset % p_align<span class="Delimiter">)</span> << <span class="Constant">" but is "</span> << <span class="Delimiter">(</span>p_start % p_align<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L178" class="LineNr">178 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L179" class="LineNr">179 </span> <span class="Delimiter">}</span> +<span id="L180" class="LineNr">180 </span> +<span id="L181" class="LineNr">181 </span> <span class="Comment">// prepare for next segment</span> +<span id="L182" class="LineNr">182 </span> p_offset += size<span class="Delimiter">;</span> +<span id="L183" class="LineNr">183 </span> <span class="Delimiter">}</span> +<span id="L184" class="LineNr">184 </span><span class="PreProc">#undef </span><span class="Special">O</span> +<span id="L185" class="LineNr">185 </span><span class="PreProc">#undef emit</span> +<span id="L186" class="LineNr">186 </span><span class="Delimiter">}</span> <span id="L187" class="LineNr">187 </span> -<span id="L188" class="LineNr">188 </span> <span class="Comment">// prepare for next segment</span> -<span id="L189" class="LineNr">189 </span> p_offset += size<span class="Delimiter">;</span> -<span id="L190" class="LineNr">190 </span> <span class="Delimiter">}</span> -<span id="L191" class="LineNr">191 </span><span class="PreProc">#undef </span><span class="Special">O</span> -<span id="L192" class="LineNr">192 </span><span class="PreProc">#undef emit</span> -<span id="L193" class="LineNr">193 </span><span class="Delimiter">}</span> -<span id="L194" class="LineNr">194 </span> -<span id="L195" class="LineNr">195 </span><span class="Normal">void</span> <a href='030---translate.cc.html#L195'>write_segment</a><span class="Delimiter">(</span><span class="Normal">const</span> segment& s<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L196" class="LineNr">196 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L197" class="LineNr">197 </span> <span class="Normal">const</span> vector<word>& w = s<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">;</span> -<span id="L198" class="LineNr">198 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L199" class="LineNr">199 </span> <span class="Normal">uint8_t</span> x = <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>data<span class="Delimiter">);</span> <span class="Comment">// we're done with metadata by this point</span> -<span id="L200" class="LineNr">200 </span> out<span class="Delimiter">.</span>write<span class="Delimiter">(</span><span class="Normal">reinterpret_cast</span><<span class="Normal">const</span> <span class="Normal">char</span>*><span class="Delimiter">(</span>&x<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">sizeof(byte)</span><span class="Comment">*/</span><span class="Constant">1</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="L188" class="LineNr">188 </span><span class="Normal">void</span> <a href='030---translate.cc.html#L188'>write_segment</a><span class="Delimiter">(</span><span class="Normal">const</span> segment& s<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L189" class="LineNr">189 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L190" class="LineNr">190 </span> <span class="Normal">const</span> vector<word>& w = s<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">;</span> +<span id="L191" class="LineNr">191 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L192" class="LineNr">192 </span> <span class="Normal">uint8_t</span> x = <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">).</span>data<span class="Delimiter">);</span> <span class="Comment">// we're done with metadata by this point</span> +<span id="L193" class="LineNr">193 </span> out<span class="Delimiter">.</span>write<span class="Delimiter">(</span><span class="Normal">reinterpret_cast</span><<span class="Normal">const</span> <span class="Normal">char</span>*><span class="Delimiter">(</span>&x<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">sizeof(byte)</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L194" class="LineNr">194 </span> <span class="Delimiter">}</span> +<span id="L195" class="LineNr">195 </span> <span class="Delimiter">}</span> +<span id="L196" class="LineNr">196 </span><span class="Delimiter">}</span> +<span id="L197" class="LineNr">197 </span> +<span id="L198" class="LineNr">198 </span><span class="Normal">uint32_t</span> <a href='030---translate.cc.html#L198'>num_words</a><span class="Delimiter">(</span><span class="Normal">const</span> segment& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L199" class="LineNr">199 </span> <span class="Normal">uint32_t</span> sum = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L200" class="LineNr">200 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L201" class="LineNr">201 </span> sum += <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> +<span id="L202" class="LineNr">202 </span> <span class="Identifier">return</span> sum<span class="Delimiter">;</span> <span id="L203" class="LineNr">203 </span><span class="Delimiter">}</span> <span id="L204" class="LineNr">204 </span> -<span id="L205" class="LineNr">205 </span><span class="Normal">uint32_t</span> <a href='030---translate.cc.html#L205'>num_words</a><span class="Delimiter">(</span><span class="Normal">const</span> segment& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L206" class="LineNr">206 </span> <span class="Normal">uint32_t</span> sum = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L207" class="LineNr">207 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L208" class="LineNr">208 </span> sum += <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> -<span id="L209" class="LineNr">209 </span> <span class="Identifier">return</span> sum<span class="Delimiter">;</span> -<span id="L210" class="LineNr">210 </span><span class="Delimiter">}</span> -<span id="L211" class="LineNr">211 </span> -<span id="L212" class="LineNr">212 </span><span class="Delimiter">:(before "End Includes")</span> -<span id="L213" class="LineNr">213 </span><span class="Normal">using</span> std::ios<span class="Delimiter">;</span> +<span id="L205" class="LineNr">205 </span><span class="Delimiter">:(before "End Includes")</span> +<span id="L206" class="LineNr">206 </span><span class="Normal">using</span> std::ios<span class="Delimiter">;</span> </pre> </body> </html> diff --git a/html/031transforms.cc.html b/html/031transforms.cc.html index 2589975b..73e7b823 100644 --- a/html/031transforms.cc.html +++ b/html/031transforms.cc.html @@ -15,8 +15,11 @@ body { font-size:12pt; font-family: monospace; color: #000000; background-color: a { color:inherit; } * { font-size:12pt; font-size: 1em; } .LineNr { } +.Constant { color: #008787; } .Comment { color: #005faf; } .Delimiter { color: #c000c0; } +.Special { color: #d70000; } +.Normal { color: #000000; background-color: #c6c6c6; padding-bottom: 1px; } --> </style> @@ -52,71 +55,18 @@ if ('onhashchange' in window) { <body onload='JumpToLine();'> <a href='https://github.com/akkartik/mu/blob/master/031transforms.cc'>https://github.com/akkartik/mu/blob/master/031transforms.cc</a> <pre id='vimCodeElement'> -<span id="L1" class="LineNr"> 1 </span><span class="Comment">//: Ordering transforms is a well-known hard problem when building compilers.</span> -<span id="L2" class="LineNr"> 2 </span><span class="Comment">//: In our case we also have the additional notion of layers. The ordering of</span> -<span id="L3" class="LineNr"> 3 </span><span class="Comment">//: layers can have nothing in common with the ordering of transforms when</span> -<span id="L4" class="LineNr"> 4 </span><span class="Comment">//: SubX is tangled and run. This can be confusing for readers, particularly</span> -<span id="L5" class="LineNr"> 5 </span><span class="Comment">//: if later layers start inserting transforms at arbitrary points between</span> -<span id="L6" class="LineNr"> 6 </span><span class="Comment">//: transforms introduced earlier. Over time adding transforms can get harder</span> -<span id="L7" class="LineNr"> 7 </span><span class="Comment">//: and harder, having to meet the constraints of everything that's come</span> -<span id="L8" class="LineNr"> 8 </span><span class="Comment">//: before. It's worth thinking about organization up-front so the ordering is</span> -<span id="L9" class="LineNr"> 9 </span><span class="Comment">//: easy to hold in our heads, and it's obvious where to add a new transform.</span> -<span id="L10" class="LineNr">10 </span><span class="Comment">//: Some constraints:</span> -<span id="L11" class="LineNr">11 </span><span class="Comment">//:</span> -<span id="L12" class="LineNr">12 </span><span class="Comment">//: 1. Layers force us to build SubX bottom-up; since we want to be able to</span> -<span id="L13" class="LineNr">13 </span><span class="Comment">//: build and run SubX after stopping loading at any layer, the overall</span> -<span id="L14" class="LineNr">14 </span><span class="Comment">//: organization has to be to introduce primitives before we start using</span> -<span id="L15" class="LineNr">15 </span><span class="Comment">//: them.</span> -<span id="L16" class="LineNr">16 </span><span class="Comment">//:</span> -<span id="L17" class="LineNr">17 </span><span class="Comment">//: 2. Transforms usually need to be run top-down, converting high-level</span> -<span id="L18" class="LineNr">18 </span><span class="Comment">//: representations to low-level ones so that low-level layers can be</span> -<span id="L19" class="LineNr">19 </span><span class="Comment">//: oblivious to them.</span> -<span id="L20" class="LineNr">20 </span><span class="Comment">//:</span> -<span id="L21" class="LineNr">21 </span><span class="Comment">//: 3. When running we'd often like new representations to be checked before</span> -<span id="L22" class="LineNr">22 </span><span class="Comment">//: they are transformed away. The whole reason for new representations is</span> -<span id="L23" class="LineNr">23 </span><span class="Comment">//: often to add new kinds of automatic checking for our machine code</span> -<span id="L24" class="LineNr">24 </span><span class="Comment">//: programs.</span> -<span id="L25" class="LineNr">25 </span><span class="Comment">//:</span> -<span id="L26" class="LineNr">26 </span><span class="Comment">//: Putting these constraints together, we'll use the following broad</span> -<span id="L27" class="LineNr">27 </span><span class="Comment">//: organization:</span> -<span id="L28" class="LineNr">28 </span><span class="Comment">//:</span> -<span id="L29" class="LineNr">29 </span><span class="Comment">//: a) We'll divide up our transforms into "levels", each level consisting</span> -<span id="L30" class="LineNr">30 </span><span class="Comment">//: of multiple transforms, and dealing in some new set of representational</span> -<span id="L31" class="LineNr">31 </span><span class="Comment">//: ideas. Levels will be added in reverse order to the one their transforms</span> -<span id="L32" class="LineNr">32 </span><span class="Comment">//: will be run in.</span> -<span id="L33" class="LineNr">33 </span><span class="Comment">//:</span> -<span id="L34" class="LineNr">34 </span><span class="Comment">//: To run all transforms:</span> -<span id="L35" class="LineNr">35 </span><span class="Comment">//: Load transforms for level n</span> -<span id="L36" class="LineNr">36 </span><span class="Comment">//: Load transforms for level n-1</span> -<span id="L37" class="LineNr">37 </span><span class="Comment">//: ...</span> -<span id="L38" class="LineNr">38 </span><span class="Comment">//: Load transforms for level 2</span> -<span id="L39" class="LineNr">39 </span><span class="Comment">//: Run code at level 1</span> -<span id="L40" class="LineNr">40 </span><span class="Comment">//:</span> -<span id="L41" class="LineNr">41 </span><span class="Comment">//: b) *Within* a level we'll usually introduce transforms in the order</span> -<span id="L42" class="LineNr">42 </span><span class="Comment">//: they're run in.</span> -<span id="L43" class="LineNr">43 </span><span class="Comment">//:</span> -<span id="L44" class="LineNr">44 </span><span class="Comment">//: To run transforms for level n:</span> -<span id="L45" class="LineNr">45 </span><span class="Comment">//: Perform transform of layer l</span> -<span id="L46" class="LineNr">46 </span><span class="Comment">//: Perform transform of layer l+1</span> -<span id="L47" class="LineNr">47 </span><span class="Comment">//: ...</span> -<span id="L48" class="LineNr">48 </span><span class="Comment">//:</span> -<span id="L49" class="LineNr">49 </span><span class="Comment">//: c) Within a level it's often most natural to introduce a new</span> -<span id="L50" class="LineNr">50 </span><span class="Comment">//: representation by showing how it's transformed to the level below. To</span> -<span id="L51" class="LineNr">51 </span><span class="Comment">//: make such exceptions more obvious checks usually won't be first-class</span> -<span id="L52" class="LineNr">52 </span><span class="Comment">//: transforms; instead code that keeps the program unmodified will run</span> -<span id="L53" class="LineNr">53 </span><span class="Comment">//: within transforms before they mutate the program. As an example:</span> -<span id="L54" class="LineNr">54 </span><span class="Comment">//:</span> -<span id="L55" class="LineNr">55 </span><span class="Comment">//: Layer l introduces a transform</span> -<span id="L56" class="LineNr">56 </span><span class="Comment">//: Layer l+1 adds precondition checks for the transform</span> -<span id="L57" class="LineNr">57 </span><span class="Comment">//:</span> -<span id="L58" class="LineNr">58 </span><span class="Comment">//: This may all seem abstract, but will hopefully make sense over time. The</span> -<span id="L59" class="LineNr">59 </span><span class="Comment">//: goals are basically to always have a working program after any layer, to</span> -<span id="L60" class="LineNr">60 </span><span class="Comment">//: have the order of layers make narrative sense, and to order transforms</span> -<span id="L61" class="LineNr">61 </span><span class="Comment">//: correctly at runtime.</span> -<span id="L62" class="LineNr">62 </span> -<span id="L63" class="LineNr">63 </span><span class="Delimiter">:(before "End One-time Setup")</span> -<span id="L64" class="LineNr">64 </span><span class="Comment">// Begin Transforms</span> -<span id="L65" class="LineNr">65 </span><span class="Comment">// End Transforms</span> +<span id="L1" class="LineNr"> 1 </span><span class="Delimiter">:(before "End Types")</span> +<span id="L2" class="LineNr"> 2 </span><span class="Normal">typedef</span> <span class="Normal">void</span> <span class="Delimiter">(</span>*transform_fn<span class="Delimiter">)(</span>program&<span class="Delimiter">);</span> +<span id="L3" class="LineNr"> 3 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L4" class="LineNr"> 4 </span>vector<transform_fn> <span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">;</span> +<span id="L5" class="LineNr"> 5 </span> +<span id="L6" class="LineNr"> 6 </span><span class="Delimiter">:(before "End transform(program& p)")</span> +<span id="L7" class="LineNr"> 7 </span><span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> t = <span class="Constant">0</span><span class="Delimiter">;</span> t < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span><span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">);</span> ++t<span class="Delimiter">)</span> +<span id="L8" class="LineNr"> 8 </span> <span class="Delimiter">(</span>*<span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">.</span>at<span class="Delimiter">(</span>t<span class="Delimiter">))(</span>p<span class="Delimiter">);</span> +<span id="L9" class="LineNr"> 9 </span> +<span id="L10" class="LineNr">10 </span><span class="Delimiter">:(before "End One-time Setup")</span> +<span id="L11" class="LineNr">11 </span><span class="Comment">// Begin Transforms</span> +<span id="L12" class="LineNr">12 </span><span class="Comment">// End Transforms</span> </pre> </body> </html> diff --git a/html/032---operands.cc.html b/html/032---operands.cc.html index ac421edd..30d288ce 100644 --- a/html/032---operands.cc.html +++ b/html/032---operands.cc.html @@ -58,545 +58,546 @@ if ('onhashchange' in window) { <body onload='JumpToLine();'> <a href='https://github.com/akkartik/mu/blob/master/032---operands.cc'>https://github.com/akkartik/mu/blob/master/032---operands.cc</a> <pre id='vimCodeElement'> -<span id="L1" class="LineNr"> 1 </span><span class="Comment">//: Beginning of "level 2": tagging bytes with metadata around what field of</span> -<span id="L2" class="LineNr"> 2 </span><span class="Comment">//: an x86 instruction they're for.</span> -<span id="L3" class="LineNr"> 3 </span><span class="Comment">//:</span> -<span id="L4" class="LineNr"> 4 </span><span class="Comment">//: The x86 instruction set is variable-length, and how a byte is interpreted</span> -<span id="L5" class="LineNr"> 5 </span><span class="Comment">//: affects later instruction boundaries. A lot of the pain in programming</span> -<span id="L6" class="LineNr"> 6 </span><span class="Comment">//: machine code stems from computer and programmer going out of sync on what</span> -<span id="L7" class="LineNr"> 7 </span><span class="Comment">//: a byte means. The miscommunication is usually not immediately caught, and</span> -<span id="L8" class="LineNr"> 8 </span><span class="Comment">//: metastasizes at runtime into kilobytes of misinterpreted instructions.</span> -<span id="L9" class="LineNr"> 9 </span><span class="Comment">//:</span> -<span id="L10" class="LineNr"> 10 </span><span class="Comment">//: To mitigate these issues, we'll start programming in terms of logical</span> -<span id="L11" class="LineNr"> 11 </span><span class="Comment">//: operands rather than physical bytes. Some operands are smaller than a</span> -<span id="L12" class="LineNr"> 12 </span><span class="Comment">//: byte, and others may consist of multiple bytes. This layer will correctly</span> -<span id="L13" class="LineNr"> 13 </span><span class="Comment">//: pack and order the bytes corresponding to the operands in an instruction.</span> -<span id="L14" class="LineNr"> 14 </span> -<span id="L15" class="LineNr"> 15 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Texts")</span> -<span id="L16" class="LineNr"> 16 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='001help.cc.html#L53'>Help</a></span><span class="Delimiter">,</span> <span class="Constant">"instructions"</span><span class="Delimiter">,</span> -<span id="L17" class="LineNr"> 17 </span> <span class="Constant">"Each x86 instruction consists of an instruction or opcode and some number\n"</span> -<span id="L18" class="LineNr"> 18 </span> <span class="Constant">"of operands.\n"</span> -<span id="L19" class="LineNr"> 19 </span> <span class="Constant">"Each operand has a type. An instruction won't have more than one operand of\n"</span> -<span id="L20" class="LineNr"> 20 </span> <span class="Constant">"any type.\n"</span> -<span id="L21" class="LineNr"> 21 </span> <span class="Constant">"Each instruction has some set of allowed operand types. It'll reject others.\n"</span> -<span id="L22" class="LineNr"> 22 </span> <span class="Constant">"The complete list of operand types: mod, subop, r32 (register), rm32\n"</span> -<span id="L23" class="LineNr"> 23 </span> <span class="Constant">"(register or memory), scale, index, base, disp8, disp16, <a href='040---tests.cc.html#L84'>disp32</a>, imm8,\n"</span> -<span id="L24" class="LineNr"> 24 </span> <span class="Constant">"imm32.\n"</span> -<span id="L25" class="LineNr"> 25 </span> <span class="Constant">"Each of these has its own help page. Try reading 'subx help mod' next.\n"</span> -<span id="L26" class="LineNr"> 26 </span><span class="Delimiter">);</span> -<span id="L27" class="LineNr"> 27 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Contents")</span> -<span id="L28" class="LineNr"> 28 </span>cerr << <span class="Constant">" instructions\n"</span><span class="Delimiter">;</span> -<span id="L29" class="LineNr"> 29 </span> -<span id="L30" class="LineNr"> 30 </span><span class="Delimiter">:(code)</span> -<span id="L31" class="LineNr"> 31 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L31'>test_pack_immediate_constants</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L32" class="LineNr"> 32 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> -<span id="L33" class="LineNr"> 33 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L34" class="LineNr"> 34 </span> <span class="Constant">"bb 0x2a/imm32\n"</span> -<span id="L35" class="LineNr"> 35 </span> <span class="Delimiter">);</span> -<span id="L36" class="LineNr"> 36 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L37" class="LineNr"> 37 </span> <span class="Constant">"transform: packing instruction 'bb 0x2a/imm32'\n"</span> -<span id="L38" class="LineNr"> 38 </span> <span class="Constant">"transform: instruction after packing: 'bb 2a 00 00 00'\n"</span> -<span id="L39" class="LineNr"> 39 </span> <span class="Constant">"run: copy imm32 0x0000002a to EBX\n"</span> -<span id="L40" class="LineNr"> 40 </span> <span class="Delimiter">);</span> -<span id="L41" class="LineNr"> 41 </span><span class="Delimiter">}</span> -<span id="L42" class="LineNr"> 42 </span> -<span id="L43" class="LineNr"> 43 </span><span class="Comment">//: complete set of valid operand types</span> -<span id="L44" class="LineNr"> 44 </span> -<span id="L45" class="LineNr"> 45 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L46" class="LineNr"> 46 </span>set<string> <span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">;</span> -<span id="L47" class="LineNr"> 47 </span><span class="Delimiter">:(before "End One-time Setup")</span> -<span id="L48" class="LineNr"> 48 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"subop"</span><span class="Delimiter">);</span> -<span id="L49" class="LineNr"> 49 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"mod"</span><span class="Delimiter">);</span> -<span id="L50" class="LineNr"> 50 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"rm32"</span><span class="Delimiter">);</span> -<span id="L51" class="LineNr"> 51 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"base"</span><span class="Delimiter">);</span> -<span id="L52" class="LineNr"> 52 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"index"</span><span class="Delimiter">);</span> -<span id="L53" class="LineNr"> 53 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"scale"</span><span class="Delimiter">);</span> -<span id="L54" class="LineNr"> 54 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"r32"</span><span class="Delimiter">);</span> -<span id="L55" class="LineNr"> 55 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"disp8"</span><span class="Delimiter">);</span> -<span id="L56" class="LineNr"> 56 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"disp16"</span><span class="Delimiter">);</span> -<span id="L57" class="LineNr"> 57 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"disp32"</span><span class="Delimiter">);</span> -<span id="L58" class="LineNr"> 58 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"imm8"</span><span class="Delimiter">);</span> -<span id="L59" class="LineNr"> 59 </span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"imm32"</span><span class="Delimiter">);</span> -<span id="L60" class="LineNr"> 60 </span> -<span id="L61" class="LineNr"> 61 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Texts")</span> -<span id="L62" class="LineNr"> 62 </span><a href='032---operands.cc.html#L64'>init_operand_type_help</a><span class="Delimiter">();</span> -<span id="L63" class="LineNr"> 63 </span><span class="Delimiter">:(code)</span> -<span id="L64" class="LineNr"> 64 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L64'>init_operand_type_help</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L65" class="LineNr"> 65 </span> <a href='001help.cc.html#L255'>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">"mod"</span><span class="Delimiter">,</span> -<span id="L66" class="LineNr"> 66 </span> <span class="Constant">"2-bit operand controlling the _addressing mode_ of many instructions,\n"</span> -<span id="L67" class="LineNr"> 67 </span> <span class="Constant">"to determine how to compute the _effective address_ to look up memory at\n"</span> -<span id="L68" class="LineNr"> 68 </span> <span class="Constant">"based on the 'rm32' operand and potentially others.\n"</span> -<span id="L69" class="LineNr"> 69 </span> <span class="Constant">"\n"</span> -<span id="L70" class="LineNr"> 70 </span> <span class="Constant">"If mod = 3, just operate on the <a href='003trace.cc.html#L117'>contents</a> of the register specified by rm32\n"</span> -<span id="L71" class="LineNr"> 71 </span> <span class="Constant">" (direct mode).\n"</span> -<span id="L72" class="LineNr"> 72 </span> <span class="Constant">"If mod = 2, effective address is usually* rm32 + disp32\n"</span> -<span id="L73" class="LineNr"> 73 </span> <span class="Constant">" (indirect mode with displacement).\n"</span> -<span id="L74" class="LineNr"> 74 </span> <span class="Constant">"If mod = 1, effective address is usually* rm32 + disp8\n"</span> -<span id="L75" class="LineNr"> 75 </span> <span class="Constant">" (indirect mode with displacement).\n"</span> -<span id="L76" class="LineNr"> 76 </span> <span class="Constant">"If mod = 0, effective address is usually* rm32 (indirect mode).\n"</span> -<span id="L77" class="LineNr"> 77 </span> <span class="Constant">"(* - The exception is when rm32 is '4'. Register 4 is the stack pointer (<a href='010---vm.cc.html#L20'>ESP</a>).\n"</span> -<span id="L78" class="LineNr"> 78 </span> <span class="Constant">" Using it as an address gets more involved. For more details,\n"</span> -<span id="L79" class="LineNr"> 79 </span> <span class="Constant">" try reading the help pages for 'base', 'index' and 'scale'.)\n"</span> -<span id="L80" class="LineNr"> 80 </span> <span class="Constant">"\n"</span> -<span id="L81" class="LineNr"> 81 </span> <span class="Constant">"For complete details, spend some time with two tables in the IA-32 software\n"</span> -<span id="L82" class="LineNr"> 82 </span> <span class="Constant">"developer's manual that are also included in this repo:\n"</span> -<span id="L83" class="LineNr"> 83 </span> <span class="Constant">" - modrm.pdf: volume 2, table 2-2, \"</span><span class="Constant">32</span>-bit addressing with the ModR/<span class="Special">M</span> byte<span class="Delimiter">.</span>\<span class="Constant">".\n"</span> -<span id="L84" class="LineNr"> 84 </span> <span class="Constant">" - sib.pdf: volume 2, table 2-3, \"</span><span class="Constant">32</span>-bit addressing with the SIB byte<span class="Delimiter">.</span>\<span class="Constant">".\n"</span> -<span id="L85" class="LineNr"> 85 </span> <span class="Delimiter">);</span> -<span id="L86" class="LineNr"> 86 </span> <a href='001help.cc.html#L255'>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">"subop"</span><span class="Delimiter">,</span> -<span id="L87" class="LineNr"> 87 </span> <span class="Constant">"Additional 3-bit operand for determining the instruction when the opcode\n"</span> -<span id="L88" class="LineNr"> 88 </span> <span class="Constant">"is 81, 8f, d3, f7 or ff.\n"</span> -<span id="L89" class="LineNr"> 89 </span> <span class="Constant">"Can't coexist with operand of type 'r32' in a single instruction, because\n"</span> -<span id="L90" class="LineNr"> 90 </span> <span class="Constant">"the two use the same bits.\n"</span> -<span id="L91" class="LineNr"> 91 </span> <span class="Delimiter">);</span> -<span id="L92" class="LineNr"> 92 </span> <a href='001help.cc.html#L255'>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">"r32"</span><span class="Delimiter">,</span> -<span id="L93" class="LineNr"> 93 </span> <span class="Constant">"3-bit operand specifying a register operand used directly, without any further addressing modes.\n"</span> +<span id="L1" class="LineNr"> 1 </span><span class="Comment">//: Metadata for fields of an x86 instruction.</span> +<span id="L2" class="LineNr"> 2 </span><span class="Comment">//:</span> +<span id="L3" class="LineNr"> 3 </span><span class="Comment">//: The x86 instruction set is variable-length, and how a byte is interpreted</span> +<span id="L4" class="LineNr"> 4 </span><span class="Comment">//: affects later instruction boundaries. A lot of the pain in programming</span> +<span id="L5" class="LineNr"> 5 </span><span class="Comment">//: machine code stems from computer and programmer going out of sync on what</span> +<span id="L6" class="LineNr"> 6 </span><span class="Comment">//: a byte means. The miscommunication is usually not immediately caught, and</span> +<span id="L7" class="LineNr"> 7 </span><span class="Comment">//: metastasizes at runtime into kilobytes of misinterpreted instructions.</span> +<span id="L8" class="LineNr"> 8 </span><span class="Comment">//:</span> +<span id="L9" class="LineNr"> 9 </span><span class="Comment">//: To mitigate these issues, we'll start programming in terms of logical</span> +<span id="L10" class="LineNr"> 10 </span><span class="Comment">//: operands rather than physical bytes. Some operands are smaller than a</span> +<span id="L11" class="LineNr"> 11 </span><span class="Comment">//: byte, and others may consist of multiple bytes. This layer will correctly</span> +<span id="L12" class="LineNr"> 12 </span><span class="Comment">//: pack and order the bytes corresponding to the operands in an instruction.</span> +<span id="L13" class="LineNr"> 13 </span> +<span id="L14" class="LineNr"> 14 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Texts")</span> +<span id="L15" class="LineNr"> 15 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='001help.cc.html#L53'>Help</a></span><span class="Delimiter">,</span> <span class="Constant">"instructions"</span><span class="Delimiter">,</span> +<span id="L16" class="LineNr"> 16 </span> <span class="Constant">"Each x86 instruction consists of an instruction or opcode and some number\n"</span> +<span id="L17" class="LineNr"> 17 </span> <span class="Constant">"of operands.\n"</span> +<span id="L18" class="LineNr"> 18 </span> <span class="Constant">"Each operand has a type. An instruction won't have more than one operand of\n"</span> +<span id="L19" class="LineNr"> 19 </span> <span class="Constant">"any type.\n"</span> +<span id="L20" class="LineNr"> 20 </span> <span class="Constant">"Each instruction has some set of allowed operand types. It'll reject others.\n"</span> +<span id="L21" class="LineNr"> 21 </span> <span class="Constant">"The complete list of operand types: mod, subop, r32 (register), rm32\n"</span> +<span id="L22" class="LineNr"> 22 </span> <span class="Constant">"(register or memory), scale, index, base, disp8, disp16, <a href='040---tests.cc.html#L82'>disp32</a>, imm8,\n"</span> +<span id="L23" class="LineNr"> 23 </span> <span class="Constant">"imm32.\n"</span> +<span id="L24" class="LineNr"> 24 </span> <span class="Constant">"Each of these has its own help page. Try reading 'bootstrap help mod' next.\n"</span> +<span id="L25" class="LineNr"> 25 </span><span class="Delimiter">);</span> +<span id="L26" class="LineNr"> 26 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Contents")</span> +<span id="L27" class="LineNr"> 27 </span>cerr << <span class="Constant">" instructions\n"</span><span class="Delimiter">;</span> +<span id="L28" class="LineNr"> 28 </span> +<span id="L29" class="LineNr"> 29 </span><span class="Delimiter">:(before "Running Test Program")</span> +<span id="L30" class="LineNr"> 30 </span>transform<span class="Delimiter">(</span>p<span class="Delimiter">);</span> +<span id="L31" class="LineNr"> 31 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L32" class="LineNr"> 32 </span> +<span id="L33" class="LineNr"> 33 </span><span class="Delimiter">:(code)</span> +<span id="L34" class="LineNr"> 34 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L34'>test_pack_immediate_constants</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L35" class="LineNr"> 35 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> +<span id="L36" class="LineNr"> 36 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L37" class="LineNr"> 37 </span> <span class="Constant">"bb 0x2a/imm32\n"</span> +<span id="L38" class="LineNr"> 38 </span> <span class="Delimiter">);</span> +<span id="L39" class="LineNr"> 39 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L40" class="LineNr"> 40 </span> <span class="Constant">"transform: packing instruction 'bb 0x2a/imm32'\n"</span> +<span id="L41" class="LineNr"> 41 </span> <span class="Constant">"transform: instruction after packing: 'bb 2a 00 00 00'\n"</span> +<span id="L42" class="LineNr"> 42 </span> <span class="Constant">"run: copy imm32 0x0000002a to EBX\n"</span> +<span id="L43" class="LineNr"> 43 </span> <span class="Delimiter">);</span> +<span id="L44" class="LineNr"> 44 </span><span class="Delimiter">}</span> +<span id="L45" class="LineNr"> 45 </span> +<span id="L46" class="LineNr"> 46 </span><span class="Comment">//: complete set of valid operand types</span> +<span id="L47" class="LineNr"> 47 </span> +<span id="L48" class="LineNr"> 48 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L49" class="LineNr"> 49 </span>set<string> <span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">;</span> +<span id="L50" class="LineNr"> 50 </span><span class="Delimiter">:(before "End One-time Setup")</span> +<span id="L51" class="LineNr"> 51 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"subop"</span><span class="Delimiter">);</span> +<span id="L52" class="LineNr"> 52 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"mod"</span><span class="Delimiter">);</span> +<span id="L53" class="LineNr"> 53 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"rm32"</span><span class="Delimiter">);</span> +<span id="L54" class="LineNr"> 54 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"base"</span><span class="Delimiter">);</span> +<span id="L55" class="LineNr"> 55 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"index"</span><span class="Delimiter">);</span> +<span id="L56" class="LineNr"> 56 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"scale"</span><span class="Delimiter">);</span> +<span id="L57" class="LineNr"> 57 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"r32"</span><span class="Delimiter">);</span> +<span id="L58" class="LineNr"> 58 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"disp8"</span><span class="Delimiter">);</span> +<span id="L59" class="LineNr"> 59 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"disp16"</span><span class="Delimiter">);</span> +<span id="L60" class="LineNr"> 60 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"disp32"</span><span class="Delimiter">);</span> +<span id="L61" class="LineNr"> 61 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"imm8"</span><span class="Delimiter">);</span> +<span id="L62" class="LineNr"> 62 </span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>insert<span class="Delimiter">(</span><span class="Constant">"imm32"</span><span class="Delimiter">);</span> +<span id="L63" class="LineNr"> 63 </span> +<span id="L64" class="LineNr"> 64 </span><span class="Delimiter">:(before "End <a href='001help.cc.html#L53'>Help</a> Texts")</span> +<span id="L65" class="LineNr"> 65 </span><a href='032---operands.cc.html#L67'>init_operand_type_help</a><span class="Delimiter">();</span> +<span id="L66" class="LineNr"> 66 </span><span class="Delimiter">:(code)</span> +<span id="L67" class="LineNr"> 67 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L67'>init_operand_type_help</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L68" class="LineNr"> 68 </span> <a href='001help.cc.html#L229'>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">"mod"</span><span class="Delimiter">,</span> +<span id="L69" class="LineNr"> 69 </span> <span class="Constant">"2-bit operand controlling the _addressing mode_ of many instructions,\n"</span> +<span id="L70" class="LineNr"> 70 </span> <span class="Constant">"to determine how to compute the _effective address_ to look up memory at\n"</span> +<span id="L71" class="LineNr"> 71 </span> <span class="Constant">"based on the 'rm32' operand and potentially others.\n"</span> +<span id="L72" class="LineNr"> 72 </span> <span class="Constant">"\n"</span> +<span id="L73" class="LineNr"> 73 </span> <span class="Constant">"If mod = 3, just operate on the <a href='003trace.cc.html#L117'>contents</a> of the register specified by rm32\n"</span> +<span id="L74" class="LineNr"> 74 </span> <span class="Constant">" (direct mode).\n"</span> +<span id="L75" class="LineNr"> 75 </span> <span class="Constant">"If mod = 2, effective address is usually* rm32 + disp32\n"</span> +<span id="L76" class="LineNr"> 76 </span> <span class="Constant">" (indirect mode with displacement).\n"</span> +<span id="L77" class="LineNr"> 77 </span> <span class="Constant">"If mod = 1, effective address is usually* rm32 + disp8\n"</span> +<span id="L78" class="LineNr"> 78 </span> <span class="Constant">" (indirect mode with displacement).\n"</span> +<span id="L79" class="LineNr"> 79 </span> <span class="Constant">"If mod = 0, effective address is usually* rm32 (indirect mode).\n"</span> +<span id="L80" class="LineNr"> 80 </span> <span class="Constant">"(* - The exception is when rm32 is '4'. Register 4 is the stack pointer (<a href='010---vm.cc.html#L14'>ESP</a>).\n"</span> +<span id="L81" class="LineNr"> 81 </span> <span class="Constant">" Using it as an address gets more involved. For more details,\n"</span> +<span id="L82" class="LineNr"> 82 </span> <span class="Constant">" try reading the help pages for 'base', 'index' and 'scale'.)\n"</span> +<span id="L83" class="LineNr"> 83 </span> <span class="Constant">"\n"</span> +<span id="L84" class="LineNr"> 84 </span> <span class="Constant">"For complete details, spend some time with two tables in the IA-32 software\n"</span> +<span id="L85" class="LineNr"> 85 </span> <span class="Constant">"developer's manual that are also included in this repo:\n"</span> +<span id="L86" class="LineNr"> 86 </span> <span class="Constant">" - modrm.pdf: volume 2, table 2-2, \"</span><span class="Constant">32</span>-bit addressing with the ModR/<span class="Special">M</span> byte<span class="Delimiter">.</span>\<span class="Constant">".\n"</span> +<span id="L87" class="LineNr"> 87 </span> <span class="Constant">" - sib.pdf: volume 2, table 2-3, \"</span><span class="Constant">32</span>-bit addressing with the SIB byte<span class="Delimiter">.</span>\<span class="Constant">".\n"</span> +<span id="L88" class="LineNr"> 88 </span> <span class="Delimiter">);</span> +<span id="L89" class="LineNr"> 89 </span> <a href='001help.cc.html#L229'>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">"subop"</span><span class="Delimiter">,</span> +<span id="L90" class="LineNr"> 90 </span> <span class="Constant">"Additional 3-bit operand for determining the instruction when the opcode\n"</span> +<span id="L91" class="LineNr"> 91 </span> <span class="Constant">"is 81, 8f, d3, f7 or ff.\n"</span> +<span id="L92" class="LineNr"> 92 </span> <span class="Constant">"Can't coexist with operand of type 'r32' in a single instruction, because\n"</span> +<span id="L93" class="LineNr"> 93 </span> <span class="Constant">"the two use the same bits.\n"</span> <span id="L94" class="LineNr"> 94 </span> <span class="Delimiter">);</span> -<span id="L95" class="LineNr"> 95 </span> <a href='001help.cc.html#L255'>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">"rm32"</span><span class="Delimiter">,</span> -<span id="L96" class="LineNr"> 96 </span> <span class="Constant">"32-bit value in register or memory. The precise details of its construction\n"</span> -<span id="L97" class="LineNr"> 97 </span> <span class="Constant">"depend on the eponymous 3-bit 'rm32' operand, the 'mod' operand, and also\n"</span> -<span id="L98" class="LineNr"> 98 </span> <span class="Constant">"potentially the 'SIB' operands ('scale', 'index' and 'base') and a displacement\n"</span> -<span id="L99" class="LineNr"> 99 </span> <span class="Constant">"('disp8' or 'disp32').\n"</span> -<span id="L100" class="LineNr">100 </span> <span class="Constant">"\n"</span> -<span id="L101" class="LineNr">101 </span> <span class="Constant">"For complete details, spend some time with two tables in the IA-32 software\n"</span> -<span id="L102" class="LineNr">102 </span> <span class="Constant">"developer's manual that are also included in this repo:\n"</span> -<span id="L103" class="LineNr">103 </span> <span class="Constant">" - modrm.pdf: volume 2, table 2-2, \"</span><span class="Constant">32</span>-bit addressing with the ModR/<span class="Special">M</span> byte<span class="Delimiter">.</span>\<span class="Constant">".\n"</span> -<span id="L104" class="LineNr">104 </span> <span class="Constant">" - sib.pdf: volume 2, table 2-3, \"</span><span class="Constant">32</span>-bit addressing with the SIB byte<span class="Delimiter">.</span>\<span class="Constant">".\n"</span> -<span id="L105" class="LineNr">105 </span> <span class="Delimiter">);</span> -<span id="L106" class="LineNr">106 </span> <a href='001help.cc.html#L255'>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">"base"</span><span class="Delimiter">,</span> -<span id="L107" class="LineNr">107 </span> <span class="Constant">"Additional 3-bit operand (when 'rm32' is 4, unless 'mod' is 3) specifying the\n"</span> -<span id="L108" class="LineNr">108 </span> <span class="Constant">"register containing an address to look up.\n"</span> -<span id="L109" class="LineNr">109 </span> <span class="Constant">"This address may be further modified by 'index' and 'scale' operands.\n"</span> -<span id="L110" class="LineNr">110 </span> <span class="Constant">" effective address = base + index*scale + displacement (disp8 or <a href='040---tests.cc.html#L84'>disp32</a>)\n"</span> -<span id="L111" class="LineNr">111 </span> <span class="Constant">"For complete details, spend some time with the IA-32 software developer's manual,\n"</span> -<span id="L112" class="LineNr">112 </span> <span class="Constant">"volume 2, table 2-3, \"</span><span class="Constant">32</span>-bit addressing with the SIB byte\<span class="Constant">".\n"</span> -<span id="L113" class="LineNr">113 </span> <span class="Constant">"It is included in this repository as 'sib.pdf'.\n"</span> -<span id="L114" class="LineNr">114 </span> <span class="Delimiter">);</span> -<span id="L115" class="LineNr">115 </span> <a href='001help.cc.html#L255'>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">"index"</span><span class="Delimiter">,</span> -<span id="L116" class="LineNr">116 </span> <span class="Constant">"Optional 3-bit operand (when 'rm32' is 4 unless 'mod' is 3) that can be added to\n"</span> -<span id="L117" class="LineNr">117 </span> <span class="Constant">"the 'base' operand to compute the 'effective address' at which to look up memory.\n"</span> -<span id="L118" class="LineNr">118 </span> <span class="Constant">" effective address = base + index*scale + displacement (disp8 or <a href='040---tests.cc.html#L84'>disp32</a>)\n"</span> -<span id="L119" class="LineNr">119 </span> <span class="Constant">"For complete details, spend some time with the IA-32 software developer's manual,\n"</span> -<span id="L120" class="LineNr">120 </span> <span class="Constant">"volume 2, table 2-3, \"</span><span class="Constant">32</span>-bit addressing with the SIB byte\<span class="Constant">".\n"</span> -<span id="L121" class="LineNr">121 </span> <span class="Constant">"It is included in this repository as 'sib.pdf'.\n"</span> -<span id="L122" class="LineNr">122 </span> <span class="Delimiter">);</span> -<span id="L123" class="LineNr">123 </span> <a href='001help.cc.html#L255'>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">"scale"</span><span class="Delimiter">,</span> -<span id="L124" class="LineNr">124 </span> <span class="Constant">"Optional 2-bit operand (when 'rm32' is 4 unless 'mod' is 3) that encodes a\n"</span> -<span id="L125" class="LineNr">125 </span> <span class="Constant">"power of 2 to be multiplied to the 'index' operand before adding the result to\n"</span> -<span id="L126" class="LineNr">126 </span> <span class="Constant">"the 'base' operand to compute the _effective address_ to operate on.\n"</span> -<span id="L127" class="LineNr">127 </span> <span class="Constant">" effective address = base + index * scale + displacement (disp8 or <a href='040---tests.cc.html#L84'>disp32</a>)\n"</span> -<span id="L128" class="LineNr">128 </span> <span class="Constant">"\n"</span> -<span id="L129" class="LineNr">129 </span> <span class="Constant">"When scale is 0, use index unmodified.\n"</span> -<span id="L130" class="LineNr">130 </span> <span class="Constant">"When scale is 1, multiply index by 2.\n"</span> -<span id="L131" class="LineNr">131 </span> <span class="Constant">"When scale is 2, multiply index by 4.\n"</span> -<span id="L132" class="LineNr">132 </span> <span class="Constant">"When scale is 3, multiply index by 8.\n"</span> -<span id="L133" class="LineNr">133 </span> <span class="Constant">"\n"</span> -<span id="L134" class="LineNr">134 </span> <span class="Constant">"For complete details, spend some time with the IA-32 software developer's manual,\n"</span> -<span id="L135" class="LineNr">135 </span> <span class="Constant">"volume 2, table 2-3, \"</span><span class="Constant">32</span>-bit addressing with the SIB byte\<span class="Constant">".\n"</span> -<span id="L136" class="LineNr">136 </span> <span class="Constant">"It is included in this repository as 'sib.pdf'.\n"</span> -<span id="L137" class="LineNr">137 </span> <span class="Delimiter">);</span> -<span id="L138" class="LineNr">138 </span> <a href='001help.cc.html#L255'>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">"disp8"</span><span class="Delimiter">,</span> -<span id="L139" class="LineNr">139 </span> <span class="Constant">"8-bit value to be added in many instructions.\n"</span> +<span id="L95" class="LineNr"> 95 </span> <a href='001help.cc.html#L229'>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">"r32"</span><span class="Delimiter">,</span> +<span id="L96" class="LineNr"> 96 </span> <span class="Constant">"3-bit operand specifying a register operand used directly, without any further addressing modes.\n"</span> +<span id="L97" class="LineNr"> 97 </span> <span class="Delimiter">);</span> +<span id="L98" class="LineNr"> 98 </span> <a href='001help.cc.html#L229'>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">"rm32"</span><span class="Delimiter">,</span> +<span id="L99" class="LineNr"> 99 </span> <span class="Constant">"32-bit value in register or memory. The precise details of its construction\n"</span> +<span id="L100" class="LineNr">100 </span> <span class="Constant">"depend on the eponymous 3-bit 'rm32' operand, the 'mod' operand, and also\n"</span> +<span id="L101" class="LineNr">101 </span> <span class="Constant">"potentially the 'SIB' operands ('scale', 'index' and 'base') and a displacement\n"</span> +<span id="L102" class="LineNr">102 </span> <span class="Constant">"('disp8' or 'disp32').\n"</span> +<span id="L103" class="LineNr">103 </span> <span class="Constant">"\n"</span> +<span id="L104" class="LineNr">104 </span> <span class="Constant">"For complete details, spend some time with two tables in the IA-32 software\n"</span> +<span id="L105" class="LineNr">105 </span> <span class="Constant">"developer's manual that are also included in this repo:\n"</span> +<span id="L106" class="LineNr">106 </span> <span class="Constant">" - modrm.pdf: volume 2, table 2-2, \"</span><span class="Constant">32</span>-bit addressing with the ModR/<span class="Special">M</span> byte<span class="Delimiter">.</span>\<span class="Constant">".\n"</span> +<span id="L107" class="LineNr">107 </span> <span class="Constant">" - sib.pdf: volume 2, table 2-3, \"</span><span class="Constant">32</span>-bit addressing with the SIB byte<span class="Delimiter">.</span>\<span class="Constant">".\n"</span> +<span id="L108" class="LineNr">108 </span> <span class="Delimiter">);</span> +<span id="L109" class="LineNr">109 </span> <a href='001help.cc.html#L229'>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">"base"</span><span class="Delimiter">,</span> +<span id="L110" class="LineNr">110 </span> <span class="Constant">"Additional 3-bit operand (when 'rm32' is 4, unless 'mod' is 3) specifying the\n"</span> +<span id="L111" class="LineNr">111 </span> <span class="Constant">"register containing an address to look up.\n"</span> +<span id="L112" class="LineNr">112 </span> <span class="Constant">"This address may be further modified by 'index' and 'scale' operands.\n"</span> +<span id="L113" class="LineNr">113 </span> <span class="Constant">" effective address = base + index*scale + displacement (disp8 or <a href='040---tests.cc.html#L82'>disp32</a>)\n"</span> +<span id="L114" class="LineNr">114 </span> <span class="Constant">"For complete details, spend some time with the IA-32 software developer's manual,\n"</span> +<span id="L115" class="LineNr">115 </span> <span class="Constant">"volume 2, table 2-3, \"</span><span class="Constant">32</span>-bit addressing with the SIB byte\<span class="Constant">".\n"</span> +<span id="L116" class="LineNr">116 </span> <span class="Constant">"It is included in this repository as 'sib.pdf'.\n"</span> +<span id="L117" class="LineNr">117 </span> <span class="Delimiter">);</span> +<span id="L118" class="LineNr">118 </span> <a href='001help.cc.html#L229'>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">"index"</span><span class="Delimiter">,</span> +<span id="L119" class="LineNr">119 </span> <span class="Constant">"Optional 3-bit operand (when 'rm32' is 4 unless 'mod' is 3) that can be added to\n"</span> +<span id="L120" class="LineNr">120 </span> <span class="Constant">"the 'base' operand to compute the 'effective address' at which to look up memory.\n"</span> +<span id="L121" class="LineNr">121 </span> <span class="Constant">" effective address = base + index*scale + displacement (disp8 or <a href='040---tests.cc.html#L82'>disp32</a>)\n"</span> +<span id="L122" class="LineNr">122 </span> <span class="Constant">"For complete details, spend some time with the IA-32 software developer's manual,\n"</span> +<span id="L123" class="LineNr">123 </span> <span class="Constant">"volume 2, table 2-3, \"</span><span class="Constant">32</span>-bit addressing with the SIB byte\<span class="Constant">".\n"</span> +<span id="L124" class="LineNr">124 </span> <span class="Constant">"It is included in this repository as 'sib.pdf'.\n"</span> +<span id="L125" class="LineNr">125 </span> <span class="Delimiter">);</span> +<span id="L126" class="LineNr">126 </span> <a href='001help.cc.html#L229'>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">"scale"</span><span class="Delimiter">,</span> +<span id="L127" class="LineNr">127 </span> <span class="Constant">"Optional 2-bit operand (when 'rm32' is 4 unless 'mod' is 3) that encodes a\n"</span> +<span id="L128" class="LineNr">128 </span> <span class="Constant">"power of 2 to be multiplied to the 'index' operand before adding the result to\n"</span> +<span id="L129" class="LineNr">129 </span> <span class="Constant">"the 'base' operand to compute the _effective address_ to operate on.\n"</span> +<span id="L130" class="LineNr">130 </span> <span class="Constant">" effective address = base + index * scale + displacement (disp8 or <a href='040---tests.cc.html#L82'>disp32</a>)\n"</span> +<span id="L131" class="LineNr">131 </span> <span class="Constant">"\n"</span> +<span id="L132" class="LineNr">132 </span> <span class="Constant">"When scale is 0, use index unmodified.\n"</span> +<span id="L133" class="LineNr">133 </span> <span class="Constant">"When scale is 1, multiply index by 2.\n"</span> +<span id="L134" class="LineNr">134 </span> <span class="Constant">"When scale is 2, multiply index by 4.\n"</span> +<span id="L135" class="LineNr">135 </span> <span class="Constant">"When scale is 3, multiply index by 8.\n"</span> +<span id="L136" class="LineNr">136 </span> <span class="Constant">"\n"</span> +<span id="L137" class="LineNr">137 </span> <span class="Constant">"For complete details, spend some time with the IA-32 software developer's manual,\n"</span> +<span id="L138" class="LineNr">138 </span> <span class="Constant">"volume 2, table 2-3, \"</span><span class="Constant">32</span>-bit addressing with the SIB byte\<span class="Constant">".\n"</span> +<span id="L139" class="LineNr">139 </span> <span class="Constant">"It is included in this repository as 'sib.pdf'.\n"</span> <span id="L140" class="LineNr">140 </span> <span class="Delimiter">);</span> -<span id="L141" class="LineNr">141 </span> <a href='001help.cc.html#L255'>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">"disp16"</span><span class="Delimiter">,</span> -<span id="L142" class="LineNr">142 </span> <span class="Constant">"16-bit value to be added in many instructions.\n"</span> -<span id="L143" class="LineNr">143 </span> <span class="Constant">"Currently not used in any SubX instructions.\n"</span> -<span id="L144" class="LineNr">144 </span> <span class="Delimiter">);</span> -<span id="L145" class="LineNr">145 </span> <a href='001help.cc.html#L255'>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">"disp32"</span><span class="Delimiter">,</span> -<span id="L146" class="LineNr">146 </span> <span class="Constant">"32-bit value to be added in many instructions.\n"</span> +<span id="L141" class="LineNr">141 </span> <a href='001help.cc.html#L229'>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">"disp8"</span><span class="Delimiter">,</span> +<span id="L142" class="LineNr">142 </span> <span class="Constant">"8-bit value to be added in many instructions.\n"</span> +<span id="L143" class="LineNr">143 </span> <span class="Delimiter">);</span> +<span id="L144" class="LineNr">144 </span> <a href='001help.cc.html#L229'>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">"disp16"</span><span class="Delimiter">,</span> +<span id="L145" class="LineNr">145 </span> <span class="Constant">"16-bit value to be added in many instructions.\n"</span> +<span id="L146" class="LineNr">146 </span> <span class="Constant">"Currently not used in any SubX instructions.\n"</span> <span id="L147" class="LineNr">147 </span> <span class="Delimiter">);</span> -<span id="L148" class="LineNr">148 </span> <a href='001help.cc.html#L255'>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">"imm8"</span><span class="Delimiter">,</span> -<span id="L149" class="LineNr">149 </span> <span class="Constant">"8-bit value for many instructions.\n"</span> +<span id="L148" class="LineNr">148 </span> <a href='001help.cc.html#L229'>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">"disp32"</span><span class="Delimiter">,</span> +<span id="L149" class="LineNr">149 </span> <span class="Constant">"32-bit value to be added in many instructions.\n"</span> <span id="L150" class="LineNr">150 </span> <span class="Delimiter">);</span> -<span id="L151" class="LineNr">151 </span> <a href='001help.cc.html#L255'>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">"imm32"</span><span class="Delimiter">,</span> -<span id="L152" class="LineNr">152 </span> <span class="Constant">"32-bit value for many instructions.\n"</span> +<span id="L151" class="LineNr">151 </span> <a href='001help.cc.html#L229'>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">"imm8"</span><span class="Delimiter">,</span> +<span id="L152" class="LineNr">152 </span> <span class="Constant">"8-bit value for many instructions.\n"</span> <span id="L153" class="LineNr">153 </span> <span class="Delimiter">);</span> -<span id="L154" class="LineNr">154 </span><span class="Delimiter">}</span> -<span id="L155" class="LineNr">155 </span> -<span id="L156" class="LineNr">156 </span><span class="SalientComment">//:: transform packing operands into bytes in the right order</span> -<span id="L157" class="LineNr">157 </span> -<span id="L158" class="LineNr">158 </span><span class="Delimiter">:(after "Begin Transforms")</span> -<span id="L159" class="LineNr">159 </span><span class="Comment">// Begin Level-2 Transforms</span> -<span id="L160" class="LineNr">160 </span><span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pack_operands<span class="Delimiter">);</span> -<span id="L161" class="LineNr">161 </span><span class="Comment">// End Level-2 Transforms</span> -<span id="L162" class="LineNr">162 </span> -<span id="L163" class="LineNr">163 </span><span class="Delimiter">:(code)</span> -<span id="L164" class="LineNr">164 </span><span class="Normal">void</span> pack_operands<span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L165" class="LineNr">165 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L166" class="LineNr">166 </span> segment& code = *find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">);</span> -<span id="L167" class="LineNr">167 </span> <span class="Comment">// Pack Operands(segment code)</span> -<span id="L168" class="LineNr">168 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- pack operands"</span> << end<span class="Delimiter">();</span> -<span id="L169" class="LineNr">169 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L170" class="LineNr">170 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L171" class="LineNr">171 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L429'>all_hex_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L172" class="LineNr">172 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"packing instruction '"</span> << to_string<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">with metadata</span><span class="Comment">*/</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> -<span id="L173" class="LineNr">173 </span> pack_operands<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> -<span id="L174" class="LineNr">174 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"instruction after packing: '"</span> << to_string<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">without metadata</span><span class="Comment">*/</span>inst<span class="Delimiter">.</span>words<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> -<span id="L175" class="LineNr">175 </span> <span class="Delimiter">}</span> -<span id="L176" class="LineNr">176 </span><span class="Delimiter">}</span> -<span id="L177" class="LineNr">177 </span> -<span id="L178" class="LineNr">178 </span><span class="Normal">void</span> pack_operands<span class="Delimiter">(</span>line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L179" class="LineNr">179 </span> <a href='011run.cc.html#L122'>line</a> new_inst<span class="Delimiter">;</span> -<span id="L180" class="LineNr">180 </span> <a href='032---operands.cc.html#L188'>add_opcodes</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> new_inst<span class="Delimiter">);</span> -<span id="L181" class="LineNr">181 </span> <a href='032---operands.cc.html#L198'>add_modrm_byte</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> new_inst<span class="Delimiter">);</span> -<span id="L182" class="LineNr">182 </span> <a href='032---operands.cc.html#L224'>add_sib_byte</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> new_inst<span class="Delimiter">);</span> -<span id="L183" class="LineNr">183 </span> <a href='032---operands.cc.html#L246'>add_disp_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> new_inst<span class="Delimiter">);</span> -<span id="L184" class="LineNr">184 </span> <a href='032---operands.cc.html#L258'>add_imm_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> new_inst<span class="Delimiter">);</span> -<span id="L185" class="LineNr">185 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> -<span id="L186" class="LineNr">186 </span><span class="Delimiter">}</span> -<span id="L187" class="LineNr">187 </span> -<span id="L188" class="LineNr">188 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L188'>add_opcodes</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">,</span> line& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L189" class="LineNr">189 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> -<span id="L190" class="LineNr">190 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span> || in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f2"</span> || in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f3"</span><span class="Delimiter">)</span> -<span id="L191" class="LineNr">191 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">));</span> -<span id="L192" class="LineNr">192 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f3"</span> && in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span><span class="Delimiter">)</span> -<span id="L193" class="LineNr">193 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">));</span> -<span id="L194" class="LineNr">194 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f2"</span> && in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span><span class="Delimiter">)</span> -<span id="L195" class="LineNr">195 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">));</span> -<span id="L196" class="LineNr">196 </span><span class="Delimiter">}</span> -<span id="L197" class="LineNr">197 </span> -<span id="L198" class="LineNr">198 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L198'>add_modrm_byte</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">,</span> line& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L199" class="LineNr">199 </span> <span class="Normal">uint8_t</span> mod=<span class="Constant">0</span><span class="Delimiter">,</span> reg_subop=<span class="Constant">0</span><span class="Delimiter">,</span> rm32=<span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L200" class="LineNr">200 </span> <span class="Normal">bool</span> emit = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L201" class="LineNr">201 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L202" class="LineNr">202 </span> <span class="Normal">const</span> word& curr = in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L203" class="LineNr">203 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L204" class="LineNr">204 </span> mod = <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> -<span id="L205" class="LineNr">205 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L206" class="LineNr">206 </span> <span class="Delimiter">}</span> -<span id="L207" class="LineNr">207 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"rm32"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L208" class="LineNr">208 </span> rm32 = <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> -<span id="L209" class="LineNr">209 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L210" class="LineNr">210 </span> <span class="Delimiter">}</span> -<span id="L211" class="LineNr">211 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"r32"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L212" class="LineNr">212 </span> reg_subop = <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> -<span id="L213" class="LineNr">213 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L214" class="LineNr">214 </span> <span class="Delimiter">}</span> -<span id="L215" class="LineNr">215 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"subop"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L216" class="LineNr">216 </span> reg_subop = <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> -<span id="L217" class="LineNr">217 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L218" class="LineNr">218 </span> <span class="Delimiter">}</span> -<span id="L219" class="LineNr">219 </span> <span class="Delimiter">}</span> -<span id="L220" class="LineNr">220 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>emit<span class="Delimiter">)</span> -<span id="L221" class="LineNr">221 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='032---operands.cc.html#L288'>hex_byte_text</a><span class="Delimiter">((</span>mod << <span class="Constant">6</span><span class="Delimiter">)</span> | <span class="Delimiter">(</span>reg_subop << <span class="Constant">3</span><span class="Delimiter">)</span> | rm32<span class="Delimiter">));</span> -<span id="L222" class="LineNr">222 </span><span class="Delimiter">}</span> -<span id="L223" class="LineNr">223 </span> -<span id="L224" class="LineNr">224 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L224'>add_sib_byte</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">,</span> line& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L225" class="LineNr">225 </span> <span class="Normal">uint8_t</span> scale=<span class="Constant">0</span><span class="Delimiter">,</span> index=<span class="Constant">0</span><span class="Delimiter">,</span> base=<span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L226" class="LineNr">226 </span> <span class="Normal">bool</span> emit = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L227" class="LineNr">227 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L228" class="LineNr">228 </span> <span class="Normal">const</span> word& curr = in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L229" class="LineNr">229 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"scale"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L230" class="LineNr">230 </span> scale = <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> -<span id="L231" class="LineNr">231 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L232" class="LineNr">232 </span> <span class="Delimiter">}</span> -<span id="L233" class="LineNr">233 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"index"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L234" class="LineNr">234 </span> index = <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> -<span id="L235" class="LineNr">235 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L236" class="LineNr">236 </span> <span class="Delimiter">}</span> -<span id="L237" class="LineNr">237 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"base"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L238" class="LineNr">238 </span> base = <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> -<span id="L239" class="LineNr">239 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L240" class="LineNr">240 </span> <span class="Delimiter">}</span> -<span id="L241" class="LineNr">241 </span> <span class="Delimiter">}</span> -<span id="L242" class="LineNr">242 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>emit<span class="Delimiter">)</span> -<span id="L243" class="LineNr">243 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='032---operands.cc.html#L288'>hex_byte_text</a><span class="Delimiter">((</span>scale << <span class="Constant">6</span><span class="Delimiter">)</span> | <span class="Delimiter">(</span>index << <span class="Constant">3</span><span class="Delimiter">)</span> | base<span class="Delimiter">));</span> -<span id="L244" class="LineNr">244 </span><span class="Delimiter">}</span> -<span id="L245" class="LineNr">245 </span> -<span id="L246" class="LineNr">246 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L246'>add_disp_bytes</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">,</span> line& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L247" class="LineNr">247 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L248" class="LineNr">248 </span> <span class="Normal">const</span> word& curr = in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L249" class="LineNr">249 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"disp8"</span><span class="Delimiter">))</span> -<span id="L250" class="LineNr">250 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L251" class="LineNr">251 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"disp16"</span><span class="Delimiter">))</span> -<span id="L252" class="LineNr">252 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> -<span id="L253" class="LineNr">253 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"disp32"</span><span class="Delimiter">))</span> -<span id="L254" class="LineNr">254 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">4</span><span class="Delimiter">);</span> -<span id="L255" class="LineNr">255 </span> <span class="Delimiter">}</span> -<span id="L256" class="LineNr">256 </span><span class="Delimiter">}</span> -<span id="L257" class="LineNr">257 </span> -<span id="L258" class="LineNr">258 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L258'>add_imm_bytes</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">,</span> line& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L259" class="LineNr">259 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L260" class="LineNr">260 </span> <span class="Normal">const</span> word& curr = in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L261" class="LineNr">261 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"imm8"</span><span class="Delimiter">))</span> -<span id="L262" class="LineNr">262 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L263" class="LineNr">263 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"imm32"</span><span class="Delimiter">))</span> -<span id="L264" class="LineNr">264 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">4</span><span class="Delimiter">);</span> -<span id="L265" class="LineNr">265 </span> <span class="Delimiter">}</span> -<span id="L266" class="LineNr">266 </span><span class="Delimiter">}</span> -<span id="L267" class="LineNr">267 </span> -<span id="L268" class="LineNr">268 </span><span class="Normal">void</span> emit_hex_bytes<span class="Delimiter">(</span>line& out<span class="Delimiter">,</span> <span class="Normal">const</span> word& w<span class="Delimiter">,</span> <span class="Normal">int</span> num<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L269" class="LineNr">269 </span> assert<span class="Delimiter">(</span>num <= <span class="Constant">4</span><span class="Delimiter">);</span> -<span id="L270" class="LineNr">270 </span> <span class="Normal">bool</span> is_number = <a href='032---operands.cc.html#L489'>looks_like_hex_int</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">);</span> -<span id="L271" class="LineNr">271 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>num == <span class="Constant">1</span> || !is_number<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L272" class="LineNr">272 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>w<span class="Delimiter">);</span> <span class="Comment">// preserve existing metadata</span> -<span id="L273" class="LineNr">273 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_number<span class="Delimiter">)</span> -<span id="L274" class="LineNr">274 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>data = <a href='032---operands.cc.html#L295'>hex_byte_to_string</a><span class="Delimiter">(</span><a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">));</span> -<span id="L275" class="LineNr">275 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L276" class="LineNr">276 </span> <span class="Delimiter">}</span> -<span id="L277" class="LineNr">277 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span><a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">)),</span> num<span class="Delimiter">);</span> -<span id="L278" class="LineNr">278 </span><span class="Delimiter">}</span> -<span id="L279" class="LineNr">279 </span> -<span id="L280" class="LineNr">280 </span><span class="Normal">void</span> emit_hex_bytes<span class="Delimiter">(</span>line& out<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> val<span class="Delimiter">,</span> <span class="Normal">int</span> num<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L281" class="LineNr">281 </span> assert<span class="Delimiter">(</span>num <= <span class="Constant">4</span><span class="Delimiter">);</span> -<span id="L282" class="LineNr">282 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < num<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L283" class="LineNr">283 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='032---operands.cc.html#L288'>hex_byte_text</a><span class="Delimiter">(</span>val & <span class="Constant">0xff</span><span class="Delimiter">));</span> -<span id="L284" class="LineNr">284 </span> val = val >> <span class="Constant">8</span><span class="Delimiter">;</span> -<span id="L285" class="LineNr">285 </span> <span class="Delimiter">}</span> -<span id="L286" class="LineNr">286 </span><span class="Delimiter">}</span> -<span id="L287" class="LineNr">287 </span> -<span id="L288" class="LineNr">288 </span><a href='011run.cc.html#L128'>word</a> <a href='032---operands.cc.html#L288'>hex_byte_text</a><span class="Delimiter">(</span><span class="Normal">uint8_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L289" class="LineNr">289 </span> <a href='011run.cc.html#L128'>word</a> result<span class="Delimiter">;</span> -<span id="L290" class="LineNr">290 </span> result<span class="Delimiter">.</span>data = <a href='032---operands.cc.html#L295'>hex_byte_to_string</a><span class="Delimiter">(</span>val<span class="Delimiter">);</span> -<span id="L291" class="LineNr">291 </span> result<span class="Delimiter">.</span>original = result<span class="Delimiter">.</span>data+<span class="Constant">"/auto"</span><span class="Delimiter">;</span> -<span id="L292" class="LineNr">292 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L293" class="LineNr">293 </span><span class="Delimiter">}</span> -<span id="L294" class="LineNr">294 </span> -<span id="L295" class="LineNr">295 </span>string <a href='032---operands.cc.html#L295'>hex_byte_to_string</a><span class="Delimiter">(</span><span class="Normal">uint8_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L296" class="LineNr">296 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L297" class="LineNr">297 </span> <span class="Comment">// uint8_t prints without padding, but int8_t will expand to 32 bits again</span> -<span id="L298" class="LineNr">298 </span> out << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>val<span class="Delimiter">);</span> -<span id="L299" class="LineNr">299 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L300" class="LineNr">300 </span><span class="Delimiter">}</span> -<span id="L301" class="LineNr">301 </span> -<span id="L302" class="LineNr">302 </span>string to_string<span class="Delimiter">(</span><span class="Normal">const</span> vector<word>& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L303" class="LineNr">303 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L304" class="LineNr">304 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L305" class="LineNr">305 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L306" class="LineNr">306 </span> out << in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">;</span> -<span id="L307" class="LineNr">307 </span> <span class="Delimiter">}</span> -<span id="L308" class="LineNr">308 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L309" class="LineNr">309 </span><span class="Delimiter">}</span> -<span id="L310" class="LineNr">310 </span> -<span id="L311" class="LineNr">311 </span><span class="Delimiter">:(before "End Unit Tests")</span> -<span id="L312" class="LineNr">312 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L312'>test_preserve_metadata_when_emitting_single_byte</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L313" class="LineNr">313 </span> <a href='011run.cc.html#L128'>word</a> in<span class="Delimiter">;</span> -<span id="L314" class="LineNr">314 </span> in<span class="Delimiter">.</span>data = <span class="Constant">"f0"</span><span class="Delimiter">;</span> -<span id="L315" class="LineNr">315 </span> in<span class="Delimiter">.</span>original = <span class="Constant">"f0/foo"</span><span class="Delimiter">;</span> -<span id="L316" class="LineNr">316 </span> <a href='011run.cc.html#L122'>line</a> out<span class="Delimiter">;</span> -<span id="L317" class="LineNr">317 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> in<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L318" class="LineNr">318 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span>out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data<span class="Delimiter">,</span> <span class="Constant">"f0"</span><span class="Delimiter">);</span> -<span id="L319" class="LineNr">319 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span>out<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original<span class="Delimiter">,</span> <span class="Constant">"f0/foo"</span><span class="Delimiter">);</span> -<span id="L320" class="LineNr">320 </span><span class="Delimiter">}</span> -<span id="L321" class="LineNr">321 </span> -<span id="L322" class="LineNr">322 </span><span class="Delimiter">:(code)</span> -<span id="L323" class="LineNr">323 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L323'>test_pack_disp8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L324" class="LineNr">324 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> -<span id="L325" class="LineNr">325 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L326" class="LineNr">326 </span> <span class="Constant">"74 2/disp8\n"</span> <span class="Comment">// jump 2 bytes away if ZF is set</span> -<span id="L327" class="LineNr">327 </span> <span class="Delimiter">);</span> -<span id="L328" class="LineNr">328 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L329" class="LineNr">329 </span> <span class="Constant">"transform: packing instruction '74 2/disp8'\n"</span> -<span id="L330" class="LineNr">330 </span> <span class="Constant">"transform: instruction after packing: '74 02'\n"</span> -<span id="L331" class="LineNr">331 </span> <span class="Delimiter">);</span> -<span id="L332" class="LineNr">332 </span><span class="Delimiter">}</span> -<span id="L333" class="LineNr">333 </span> -<span id="L334" class="LineNr">334 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L334'>test_pack_disp8_negative</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L335" class="LineNr">335 </span> transform<span class="Delimiter">(</span> -<span id="L336" class="LineNr">336 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L337" class="LineNr">337 </span> <span class="Comment">// running this will cause an infinite loop</span> -<span id="L338" class="LineNr">338 </span> <span class="Constant">"74 -1/disp8\n"</span> <span class="Comment">// jump 1 byte before if ZF is set</span> -<span id="L339" class="LineNr">339 </span> <span class="Delimiter">);</span> -<span id="L340" class="LineNr">340 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L341" class="LineNr">341 </span> <span class="Constant">"transform: packing instruction '74 -1/disp8'\n"</span> -<span id="L342" class="LineNr">342 </span> <span class="Constant">"transform: instruction after packing: '74 ff'\n"</span> -<span id="L343" class="LineNr">343 </span> <span class="Delimiter">);</span> -<span id="L344" class="LineNr">344 </span><span class="Delimiter">}</span> -<span id="L345" class="LineNr">345 </span> -<span id="L346" class="LineNr">346 </span><span class="Comment">//: helper for scenario</span> -<span id="L347" class="LineNr">347 </span><span class="Normal">void</span> transform<span class="Delimiter">(</span><span class="Normal">const</span> string& text_bytes<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L348" class="LineNr">348 </span> program p<span class="Delimiter">;</span> -<span id="L349" class="LineNr">349 </span> istringstream in<span class="Delimiter">(</span>text_bytes<span class="Delimiter">);</span> -<span id="L350" class="LineNr">350 </span> parse<span class="Delimiter">(</span>in<span class="Delimiter">,</span> p<span class="Delimiter">);</span> -<span id="L351" class="LineNr">351 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L352" class="LineNr">352 </span> transform<span class="Delimiter">(</span>p<span class="Delimiter">);</span> -<span id="L353" class="LineNr">353 </span><span class="Delimiter">}</span> -<span id="L354" class="LineNr">354 </span> -<span id="L355" class="LineNr">355 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L355'>test_pack_modrm_imm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L356" class="LineNr">356 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> -<span id="L357" class="LineNr">357 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L358" class="LineNr">358 </span> <span class="Comment">// instruction effective address operand displacement immediate\n"</span> -<span id="L359" class="LineNr">359 </span> <span class="Comment">// op subop mod rm32 base index scale r32\n"</span> -<span id="L360" class="LineNr">360 </span> <span class="Comment">// 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes\n"</span> -<span id="L361" class="LineNr">361 </span> <span class="Constant">" 81 0/add/subop 3/mod/direct 3/ebx/rm32 1/imm32 \n"</span> <span class="Comment">// add 1 to EBX</span> -<span id="L362" class="LineNr">362 </span> <span class="Delimiter">);</span> -<span id="L363" class="LineNr">363 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L364" class="LineNr">364 </span> <span class="Constant">"transform: packing instruction '81 0/add/subop 3/mod/direct 3/ebx/rm32 1/imm32'\n"</span> -<span id="L365" class="LineNr">365 </span> <span class="Constant">"transform: instruction after packing: '81 c3 01 00 00 00'\n"</span> -<span id="L366" class="LineNr">366 </span> <span class="Delimiter">);</span> -<span id="L367" class="LineNr">367 </span><span class="Delimiter">}</span> -<span id="L368" class="LineNr">368 </span> -<span id="L369" class="LineNr">369 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L369'>test_pack_imm32_large</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L370" class="LineNr">370 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> -<span id="L371" class="LineNr">371 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L372" class="LineNr">372 </span> <span class="Constant">"b9 0x080490a7/imm32\n"</span> -<span id="L373" class="LineNr">373 </span> <span class="Delimiter">);</span> -<span id="L374" class="LineNr">374 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L375" class="LineNr">375 </span> <span class="Constant">"transform: packing instruction 'b9 0x080490a7/imm32'\n"</span> -<span id="L376" class="LineNr">376 </span> <span class="Constant">"transform: instruction after packing: 'b9 a7 90 04 08'\n"</span> -<span id="L377" class="LineNr">377 </span> <span class="Delimiter">);</span> -<span id="L378" class="LineNr">378 </span><span class="Delimiter">}</span> -<span id="L379" class="LineNr">379 </span> -<span id="L380" class="LineNr">380 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L380'>test_pack_immediate_constants_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L381" class="LineNr">381 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> -<span id="L382" class="LineNr">382 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L383" class="LineNr">383 </span> <span class="Constant">"b9 0x2a/imm32\n"</span> -<span id="L384" class="LineNr">384 </span> <span class="Delimiter">);</span> -<span id="L385" class="LineNr">385 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L386" class="LineNr">386 </span> <span class="Constant">"transform: packing instruction 'b9 0x2a/imm32'\n"</span> -<span id="L387" class="LineNr">387 </span> <span class="Constant">"transform: instruction after packing: 'b9 2a 00 00 00'\n"</span> -<span id="L388" class="LineNr">388 </span> <span class="Constant">"run: copy imm32 0x0000002a to ECX\n"</span> -<span id="L389" class="LineNr">389 </span> <span class="Delimiter">);</span> -<span id="L390" class="LineNr">390 </span><span class="Delimiter">}</span> -<span id="L391" class="LineNr">391 </span> -<span id="L392" class="LineNr">392 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L392'>test_pack_silently_ignores_non_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L393" class="LineNr">393 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L394" class="LineNr">394 </span> transform<span class="Delimiter">(</span> -<span id="L395" class="LineNr">395 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L396" class="LineNr">396 </span> <span class="Constant">"b9 foo/imm32\n"</span> -<span id="L397" class="LineNr">397 </span> <span class="Delimiter">);</span> -<span id="L398" class="LineNr">398 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L399" class="LineNr">399 </span> <span class="Constant">"transform: packing instruction 'b9 foo/imm32'\n"</span> -<span id="L400" class="LineNr">400 </span> <span class="Comment">// no change (we're just not printing metadata to the trace)</span> -<span id="L401" class="LineNr">401 </span> <span class="Constant">"transform: instruction after packing: 'b9 foo'\n"</span> -<span id="L402" class="LineNr">402 </span> <span class="Delimiter">);</span> -<span id="L403" class="LineNr">403 </span><span class="Delimiter">}</span> -<span id="L404" class="LineNr">404 </span> -<span id="L405" class="LineNr">405 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L405'>test_pack_flags_bad_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L406" class="LineNr">406 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L407" class="LineNr">407 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> -<span id="L408" class="LineNr">408 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L409" class="LineNr">409 </span> <span class="Constant">"b9 0xfoo/imm32\n"</span> -<span id="L410" class="LineNr">410 </span> <span class="Delimiter">);</span> -<span id="L411" class="LineNr">411 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L412" class="LineNr">412 </span> <span class="Constant">"error: not a number: 0xfoo\n"</span> -<span id="L413" class="LineNr">413 </span> <span class="Delimiter">);</span> -<span id="L414" class="LineNr">414 </span><span class="Delimiter">}</span> -<span id="L415" class="LineNr">415 </span> -<span id="L416" class="LineNr">416 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L416'>test_pack_flags_uppercase_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L417" class="LineNr">417 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L418" class="LineNr">418 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> -<span id="L419" class="LineNr">419 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L420" class="LineNr">420 </span> <span class="Constant">"b9 0xAb/imm32\n"</span> -<span id="L421" class="LineNr">421 </span> <span class="Delimiter">);</span> -<span id="L422" class="LineNr">422 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L423" class="LineNr">423 </span> <span class="Constant">"error: uppercase hex not allowed: 0xAb\n"</span> -<span id="L424" class="LineNr">424 </span> <span class="Delimiter">);</span> -<span id="L425" class="LineNr">425 </span><span class="Delimiter">}</span> -<span id="L426" class="LineNr">426 </span> -<span id="L427" class="LineNr">427 </span><span class="SalientComment">//:: helpers</span> -<span id="L428" class="LineNr">428 </span> -<span id="L429" class="LineNr">429 </span><span class="Normal">bool</span> <a href='032---operands.cc.html#L429'>all_hex_bytes</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L430" class="LineNr">430 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L431" class="LineNr">431 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_hex_byte<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> -<span id="L432" class="LineNr">432 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L433" class="LineNr">433 </span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L434" class="LineNr">434 </span><span class="Delimiter">}</span> -<span id="L435" class="LineNr">435 </span> -<span id="L436" class="LineNr">436 </span><span class="Normal">bool</span> <a href='032---operands.cc.html#L436'>is_hex_byte</a><span class="Delimiter">(</span><span class="Normal">const</span> word& curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L437" class="LineNr">437 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L446'>contains_any_operand_metadata</a><span class="Delimiter">(</span>curr<span class="Delimiter">))</span> -<span id="L438" class="LineNr">438 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L439" class="LineNr">439 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> -<span id="L440" class="LineNr">440 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L441" class="LineNr">441 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">.</span>find_first_not_of<span class="Delimiter">(</span><span class="Constant">"0123456789abcdef"</span><span class="Delimiter">)</span> != string::npos<span class="Delimiter">)</span> -<span id="L442" class="LineNr">442 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L443" class="LineNr">443 </span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L444" class="LineNr">444 </span><span class="Delimiter">}</span> -<span id="L445" class="LineNr">445 </span> -<span id="L446" class="LineNr">446 </span><span class="Normal">bool</span> <a href='032---operands.cc.html#L446'>contains_any_operand_metadata</a><span class="Delimiter">(</span><span class="Normal">const</span> word& <a href='011run.cc.html#L128'>word</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L447" class="LineNr">447 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span><a href='011run.cc.html#L128'>word</a><span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L448" class="LineNr">448 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>find<span class="Delimiter">(</span><a href='011run.cc.html#L128'>word</a><span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> != <span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>end<span class="Delimiter">())</span> -<span id="L449" class="LineNr">449 </span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L450" class="LineNr">450 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L451" class="LineNr">451 </span><span class="Delimiter">}</span> -<span id="L452" class="LineNr">452 </span> -<span id="L453" class="LineNr">453 </span><span class="Normal">bool</span> has_operand_metadata<span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">,</span> <span class="Normal">const</span> string& m<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L454" class="LineNr">454 </span> <span class="Normal">bool</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L455" class="LineNr">455 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L456" class="LineNr">456 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_operand_metadata<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> m<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L457" class="LineNr">457 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L458" class="LineNr">458 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' has conflicting "</span> << m << <span class="Constant">" operands\n"</span> << end<span class="Delimiter">();</span> -<span id="L459" class="LineNr">459 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L460" class="LineNr">460 </span> <span class="Delimiter">}</span> -<span id="L461" class="LineNr">461 </span> result = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L462" class="LineNr">462 </span> <span class="Delimiter">}</span> -<span id="L463" class="LineNr">463 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L464" class="LineNr">464 </span><span class="Delimiter">}</span> -<span id="L465" class="LineNr">465 </span> -<span id="L466" class="LineNr">466 </span><span class="Normal">bool</span> has_operand_metadata<span class="Delimiter">(</span><span class="Normal">const</span> word& w<span class="Delimiter">,</span> <span class="Normal">const</span> string& m<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L467" class="LineNr">467 </span> <span class="Normal">bool</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L468" class="LineNr">468 </span> <span class="Normal">bool</span> metadata_found = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L469" class="LineNr">469 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L470" class="LineNr">470 </span> <span class="Normal">const</span> string& curr = w<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L471" class="LineNr">471 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>find<span class="Delimiter">(</span>curr<span class="Delimiter">)</span> == <span class="Special"><a href='032---operands.cc.html#L46'>Instruction_operands</a></span><span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// ignore unrecognized metadata</span> -<span id="L472" class="LineNr">472 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>metadata_found<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L473" class="LineNr">473 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << w<span class="Delimiter">.</span>original << <span class="Constant">"' has conflicting operand types; it should have only one\n"</span> << end<span class="Delimiter">();</span> -<span id="L474" class="LineNr">474 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L475" class="LineNr">475 </span> <span class="Delimiter">}</span> -<span id="L476" class="LineNr">476 </span> metadata_found = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L477" class="LineNr">477 </span> result = <span class="Delimiter">(</span>curr == m<span class="Delimiter">);</span> -<span id="L478" class="LineNr">478 </span> <span class="Delimiter">}</span> -<span id="L479" class="LineNr">479 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L480" class="LineNr">480 </span><span class="Delimiter">}</span> -<span id="L481" class="LineNr">481 </span> -<span id="L482" class="LineNr">482 </span><a href='011run.cc.html#L128'>word</a> metadata<span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">,</span> <span class="Normal">const</span> string& m<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L483" class="LineNr">483 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L484" class="LineNr">484 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> m<span class="Delimiter">))</span> -<span id="L485" class="LineNr">485 </span> <span class="Identifier">return</span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L486" class="LineNr">486 </span> assert<span class="Delimiter">(</span><span class="Constant">false</span><span class="Delimiter">);</span> -<span id="L487" class="LineNr">487 </span><span class="Delimiter">}</span> -<span id="L488" class="LineNr">488 </span> -<span id="L489" class="LineNr">489 </span><span class="Normal">bool</span> <a href='032---operands.cc.html#L489'>looks_like_hex_int</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L490" class="LineNr">490 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L491" class="LineNr">491 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">'-'</span> || s<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">'+'</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L492" class="LineNr">492 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>isdigit<span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Comment">// includes '0x' prefix</span> -<span id="L493" class="LineNr">493 </span> <span class="Comment">// End looks_like_hex_int(s) Detectors</span> -<span id="L494" class="LineNr">494 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L495" class="LineNr">495 </span><span class="Delimiter">}</span> -<span id="L496" class="LineNr">496 </span> -<span id="L497" class="LineNr">497 </span>string to_string<span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L498" class="LineNr">498 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L499" class="LineNr">499 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L500" class="LineNr">500 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L501" class="LineNr">501 </span> out << inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original<span class="Delimiter">;</span> -<span id="L502" class="LineNr">502 </span> <span class="Delimiter">}</span> -<span id="L503" class="LineNr">503 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L504" class="LineNr">504 </span><span class="Delimiter">}</span> -<span id="L505" class="LineNr">505 </span> -<span id="L506" class="LineNr">506 </span><span class="Normal">int32_t</span> <a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L507" class="LineNr">507 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L508" class="LineNr">508 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='011run.cc.html#L463'>contains_uppercase</a><span class="Delimiter">(</span>s<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L509" class="LineNr">509 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"uppercase hex not allowed: "</span> << s << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> -<span id="L510" class="LineNr">510 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L511" class="LineNr">511 </span> <span class="Delimiter">}</span> -<span id="L512" class="LineNr">512 </span> istringstream in<span class="Delimiter">(</span>s<span class="Delimiter">);</span> -<span id="L513" class="LineNr">513 </span> in >> std::hex<span class="Delimiter">;</span> -<span id="L514" class="LineNr">514 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">'-'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L515" class="LineNr">515 </span> <span class="Normal">int32_t</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L516" class="LineNr">516 </span> in >> result<span class="Delimiter">;</span> -<span id="L517" class="LineNr">517 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!in || !in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L518" class="LineNr">518 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"not a number: "</span> << s << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> -<span id="L519" class="LineNr">519 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L520" class="LineNr">520 </span> <span class="Delimiter">}</span> -<span id="L521" class="LineNr">521 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L522" class="LineNr">522 </span> <span class="Delimiter">}</span> -<span id="L523" class="LineNr">523 </span> <span class="Normal">uint32_t</span> uresult = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L524" class="LineNr">524 </span> in >> uresult<span class="Delimiter">;</span> -<span id="L525" class="LineNr">525 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!in || !in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L526" class="LineNr">526 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"not a number: "</span> << s << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> -<span id="L527" class="LineNr">527 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L528" class="LineNr">528 </span> <span class="Delimiter">}</span> -<span id="L529" class="LineNr">529 </span> <span class="Identifier">return</span> <span class="Normal">static_cast</span><<span class="Normal">int32_t</span>><span class="Delimiter">(</span>uresult<span class="Delimiter">);</span> -<span id="L530" class="LineNr">530 </span><span class="Delimiter">}</span> -<span id="L531" class="LineNr">531 </span><span class="Delimiter">:(before "End Unit Tests")</span> -<span id="L532" class="LineNr">532 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L532'>test_parse_int</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L533" class="LineNr">533 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"0"</span><span class="Delimiter">));</span> -<span id="L534" class="LineNr">534 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"0x0"</span><span class="Delimiter">));</span> -<span id="L535" class="LineNr">535 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"0x0"</span><span class="Delimiter">));</span> -<span id="L536" class="LineNr">536 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">16</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"10"</span><span class="Delimiter">));</span> <span class="Comment">// hex always</span> -<span id="L537" class="LineNr">537 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span>-<span class="Constant">1</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"-1"</span><span class="Delimiter">));</span> -<span id="L538" class="LineNr">538 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span>-<span class="Constant">1</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"0xffffffff"</span><span class="Delimiter">));</span> -<span id="L539" class="LineNr">539 </span><span class="Delimiter">}</span> +<span id="L154" class="LineNr">154 </span> <a href='001help.cc.html#L229'>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">"imm32"</span><span class="Delimiter">,</span> +<span id="L155" class="LineNr">155 </span> <span class="Constant">"32-bit value for many instructions.\n"</span> +<span id="L156" class="LineNr">156 </span> <span class="Delimiter">);</span> +<span id="L157" class="LineNr">157 </span><span class="Delimiter">}</span> +<span id="L158" class="LineNr">158 </span> +<span id="L159" class="LineNr">159 </span><span class="SalientComment">//:: transform packing operands into bytes in the right order</span> +<span id="L160" class="LineNr">160 </span> +<span id="L161" class="LineNr">161 </span><span class="Delimiter">:(after "Begin Transforms")</span> +<span id="L162" class="LineNr">162 </span><span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pack_operands<span class="Delimiter">);</span> +<span id="L163" class="LineNr">163 </span> +<span id="L164" class="LineNr">164 </span><span class="Delimiter">:(code)</span> +<span id="L165" class="LineNr">165 </span><span class="Normal">void</span> pack_operands<span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L166" class="LineNr">166 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L167" class="LineNr">167 </span> segment& code = *find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">);</span> +<span id="L168" class="LineNr">168 </span> <span class="Comment">// Pack Operands(segment code)</span> +<span id="L169" class="LineNr">169 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- pack operands"</span> << end<span class="Delimiter">();</span> +<span id="L170" class="LineNr">170 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L171" class="LineNr">171 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L172" class="LineNr">172 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L430'>all_hex_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L173" class="LineNr">173 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"packing instruction '"</span> << to_string<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">with metadata</span><span class="Comment">*/</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> +<span id="L174" class="LineNr">174 </span> pack_operands<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> +<span id="L175" class="LineNr">175 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"instruction after packing: '"</span> << to_string<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">without metadata</span><span class="Comment">*/</span>inst<span class="Delimiter">.</span>words<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> +<span id="L176" class="LineNr">176 </span> <span class="Delimiter">}</span> +<span id="L177" class="LineNr">177 </span><span class="Delimiter">}</span> +<span id="L178" class="LineNr">178 </span> +<span id="L179" class="LineNr">179 </span><span class="Normal">void</span> pack_operands<span class="Delimiter">(</span>line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L180" class="LineNr">180 </span> <a href='011run.cc.html#L121'>line</a> new_inst<span class="Delimiter">;</span> +<span id="L181" class="LineNr">181 </span> <a href='032---operands.cc.html#L189'>add_opcodes</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> new_inst<span class="Delimiter">);</span> +<span id="L182" class="LineNr">182 </span> <a href='032---operands.cc.html#L199'>add_modrm_byte</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> new_inst<span class="Delimiter">);</span> +<span id="L183" class="LineNr">183 </span> <a href='032---operands.cc.html#L225'>add_sib_byte</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> new_inst<span class="Delimiter">);</span> +<span id="L184" class="LineNr">184 </span> <a href='032---operands.cc.html#L247'>add_disp_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> new_inst<span class="Delimiter">);</span> +<span id="L185" class="LineNr">185 </span> <a href='032---operands.cc.html#L259'>add_imm_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> new_inst<span class="Delimiter">);</span> +<span id="L186" class="LineNr">186 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> +<span id="L187" class="LineNr">187 </span><span class="Delimiter">}</span> +<span id="L188" class="LineNr">188 </span> +<span id="L189" class="LineNr">189 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L189'>add_opcodes</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">,</span> line& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L190" class="LineNr">190 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> +<span id="L191" class="LineNr">191 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span> || in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f2"</span> || in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f3"</span><span class="Delimiter">)</span> +<span id="L192" class="LineNr">192 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">));</span> +<span id="L193" class="LineNr">193 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f3"</span> && in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span><span class="Delimiter">)</span> +<span id="L194" class="LineNr">194 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">));</span> +<span id="L195" class="LineNr">195 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f2"</span> && in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span><span class="Delimiter">)</span> +<span id="L196" class="LineNr">196 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">));</span> +<span id="L197" class="LineNr">197 </span><span class="Delimiter">}</span> +<span id="L198" class="LineNr">198 </span> +<span id="L199" class="LineNr">199 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L199'>add_modrm_byte</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">,</span> line& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L200" class="LineNr">200 </span> <span class="Normal">uint8_t</span> mod=<span class="Constant">0</span><span class="Delimiter">,</span> reg_subop=<span class="Constant">0</span><span class="Delimiter">,</span> rm32=<span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L201" class="LineNr">201 </span> <span class="Normal">bool</span> emit = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L202" class="LineNr">202 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L203" class="LineNr">203 </span> <span class="Normal">const</span> word& curr = in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L204" class="LineNr">204 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L205" class="LineNr">205 </span> mod = <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L206" class="LineNr">206 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L207" class="LineNr">207 </span> <span class="Delimiter">}</span> +<span id="L208" class="LineNr">208 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"rm32"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L209" class="LineNr">209 </span> rm32 = <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L210" class="LineNr">210 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L211" class="LineNr">211 </span> <span class="Delimiter">}</span> +<span id="L212" class="LineNr">212 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"r32"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L213" class="LineNr">213 </span> reg_subop = <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L214" class="LineNr">214 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L215" class="LineNr">215 </span> <span class="Delimiter">}</span> +<span id="L216" class="LineNr">216 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"subop"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L217" class="LineNr">217 </span> reg_subop = <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L218" class="LineNr">218 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L219" class="LineNr">219 </span> <span class="Delimiter">}</span> +<span id="L220" class="LineNr">220 </span> <span class="Delimiter">}</span> +<span id="L221" class="LineNr">221 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>emit<span class="Delimiter">)</span> +<span id="L222" class="LineNr">222 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='032---operands.cc.html#L289'>hex_byte_text</a><span class="Delimiter">((</span>mod << <span class="Constant">6</span><span class="Delimiter">)</span> | <span class="Delimiter">(</span>reg_subop << <span class="Constant">3</span><span class="Delimiter">)</span> | rm32<span class="Delimiter">));</span> +<span id="L223" class="LineNr">223 </span><span class="Delimiter">}</span> +<span id="L224" class="LineNr">224 </span> +<span id="L225" class="LineNr">225 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L225'>add_sib_byte</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">,</span> line& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L226" class="LineNr">226 </span> <span class="Normal">uint8_t</span> scale=<span class="Constant">0</span><span class="Delimiter">,</span> index=<span class="Constant">0</span><span class="Delimiter">,</span> base=<span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L227" class="LineNr">227 </span> <span class="Normal">bool</span> emit = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L228" class="LineNr">228 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L229" class="LineNr">229 </span> <span class="Normal">const</span> word& curr = in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L230" class="LineNr">230 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"scale"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L231" class="LineNr">231 </span> scale = <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L232" class="LineNr">232 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L233" class="LineNr">233 </span> <span class="Delimiter">}</span> +<span id="L234" class="LineNr">234 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"index"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L235" class="LineNr">235 </span> index = <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L236" class="LineNr">236 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L237" class="LineNr">237 </span> <span class="Delimiter">}</span> +<span id="L238" class="LineNr">238 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"base"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L239" class="LineNr">239 </span> base = <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L240" class="LineNr">240 </span> emit = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L241" class="LineNr">241 </span> <span class="Delimiter">}</span> +<span id="L242" class="LineNr">242 </span> <span class="Delimiter">}</span> +<span id="L243" class="LineNr">243 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>emit<span class="Delimiter">)</span> +<span id="L244" class="LineNr">244 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='032---operands.cc.html#L289'>hex_byte_text</a><span class="Delimiter">((</span>scale << <span class="Constant">6</span><span class="Delimiter">)</span> | <span class="Delimiter">(</span>index << <span class="Constant">3</span><span class="Delimiter">)</span> | base<span class="Delimiter">));</span> +<span id="L245" class="LineNr">245 </span><span class="Delimiter">}</span> +<span id="L246" class="LineNr">246 </span> +<span id="L247" class="LineNr">247 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L247'>add_disp_bytes</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">,</span> line& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L248" class="LineNr">248 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L249" class="LineNr">249 </span> <span class="Normal">const</span> word& curr = in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L250" class="LineNr">250 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"disp8"</span><span class="Delimiter">))</span> +<span id="L251" class="LineNr">251 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L252" class="LineNr">252 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"disp16"</span><span class="Delimiter">))</span> +<span id="L253" class="LineNr">253 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> +<span id="L254" class="LineNr">254 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"disp32"</span><span class="Delimiter">))</span> +<span id="L255" class="LineNr">255 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">4</span><span class="Delimiter">);</span> +<span id="L256" class="LineNr">256 </span> <span class="Delimiter">}</span> +<span id="L257" class="LineNr">257 </span><span class="Delimiter">}</span> +<span id="L258" class="LineNr">258 </span> +<span id="L259" class="LineNr">259 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L259'>add_imm_bytes</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">,</span> line& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L260" class="LineNr">260 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L261" class="LineNr">261 </span> <span class="Normal">const</span> word& curr = in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L262" class="LineNr">262 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"imm8"</span><span class="Delimiter">))</span> +<span id="L263" class="LineNr">263 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L264" class="LineNr">264 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"imm32"</span><span class="Delimiter">))</span> +<span id="L265" class="LineNr">265 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">4</span><span class="Delimiter">);</span> +<span id="L266" class="LineNr">266 </span> <span class="Delimiter">}</span> +<span id="L267" class="LineNr">267 </span><span class="Delimiter">}</span> +<span id="L268" class="LineNr">268 </span> +<span id="L269" class="LineNr">269 </span><span class="Normal">void</span> emit_hex_bytes<span class="Delimiter">(</span>line& out<span class="Delimiter">,</span> <span class="Normal">const</span> word& w<span class="Delimiter">,</span> <span class="Normal">int</span> num<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L270" class="LineNr">270 </span> assert<span class="Delimiter">(</span>num <= <span class="Constant">4</span><span class="Delimiter">);</span> +<span id="L271" class="LineNr">271 </span> <span class="Normal">bool</span> is_number = <a href='032---operands.cc.html#L490'>looks_like_hex_int</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L272" class="LineNr">272 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>num == <span class="Constant">1</span> || !is_number<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L273" class="LineNr">273 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>w<span class="Delimiter">);</span> <span class="Comment">// preserve existing metadata</span> +<span id="L274" class="LineNr">274 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_number<span class="Delimiter">)</span> +<span id="L275" class="LineNr">275 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>data = <a href='032---operands.cc.html#L296'>hex_byte_to_string</a><span class="Delimiter">(</span><a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">));</span> +<span id="L276" class="LineNr">276 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L277" class="LineNr">277 </span> <span class="Delimiter">}</span> +<span id="L278" class="LineNr">278 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> <span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span><a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">)),</span> num<span class="Delimiter">);</span> +<span id="L279" class="LineNr">279 </span><span class="Delimiter">}</span> +<span id="L280" class="LineNr">280 </span> +<span id="L281" class="LineNr">281 </span><span class="Normal">void</span> emit_hex_bytes<span class="Delimiter">(</span>line& out<span class="Delimiter">,</span> <span class="Normal">uint32_t</span> val<span class="Delimiter">,</span> <span class="Normal">int</span> num<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L282" class="LineNr">282 </span> assert<span class="Delimiter">(</span>num <= <span class="Constant">4</span><span class="Delimiter">);</span> +<span id="L283" class="LineNr">283 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < num<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L284" class="LineNr">284 </span> out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='032---operands.cc.html#L289'>hex_byte_text</a><span class="Delimiter">(</span>val & <span class="Constant">0xff</span><span class="Delimiter">));</span> +<span id="L285" class="LineNr">285 </span> val = val >> <span class="Constant">8</span><span class="Delimiter">;</span> +<span id="L286" class="LineNr">286 </span> <span class="Delimiter">}</span> +<span id="L287" class="LineNr">287 </span><span class="Delimiter">}</span> +<span id="L288" class="LineNr">288 </span> +<span id="L289" class="LineNr">289 </span><a href='011run.cc.html#L127'>word</a> <a href='032---operands.cc.html#L289'>hex_byte_text</a><span class="Delimiter">(</span><span class="Normal">uint8_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L290" class="LineNr">290 </span> <a href='011run.cc.html#L127'>word</a> result<span class="Delimiter">;</span> +<span id="L291" class="LineNr">291 </span> result<span class="Delimiter">.</span>data = <a href='032---operands.cc.html#L296'>hex_byte_to_string</a><span class="Delimiter">(</span>val<span class="Delimiter">);</span> +<span id="L292" class="LineNr">292 </span> result<span class="Delimiter">.</span>original = result<span class="Delimiter">.</span>data+<span class="Constant">"/auto"</span><span class="Delimiter">;</span> +<span id="L293" class="LineNr">293 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L294" class="LineNr">294 </span><span class="Delimiter">}</span> +<span id="L295" class="LineNr">295 </span> +<span id="L296" class="LineNr">296 </span>string <a href='032---operands.cc.html#L296'>hex_byte_to_string</a><span class="Delimiter">(</span><span class="Normal">uint8_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L297" class="LineNr">297 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L298" class="LineNr">298 </span> <span class="Comment">// uint8_t prints without padding, but int8_t will expand to 32 bits again</span> +<span id="L299" class="LineNr">299 </span> out << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>val<span class="Delimiter">);</span> +<span id="L300" class="LineNr">300 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L301" class="LineNr">301 </span><span class="Delimiter">}</span> +<span id="L302" class="LineNr">302 </span> +<span id="L303" class="LineNr">303 </span>string to_string<span class="Delimiter">(</span><span class="Normal">const</span> vector<word>& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L304" class="LineNr">304 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L305" class="LineNr">305 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L306" class="LineNr">306 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L307" class="LineNr">307 </span> out << in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">;</span> +<span id="L308" class="LineNr">308 </span> <span class="Delimiter">}</span> +<span id="L309" class="LineNr">309 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L310" class="LineNr">310 </span><span class="Delimiter">}</span> +<span id="L311" class="LineNr">311 </span> +<span id="L312" class="LineNr">312 </span><span class="Delimiter">:(before "End Unit Tests")</span> +<span id="L313" class="LineNr">313 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L313'>test_preserve_metadata_when_emitting_single_byte</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L314" class="LineNr">314 </span> <a href='011run.cc.html#L127'>word</a> in<span class="Delimiter">;</span> +<span id="L315" class="LineNr">315 </span> in<span class="Delimiter">.</span>data = <span class="Constant">"f0"</span><span class="Delimiter">;</span> +<span id="L316" class="LineNr">316 </span> in<span class="Delimiter">.</span>original = <span class="Constant">"f0/foo"</span><span class="Delimiter">;</span> +<span id="L317" class="LineNr">317 </span> <a href='011run.cc.html#L121'>line</a> out<span class="Delimiter">;</span> +<span id="L318" class="LineNr">318 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">,</span> in<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L319" class="LineNr">319 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span>out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data<span class="Delimiter">,</span> <span class="Constant">"f0"</span><span class="Delimiter">);</span> +<span id="L320" class="LineNr">320 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span>out<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original<span class="Delimiter">,</span> <span class="Constant">"f0/foo"</span><span class="Delimiter">);</span> +<span id="L321" class="LineNr">321 </span><span class="Delimiter">}</span> +<span id="L322" class="LineNr">322 </span> +<span id="L323" class="LineNr">323 </span><span class="Delimiter">:(code)</span> +<span id="L324" class="LineNr">324 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L324'>test_pack_disp8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L325" class="LineNr">325 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> +<span id="L326" class="LineNr">326 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L327" class="LineNr">327 </span> <span class="Constant">"74 2/disp8\n"</span> <span class="Comment">// jump 2 bytes away if ZF is set</span> +<span id="L328" class="LineNr">328 </span> <span class="Delimiter">);</span> +<span id="L329" class="LineNr">329 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L330" class="LineNr">330 </span> <span class="Constant">"transform: packing instruction '74 2/disp8'\n"</span> +<span id="L331" class="LineNr">331 </span> <span class="Constant">"transform: instruction after packing: '74 02'\n"</span> +<span id="L332" class="LineNr">332 </span> <span class="Delimiter">);</span> +<span id="L333" class="LineNr">333 </span><span class="Delimiter">}</span> +<span id="L334" class="LineNr">334 </span> +<span id="L335" class="LineNr">335 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L335'>test_pack_disp8_negative</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L336" class="LineNr">336 </span> transform<span class="Delimiter">(</span> +<span id="L337" class="LineNr">337 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L338" class="LineNr">338 </span> <span class="Comment">// running this will cause an infinite loop</span> +<span id="L339" class="LineNr">339 </span> <span class="Constant">"74 -1/disp8\n"</span> <span class="Comment">// jump 1 byte before if ZF is set</span> +<span id="L340" class="LineNr">340 </span> <span class="Delimiter">);</span> +<span id="L341" class="LineNr">341 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L342" class="LineNr">342 </span> <span class="Constant">"transform: packing instruction '74 -1/disp8'\n"</span> +<span id="L343" class="LineNr">343 </span> <span class="Constant">"transform: instruction after packing: '74 ff'\n"</span> +<span id="L344" class="LineNr">344 </span> <span class="Delimiter">);</span> +<span id="L345" class="LineNr">345 </span><span class="Delimiter">}</span> +<span id="L346" class="LineNr">346 </span> +<span id="L347" class="LineNr">347 </span><span class="Comment">//: helper for scenario</span> +<span id="L348" class="LineNr">348 </span><span class="Normal">void</span> transform<span class="Delimiter">(</span><span class="Normal">const</span> string& text_bytes<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L349" class="LineNr">349 </span> program p<span class="Delimiter">;</span> +<span id="L350" class="LineNr">350 </span> istringstream in<span class="Delimiter">(</span>text_bytes<span class="Delimiter">);</span> +<span id="L351" class="LineNr">351 </span> parse<span class="Delimiter">(</span>in<span class="Delimiter">,</span> p<span class="Delimiter">);</span> +<span id="L352" class="LineNr">352 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L353" class="LineNr">353 </span> transform<span class="Delimiter">(</span>p<span class="Delimiter">);</span> +<span id="L354" class="LineNr">354 </span><span class="Delimiter">}</span> +<span id="L355" class="LineNr">355 </span> +<span id="L356" class="LineNr">356 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L356'>test_pack_modrm_imm32</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L357" class="LineNr">357 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> +<span id="L358" class="LineNr">358 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L359" class="LineNr">359 </span> <span class="Comment">// instruction effective address operand displacement immediate\n"</span> +<span id="L360" class="LineNr">360 </span> <span class="Comment">// op subop mod rm32 base index scale r32\n"</span> +<span id="L361" class="LineNr">361 </span> <span class="Comment">// 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes\n"</span> +<span id="L362" class="LineNr">362 </span> <span class="Constant">" 81 0/add/subop 3/mod/direct 3/ebx/rm32 1/imm32 \n"</span> <span class="Comment">// add 1 to EBX</span> +<span id="L363" class="LineNr">363 </span> <span class="Delimiter">);</span> +<span id="L364" class="LineNr">364 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L365" class="LineNr">365 </span> <span class="Constant">"transform: packing instruction '81 0/add/subop 3/mod/direct 3/ebx/rm32 1/imm32'\n"</span> +<span id="L366" class="LineNr">366 </span> <span class="Constant">"transform: instruction after packing: '81 c3 01 00 00 00'\n"</span> +<span id="L367" class="LineNr">367 </span> <span class="Delimiter">);</span> +<span id="L368" class="LineNr">368 </span><span class="Delimiter">}</span> +<span id="L369" class="LineNr">369 </span> +<span id="L370" class="LineNr">370 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L370'>test_pack_imm32_large</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L371" class="LineNr">371 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> +<span id="L372" class="LineNr">372 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L373" class="LineNr">373 </span> <span class="Constant">"b9 0x080490a7/imm32\n"</span> +<span id="L374" class="LineNr">374 </span> <span class="Delimiter">);</span> +<span id="L375" class="LineNr">375 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L376" class="LineNr">376 </span> <span class="Constant">"transform: packing instruction 'b9 0x080490a7/imm32'\n"</span> +<span id="L377" class="LineNr">377 </span> <span class="Constant">"transform: instruction after packing: 'b9 a7 90 04 08'\n"</span> +<span id="L378" class="LineNr">378 </span> <span class="Delimiter">);</span> +<span id="L379" class="LineNr">379 </span><span class="Delimiter">}</span> +<span id="L380" class="LineNr">380 </span> +<span id="L381" class="LineNr">381 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L381'>test_pack_immediate_constants_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L382" class="LineNr">382 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> +<span id="L383" class="LineNr">383 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L384" class="LineNr">384 </span> <span class="Constant">"b9 0x2a/imm32\n"</span> +<span id="L385" class="LineNr">385 </span> <span class="Delimiter">);</span> +<span id="L386" class="LineNr">386 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L387" class="LineNr">387 </span> <span class="Constant">"transform: packing instruction 'b9 0x2a/imm32'\n"</span> +<span id="L388" class="LineNr">388 </span> <span class="Constant">"transform: instruction after packing: 'b9 2a 00 00 00'\n"</span> +<span id="L389" class="LineNr">389 </span> <span class="Constant">"run: copy imm32 0x0000002a to ECX\n"</span> +<span id="L390" class="LineNr">390 </span> <span class="Delimiter">);</span> +<span id="L391" class="LineNr">391 </span><span class="Delimiter">}</span> +<span id="L392" class="LineNr">392 </span> +<span id="L393" class="LineNr">393 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L393'>test_pack_silently_ignores_non_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L394" class="LineNr">394 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L395" class="LineNr">395 </span> transform<span class="Delimiter">(</span> +<span id="L396" class="LineNr">396 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L397" class="LineNr">397 </span> <span class="Constant">"b9 foo/imm32\n"</span> +<span id="L398" class="LineNr">398 </span> <span class="Delimiter">);</span> +<span id="L399" class="LineNr">399 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L400" class="LineNr">400 </span> <span class="Constant">"transform: packing instruction 'b9 foo/imm32'\n"</span> +<span id="L401" class="LineNr">401 </span> <span class="Comment">// no change (we're just not printing metadata to the trace)</span> +<span id="L402" class="LineNr">402 </span> <span class="Constant">"transform: instruction after packing: 'b9 foo'\n"</span> +<span id="L403" class="LineNr">403 </span> <span class="Delimiter">);</span> +<span id="L404" class="LineNr">404 </span><span class="Delimiter">}</span> +<span id="L405" class="LineNr">405 </span> +<span id="L406" class="LineNr">406 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L406'>test_pack_flags_bad_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L407" class="LineNr">407 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L408" class="LineNr">408 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> +<span id="L409" class="LineNr">409 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L410" class="LineNr">410 </span> <span class="Constant">"b9 0xfoo/imm32\n"</span> +<span id="L411" class="LineNr">411 </span> <span class="Delimiter">);</span> +<span id="L412" class="LineNr">412 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L413" class="LineNr">413 </span> <span class="Constant">"error: not a number: 0xfoo\n"</span> +<span id="L414" class="LineNr">414 </span> <span class="Delimiter">);</span> +<span id="L415" class="LineNr">415 </span><span class="Delimiter">}</span> +<span id="L416" class="LineNr">416 </span> +<span id="L417" class="LineNr">417 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L417'>test_pack_flags_uppercase_hex</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L418" class="LineNr">418 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L419" class="LineNr">419 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> +<span id="L420" class="LineNr">420 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L421" class="LineNr">421 </span> <span class="Constant">"b9 0xAb/imm32\n"</span> +<span id="L422" class="LineNr">422 </span> <span class="Delimiter">);</span> +<span id="L423" class="LineNr">423 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L424" class="LineNr">424 </span> <span class="Constant">"error: uppercase hex not allowed: 0xAb\n"</span> +<span id="L425" class="LineNr">425 </span> <span class="Delimiter">);</span> +<span id="L426" class="LineNr">426 </span><span class="Delimiter">}</span> +<span id="L427" class="LineNr">427 </span> +<span id="L428" class="LineNr">428 </span><span class="SalientComment">//:: helpers</span> +<span id="L429" class="LineNr">429 </span> +<span id="L430" class="LineNr">430 </span><span class="Normal">bool</span> <a href='032---operands.cc.html#L430'>all_hex_bytes</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L431" class="LineNr">431 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L432" class="LineNr">432 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_hex_byte<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> +<span id="L433" class="LineNr">433 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L434" class="LineNr">434 </span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L435" class="LineNr">435 </span><span class="Delimiter">}</span> +<span id="L436" class="LineNr">436 </span> +<span id="L437" class="LineNr">437 </span><span class="Normal">bool</span> <a href='032---operands.cc.html#L437'>is_hex_byte</a><span class="Delimiter">(</span><span class="Normal">const</span> word& curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L438" class="LineNr">438 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L447'>contains_any_operand_metadata</a><span class="Delimiter">(</span>curr<span class="Delimiter">))</span> +<span id="L439" class="LineNr">439 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L440" class="LineNr">440 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> +<span id="L441" class="LineNr">441 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L442" class="LineNr">442 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">.</span>find_first_not_of<span class="Delimiter">(</span><span class="Constant">"0123456789abcdef"</span><span class="Delimiter">)</span> != string::npos<span class="Delimiter">)</span> +<span id="L443" class="LineNr">443 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L444" class="LineNr">444 </span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L445" class="LineNr">445 </span><span class="Delimiter">}</span> +<span id="L446" class="LineNr">446 </span> +<span id="L447" class="LineNr">447 </span><span class="Normal">bool</span> <a href='032---operands.cc.html#L447'>contains_any_operand_metadata</a><span class="Delimiter">(</span><span class="Normal">const</span> word& <a href='011run.cc.html#L127'>word</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L448" class="LineNr">448 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span><a href='011run.cc.html#L127'>word</a><span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L449" class="LineNr">449 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>find<span class="Delimiter">(</span><a href='011run.cc.html#L127'>word</a><span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> != <span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>end<span class="Delimiter">())</span> +<span id="L450" class="LineNr">450 </span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L451" class="LineNr">451 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L452" class="LineNr">452 </span><span class="Delimiter">}</span> +<span id="L453" class="LineNr">453 </span> +<span id="L454" class="LineNr">454 </span><span class="Normal">bool</span> has_operand_metadata<span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">,</span> <span class="Normal">const</span> string& m<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L455" class="LineNr">455 </span> <span class="Normal">bool</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L456" class="LineNr">456 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L457" class="LineNr">457 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_operand_metadata<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> m<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L458" class="LineNr">458 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L459" class="LineNr">459 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"' has conflicting "</span> << m << <span class="Constant">" operands\n"</span> << end<span class="Delimiter">();</span> +<span id="L460" class="LineNr">460 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L461" class="LineNr">461 </span> <span class="Delimiter">}</span> +<span id="L462" class="LineNr">462 </span> result = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L463" class="LineNr">463 </span> <span class="Delimiter">}</span> +<span id="L464" class="LineNr">464 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L465" class="LineNr">465 </span><span class="Delimiter">}</span> +<span id="L466" class="LineNr">466 </span> +<span id="L467" class="LineNr">467 </span><span class="Normal">bool</span> has_operand_metadata<span class="Delimiter">(</span><span class="Normal">const</span> word& w<span class="Delimiter">,</span> <span class="Normal">const</span> string& m<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L468" class="LineNr">468 </span> <span class="Normal">bool</span> result = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L469" class="LineNr">469 </span> <span class="Normal">bool</span> metadata_found = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L470" class="LineNr">470 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L471" class="LineNr">471 </span> <span class="Normal">const</span> string& curr = w<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L472" class="LineNr">472 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>find<span class="Delimiter">(</span>curr<span class="Delimiter">)</span> == <span class="Special"><a href='032---operands.cc.html#L49'>Instruction_operands</a></span><span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// ignore unrecognized metadata</span> +<span id="L473" class="LineNr">473 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>metadata_found<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L474" class="LineNr">474 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << w<span class="Delimiter">.</span>original << <span class="Constant">"' has conflicting operand types; it should have only one\n"</span> << end<span class="Delimiter">();</span> +<span id="L475" class="LineNr">475 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L476" class="LineNr">476 </span> <span class="Delimiter">}</span> +<span id="L477" class="LineNr">477 </span> metadata_found = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L478" class="LineNr">478 </span> result = <span class="Delimiter">(</span>curr == m<span class="Delimiter">);</span> +<span id="L479" class="LineNr">479 </span> <span class="Delimiter">}</span> +<span id="L480" class="LineNr">480 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L481" class="LineNr">481 </span><span class="Delimiter">}</span> +<span id="L482" class="LineNr">482 </span> +<span id="L483" class="LineNr">483 </span><a href='011run.cc.html#L127'>word</a> metadata<span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">,</span> <span class="Normal">const</span> string& m<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L484" class="LineNr">484 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L485" class="LineNr">485 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> m<span class="Delimiter">))</span> +<span id="L486" class="LineNr">486 </span> <span class="Identifier">return</span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L487" class="LineNr">487 </span> assert<span class="Delimiter">(</span><span class="Constant">false</span><span class="Delimiter">);</span> +<span id="L488" class="LineNr">488 </span><span class="Delimiter">}</span> +<span id="L489" class="LineNr">489 </span> +<span id="L490" class="LineNr">490 </span><span class="Normal">bool</span> <a href='032---operands.cc.html#L490'>looks_like_hex_int</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L491" class="LineNr">491 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L492" class="LineNr">492 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">'-'</span> || s<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">'+'</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L493" class="LineNr">493 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>isdigit<span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Comment">// includes '0x' prefix</span> +<span id="L494" class="LineNr">494 </span> <span class="Comment">// End looks_like_hex_int(s) Detectors</span> +<span id="L495" class="LineNr">495 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L496" class="LineNr">496 </span><span class="Delimiter">}</span> +<span id="L497" class="LineNr">497 </span> +<span id="L498" class="LineNr">498 </span>string to_string<span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L499" class="LineNr">499 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L500" class="LineNr">500 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L501" class="LineNr">501 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L502" class="LineNr">502 </span> out << inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original<span class="Delimiter">;</span> +<span id="L503" class="LineNr">503 </span> <span class="Delimiter">}</span> +<span id="L504" class="LineNr">504 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L505" class="LineNr">505 </span><span class="Delimiter">}</span> +<span id="L506" class="LineNr">506 </span> +<span id="L507" class="LineNr">507 </span><span class="Normal">int32_t</span> <a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L508" class="LineNr">508 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L509" class="LineNr">509 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='011run.cc.html#L449'>contains_uppercase</a><span class="Delimiter">(</span>s<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L510" class="LineNr">510 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"uppercase hex not allowed: "</span> << s << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L511" class="LineNr">511 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L512" class="LineNr">512 </span> <span class="Delimiter">}</span> +<span id="L513" class="LineNr">513 </span> istringstream in<span class="Delimiter">(</span>s<span class="Delimiter">);</span> +<span id="L514" class="LineNr">514 </span> in >> std::hex<span class="Delimiter">;</span> +<span id="L515" class="LineNr">515 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">'-'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L516" class="LineNr">516 </span> <span class="Normal">int32_t</span> result = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L517" class="LineNr">517 </span> in >> result<span class="Delimiter">;</span> +<span id="L518" class="LineNr">518 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!in || !in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L519" class="LineNr">519 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"not a number: "</span> << s << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L520" class="LineNr">520 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L521" class="LineNr">521 </span> <span class="Delimiter">}</span> +<span id="L522" class="LineNr">522 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L523" class="LineNr">523 </span> <span class="Delimiter">}</span> +<span id="L524" class="LineNr">524 </span> <span class="Normal">uint32_t</span> uresult = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L525" class="LineNr">525 </span> in >> uresult<span class="Delimiter">;</span> +<span id="L526" class="LineNr">526 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!in || !in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L527" class="LineNr">527 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"not a number: "</span> << s << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L528" class="LineNr">528 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L529" class="LineNr">529 </span> <span class="Delimiter">}</span> +<span id="L530" class="LineNr">530 </span> <span class="Identifier">return</span> <span class="Normal">static_cast</span><<span class="Normal">int32_t</span>><span class="Delimiter">(</span>uresult<span class="Delimiter">);</span> +<span id="L531" class="LineNr">531 </span><span class="Delimiter">}</span> +<span id="L532" class="LineNr">532 </span><span class="Delimiter">:(before "End Unit Tests")</span> +<span id="L533" class="LineNr">533 </span><span class="Normal">void</span> <a href='032---operands.cc.html#L533'>test_parse_int</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L534" class="LineNr">534 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"0"</span><span class="Delimiter">));</span> +<span id="L535" class="LineNr">535 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"0x0"</span><span class="Delimiter">));</span> +<span id="L536" class="LineNr">536 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"0x0"</span><span class="Delimiter">));</span> +<span id="L537" class="LineNr">537 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><span class="Constant">16</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"10"</span><span class="Delimiter">));</span> <span class="Comment">// hex always</span> +<span id="L538" class="LineNr">538 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span>-<span class="Constant">1</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"-1"</span><span class="Delimiter">));</span> +<span id="L539" class="LineNr">539 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span>-<span class="Constant">1</span><span class="Delimiter">,</span> <a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span><span class="Constant">"0xffffffff"</span><span class="Delimiter">));</span> +<span id="L540" class="LineNr">540 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/033check_operands.cc.html b/html/033check_operands.cc.html index ad7fc2a9..f771f27e 100644 --- a/html/033check_operands.cc.html +++ b/html/033check_operands.cc.html @@ -64,7 +64,7 @@ if ('onhashchange' in window) { <span id="L3" class="LineNr"> 3 </span> <span id="L4" class="LineNr"> 4 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L4'>test_check_missing_imm8_operand</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L5" class="LineNr"> 5 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L6" class="LineNr"> 6 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L6" class="LineNr"> 6 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L7" class="LineNr"> 7 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L8" class="LineNr"> 8 </span> <span class="Constant">"cd\n"</span> <span class="Comment">// interrupt ??</span> <span id="L9" class="LineNr"> 9 </span> <span class="Delimiter">);</span> @@ -80,14 +80,14 @@ if ('onhashchange' in window) { <span id="L19" class="LineNr"> 19 </span><span class="Delimiter">:(code)</span> <span id="L20" class="LineNr"> 20 </span><span class="Normal">void</span> check_operands<span class="Delimiter">(</span><span class="Normal">const</span> segment& code<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L21" class="LineNr"> 21 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- check operands"</span> << end<span class="Delimiter">();</span> -<span id="L22" class="LineNr"> 22 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L23" class="LineNr"> 23 </span> check_operands<span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> +<span id="L22" class="LineNr"> 22 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L23" class="LineNr"> 23 </span> check_operands<span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span id="L24" class="LineNr"> 24 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// stop at the first mal-formed instruction</span> <span id="L25" class="LineNr"> 25 </span> <span class="Delimiter">}</span> <span id="L26" class="LineNr"> 26 </span><span class="Delimiter">}</span> <span id="L27" class="LineNr"> 27 </span> <span id="L28" class="LineNr"> 28 </span><span class="Normal">void</span> check_operands<span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L29" class="LineNr"> 29 </span> <a href='011run.cc.html#L128'>word</a> op = <a href='033check_operands.cc.html#L41'>preprocess_op</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> +<span id="L29" class="LineNr"> 29 </span> <a href='011run.cc.html#L127'>word</a> op = <a href='033check_operands.cc.html#L41'>preprocess_op</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span id="L30" class="LineNr"> 30 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>op<span class="Delimiter">.</span>data == <span class="Constant">"0f"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L31" class="LineNr"> 31 </span> check_operands_0f<span class="Delimiter">(</span>inst<span class="Delimiter">);</span> <span id="L32" class="LineNr"> 32 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> @@ -99,19 +99,19 @@ if ('onhashchange' in window) { <span id="L38" class="LineNr"> 38 </span> check_operands<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> op<span class="Delimiter">);</span> <span id="L39" class="LineNr"> 39 </span><span class="Delimiter">}</span> <span id="L40" class="LineNr"> 40 </span> -<span id="L41" class="LineNr"> 41 </span><a href='011run.cc.html#L128'>word</a> <a href='033check_operands.cc.html#L41'>preprocess_op</a><span class="Delimiter">(</span><a href='011run.cc.html#L128'>word</a><span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> op<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L41" class="LineNr"> 41 </span><a href='011run.cc.html#L127'>word</a> <a href='033check_operands.cc.html#L41'>preprocess_op</a><span class="Delimiter">(</span><a href='011run.cc.html#L127'>word</a><span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> op<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L42" class="LineNr"> 42 </span> op<span class="Delimiter">.</span>data = <a href='033check_operands.cc.html#L679'>tolower</a><span class="Delimiter">(</span>op<span class="Delimiter">.</span>data<span class="Delimiter">.</span>c_str<span class="Delimiter">());</span> <span id="L43" class="LineNr"> 43 </span> <span class="Comment">// opcodes can't be negative</span> -<span id="L44" class="LineNr"> 44 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L105'>starts_with</a><span class="Delimiter">(</span>op<span class="Delimiter">.</span>data<span class="Delimiter">,</span> <span class="Constant">"0x"</span><span class="Delimiter">))</span> +<span id="L44" class="LineNr"> 44 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L106'>starts_with</a><span class="Delimiter">(</span>op<span class="Delimiter">.</span>data<span class="Delimiter">,</span> <span class="Constant">"0x"</span><span class="Delimiter">))</span> <span id="L45" class="LineNr"> 45 </span> op<span class="Delimiter">.</span>data = op<span class="Delimiter">.</span>data<span class="Delimiter">.</span>substr<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> -<span id="L46" class="LineNr"> 46 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>op<span class="Delimiter">.</span>data<span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">)</span> +<span id="L46" class="LineNr"> 46 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>op<span class="Delimiter">.</span>data<span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">)</span> <span id="L47" class="LineNr"> 47 </span> op<span class="Delimiter">.</span>data = string<span class="Delimiter">(</span><span class="Constant">"0"</span><span class="Delimiter">)</span>+op<span class="Delimiter">.</span>data<span class="Delimiter">;</span> <span id="L48" class="LineNr"> 48 </span> <span class="Identifier">return</span> op<span class="Delimiter">;</span> <span id="L49" class="LineNr"> 49 </span><span class="Delimiter">}</span> <span id="L50" class="LineNr"> 50 </span> <span id="L51" class="LineNr"> 51 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L51'>test_preprocess_op</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L52" class="LineNr"> 52 </span> <a href='011run.cc.html#L128'>word</a> w1<span class="Delimiter">;</span> w1<span class="Delimiter">.</span>data = <span class="Constant">"0xf"</span><span class="Delimiter">;</span> -<span id="L53" class="LineNr"> 53 </span> <a href='011run.cc.html#L128'>word</a> w2<span class="Delimiter">;</span> w2<span class="Delimiter">.</span>data = <span class="Constant">"0f"</span><span class="Delimiter">;</span> +<span id="L52" class="LineNr"> 52 </span> <a href='011run.cc.html#L127'>word</a> w1<span class="Delimiter">;</span> w1<span class="Delimiter">.</span>data = <span class="Constant">"0xf"</span><span class="Delimiter">;</span> +<span id="L53" class="LineNr"> 53 </span> <a href='011run.cc.html#L127'>word</a> w2<span class="Delimiter">;</span> w2<span class="Delimiter">.</span>data = <span class="Constant">"0f"</span><span class="Delimiter">;</span> <span id="L54" class="LineNr"> 54 </span> <a href='002test.cc.html#L31'>CHECK_EQ</a><span class="Delimiter">(</span><a href='033check_operands.cc.html#L41'>preprocess_op</a><span class="Delimiter">(</span>w1<span class="Delimiter">).</span>data<span class="Delimiter">,</span> <a href='033check_operands.cc.html#L41'>preprocess_op</a><span class="Delimiter">(</span>w2<span class="Delimiter">).</span>data<span class="Delimiter">);</span> <span id="L55" class="LineNr"> 55 </span><span class="Delimiter">}</span> <span id="L56" class="LineNr"> 56 </span> @@ -165,147 +165,147 @@ if ('onhashchange' in window) { <span id="L104" class="LineNr">104 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L104'>init_permitted_operands</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L105" class="LineNr">105 </span> <span class="SalientComment">//// Class A: just op, no operands</span> <span id="L106" class="LineNr">106 </span> <span class="Comment">// halt</span> -<span id="L107" class="LineNr">107 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"f4"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L107" class="LineNr">107 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"f4"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> <span id="L108" class="LineNr">108 </span> <span class="Comment">// inc</span> -<span id="L109" class="LineNr">109 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"40"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L110" class="LineNr">110 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"41"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L111" class="LineNr">111 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"42"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L112" class="LineNr">112 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"43"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L113" class="LineNr">113 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"44"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L114" class="LineNr">114 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"45"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L115" class="LineNr">115 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"46"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L116" class="LineNr">116 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"47"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L109" class="LineNr">109 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"40"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L110" class="LineNr">110 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"41"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L111" class="LineNr">111 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"42"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L112" class="LineNr">112 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"43"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L113" class="LineNr">113 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"44"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L114" class="LineNr">114 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"45"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L115" class="LineNr">115 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"46"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L116" class="LineNr">116 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"47"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> <span id="L117" class="LineNr">117 </span> <span class="Comment">// dec</span> -<span id="L118" class="LineNr">118 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"48"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L119" class="LineNr">119 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"49"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L120" class="LineNr">120 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4a"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L121" class="LineNr">121 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4b"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L122" class="LineNr">122 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4c"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L123" class="LineNr">123 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4d"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L124" class="LineNr">124 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4e"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L125" class="LineNr">125 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4f"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L118" class="LineNr">118 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"48"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L119" class="LineNr">119 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"49"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L120" class="LineNr">120 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4a"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L121" class="LineNr">121 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4b"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L122" class="LineNr">122 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4c"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L123" class="LineNr">123 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4d"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L124" class="LineNr">124 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4e"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L125" class="LineNr">125 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"4f"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> <span id="L126" class="LineNr">126 </span> <span class="Comment">// push</span> -<span id="L127" class="LineNr">127 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"50"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L128" class="LineNr">128 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"51"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L129" class="LineNr">129 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"52"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L130" class="LineNr">130 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"53"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L131" class="LineNr">131 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"54"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L132" class="LineNr">132 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"55"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L133" class="LineNr">133 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"56"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L134" class="LineNr">134 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"57"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L127" class="LineNr">127 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"50"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L128" class="LineNr">128 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"51"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L129" class="LineNr">129 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"52"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L130" class="LineNr">130 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"53"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L131" class="LineNr">131 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"54"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L132" class="LineNr">132 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"55"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L133" class="LineNr">133 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"56"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L134" class="LineNr">134 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"57"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> <span id="L135" class="LineNr">135 </span> <span class="Comment">// pop</span> -<span id="L136" class="LineNr">136 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"58"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L137" class="LineNr">137 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"59"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L138" class="LineNr">138 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5a"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L139" class="LineNr">139 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5b"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L140" class="LineNr">140 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5c"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L141" class="LineNr">141 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5d"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L142" class="LineNr">142 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5e"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> -<span id="L143" class="LineNr">143 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5f"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L136" class="LineNr">136 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"58"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L137" class="LineNr">137 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"59"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L138" class="LineNr">138 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5a"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L139" class="LineNr">139 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5b"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L140" class="LineNr">140 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5c"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L141" class="LineNr">141 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5d"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L142" class="LineNr">142 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5e"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L143" class="LineNr">143 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"5f"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> <span id="L144" class="LineNr">144 </span> <span class="Comment">// sign-extend EAX into EDX</span> -<span id="L145" class="LineNr">145 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"99"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L145" class="LineNr">145 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"99"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> <span id="L146" class="LineNr">146 </span> <span class="Comment">// return</span> -<span id="L147" class="LineNr">147 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"c3"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L147" class="LineNr">147 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"c3"</span><span class="Delimiter">,</span> <span class="Constant">0x00</span><span class="Delimiter">);</span> <span id="L148" class="LineNr">148 </span> <span id="L149" class="LineNr">149 </span> <span class="SalientComment">//// Class B: just op and disp8</span> <span id="L150" class="LineNr">150 </span> <span class="Comment">// imm32 imm8 disp32 |disp16 disp8 subop modrm</span> <span id="L151" class="LineNr">151 </span> <span class="Comment">// 0 0 0 |0 1 0 0</span> <span id="L152" class="LineNr">152 </span> <span id="L153" class="LineNr">153 </span> <span class="Comment">// jump</span> -<span id="L154" class="LineNr">154 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"eb"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> -<span id="L155" class="LineNr">155 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"72"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> -<span id="L156" class="LineNr">156 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"73"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> -<span id="L157" class="LineNr">157 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"74"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> -<span id="L158" class="LineNr">158 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"75"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> -<span id="L159" class="LineNr">159 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"76"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> -<span id="L160" class="LineNr">160 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"77"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> -<span id="L161" class="LineNr">161 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"7c"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> -<span id="L162" class="LineNr">162 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"7d"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> -<span id="L163" class="LineNr">163 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"7e"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> -<span id="L164" class="LineNr">164 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"7f"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L154" class="LineNr">154 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"eb"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L155" class="LineNr">155 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"72"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L156" class="LineNr">156 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"73"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L157" class="LineNr">157 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"74"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L158" class="LineNr">158 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"75"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L159" class="LineNr">159 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"76"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L160" class="LineNr">160 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"77"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L161" class="LineNr">161 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"7c"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L162" class="LineNr">162 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"7d"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L163" class="LineNr">163 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"7e"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> +<span id="L164" class="LineNr">164 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"7f"</span><span class="Delimiter">,</span> <span class="Constant">0x04</span><span class="Delimiter">);</span> <span id="L165" class="LineNr">165 </span> <span id="L166" class="LineNr">166 </span> <span class="SalientComment">//// Class D: just op and disp32</span> <span id="L167" class="LineNr">167 </span> <span class="Comment">// imm32 imm8 disp32 |disp16 disp8 subop modrm</span> <span id="L168" class="LineNr">168 </span> <span class="Comment">// 0 0 1 |0 0 0 0</span> -<span id="L169" class="LineNr">169 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"e8"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> <span class="Comment">// call</span> -<span id="L170" class="LineNr">170 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"e9"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> <span class="Comment">// jump</span> +<span id="L169" class="LineNr">169 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"e8"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> <span class="Comment">// call</span> +<span id="L170" class="LineNr">170 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"e9"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> <span class="Comment">// jump</span> <span id="L171" class="LineNr">171 </span> <span id="L172" class="LineNr">172 </span> <span class="SalientComment">//// Class E: just op and imm8</span> <span id="L173" class="LineNr">173 </span> <span class="Comment">// imm32 imm8 disp32 |disp16 disp8 subop modrm</span> <span id="L174" class="LineNr">174 </span> <span class="Comment">// 0 1 0 |0 0 0 0</span> -<span id="L175" class="LineNr">175 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"cd"</span><span class="Delimiter">,</span> <span class="Constant">0x20</span><span class="Delimiter">);</span> <span class="Comment">// software interrupt</span> +<span id="L175" class="LineNr">175 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"cd"</span><span class="Delimiter">,</span> <span class="Constant">0x20</span><span class="Delimiter">);</span> <span class="Comment">// software interrupt</span> <span id="L176" class="LineNr">176 </span> <span id="L177" class="LineNr">177 </span> <span class="SalientComment">//// Class F: just op and imm32</span> <span id="L178" class="LineNr">178 </span> <span class="Comment">// imm32 imm8 disp32 |disp16 disp8 subop modrm</span> <span id="L179" class="LineNr">179 </span> <span class="Comment">// 1 0 0 |0 0 0 0</span> -<span id="L180" class="LineNr">180 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"05"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// add</span> -<span id="L181" class="LineNr">181 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"2d"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// subtract</span> -<span id="L182" class="LineNr">182 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"25"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// and</span> -<span id="L183" class="LineNr">183 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"0d"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// or</span> -<span id="L184" class="LineNr">184 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"35"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// xor</span> -<span id="L185" class="LineNr">185 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"3d"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// compare</span> -<span id="L186" class="LineNr">186 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"68"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// push</span> +<span id="L180" class="LineNr">180 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"05"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// add</span> +<span id="L181" class="LineNr">181 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"2d"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// subtract</span> +<span id="L182" class="LineNr">182 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"25"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// and</span> +<span id="L183" class="LineNr">183 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"0d"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// or</span> +<span id="L184" class="LineNr">184 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"35"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// xor</span> +<span id="L185" class="LineNr">185 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"3d"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// compare</span> +<span id="L186" class="LineNr">186 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"68"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span class="Comment">// push</span> <span id="L187" class="LineNr">187 </span> <span class="Comment">// copy</span> -<span id="L188" class="LineNr">188 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"b8"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> -<span id="L189" class="LineNr">189 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"b9"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> -<span id="L190" class="LineNr">190 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"ba"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> -<span id="L191" class="LineNr">191 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"bb"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> -<span id="L192" class="LineNr">192 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"bc"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> -<span id="L193" class="LineNr">193 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"bd"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> -<span id="L194" class="LineNr">194 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"be"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> -<span id="L195" class="LineNr">195 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"bf"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> +<span id="L188" class="LineNr">188 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"b8"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> +<span id="L189" class="LineNr">189 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"b9"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> +<span id="L190" class="LineNr">190 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"ba"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> +<span id="L191" class="LineNr">191 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"bb"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> +<span id="L192" class="LineNr">192 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"bc"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> +<span id="L193" class="LineNr">193 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"bd"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> +<span id="L194" class="LineNr">194 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"be"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> +<span id="L195" class="LineNr">195 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"bf"</span><span class="Delimiter">,</span> <span class="Constant">0x40</span><span class="Delimiter">);</span> <span id="L196" class="LineNr">196 </span> <span id="L197" class="LineNr">197 </span> <span class="SalientComment">//// Class M: using ModR/M byte</span> <span id="L198" class="LineNr">198 </span> <span class="Comment">// imm32 imm8 disp32 |disp16 disp8 subop modrm</span> <span id="L199" class="LineNr">199 </span> <span class="Comment">// 0 0 0 |0 0 0 1</span> <span id="L200" class="LineNr">200 </span> <span id="L201" class="LineNr">201 </span> <span class="Comment">// add</span> -<span id="L202" class="LineNr">202 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"01"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> -<span id="L203" class="LineNr">203 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"03"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L202" class="LineNr">202 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"01"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L203" class="LineNr">203 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"03"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> <span id="L204" class="LineNr">204 </span> <span class="Comment">// subtract</span> -<span id="L205" class="LineNr">205 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"29"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> -<span id="L206" class="LineNr">206 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"2b"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L205" class="LineNr">205 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"29"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L206" class="LineNr">206 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"2b"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> <span id="L207" class="LineNr">207 </span> <span class="Comment">// and</span> -<span id="L208" class="LineNr">208 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"21"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> -<span id="L209" class="LineNr">209 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"23"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L208" class="LineNr">208 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"21"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L209" class="LineNr">209 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"23"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> <span id="L210" class="LineNr">210 </span> <span class="Comment">// or</span> -<span id="L211" class="LineNr">211 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"09"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> -<span id="L212" class="LineNr">212 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"0b"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L211" class="LineNr">211 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"09"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L212" class="LineNr">212 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"0b"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> <span id="L213" class="LineNr">213 </span> <span class="Comment">// xor</span> -<span id="L214" class="LineNr">214 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"31"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> -<span id="L215" class="LineNr">215 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"33"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L214" class="LineNr">214 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"31"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L215" class="LineNr">215 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"33"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> <span id="L216" class="LineNr">216 </span> <span class="Comment">// compare</span> -<span id="L217" class="LineNr">217 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"39"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> -<span id="L218" class="LineNr">218 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"3b"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L217" class="LineNr">217 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"39"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L218" class="LineNr">218 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"3b"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> <span id="L219" class="LineNr">219 </span> <span class="Comment">// copy</span> -<span id="L220" class="LineNr">220 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"88"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> -<span id="L221" class="LineNr">221 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"89"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> -<span id="L222" class="LineNr">222 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"8a"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> -<span id="L223" class="LineNr">223 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"8b"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L220" class="LineNr">220 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"88"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L221" class="LineNr">221 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"89"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L222" class="LineNr">222 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"8a"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L223" class="LineNr">223 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"8b"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> <span id="L224" class="LineNr">224 </span> <span class="Comment">// swap</span> -<span id="L225" class="LineNr">225 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"87"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L225" class="LineNr">225 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"87"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> <span id="L226" class="LineNr">226 </span> <span class="Comment">// copy address (lea)</span> -<span id="L227" class="LineNr">227 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"8d"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L227" class="LineNr">227 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"8d"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> <span id="L228" class="LineNr">228 </span> <span id="L229" class="LineNr">229 </span> <span class="SalientComment">//// Class N: op, ModR/M and subop (not r32)</span> <span id="L230" class="LineNr">230 </span> <span class="Comment">// imm32 imm8 disp32 |disp16 disp8 subop modrm</span> <span id="L231" class="LineNr">231 </span> <span class="Comment">// 0 0 0 |0 0 1 1</span> -<span id="L232" class="LineNr">232 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"8f"</span><span class="Delimiter">,</span> <span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Comment">// pop</span> -<span id="L233" class="LineNr">233 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"d3"</span><span class="Delimiter">,</span> <span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Comment">// shift</span> -<span id="L234" class="LineNr">234 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"f7"</span><span class="Delimiter">,</span> <span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Comment">// test/not/mul/div</span> -<span id="L235" class="LineNr">235 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"ff"</span><span class="Delimiter">,</span> <span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Comment">// jump/push/call</span> +<span id="L232" class="LineNr">232 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"8f"</span><span class="Delimiter">,</span> <span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Comment">// pop</span> +<span id="L233" class="LineNr">233 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"d3"</span><span class="Delimiter">,</span> <span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Comment">// shift</span> +<span id="L234" class="LineNr">234 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"f7"</span><span class="Delimiter">,</span> <span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Comment">// test/not/mul/div</span> +<span id="L235" class="LineNr">235 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"ff"</span><span class="Delimiter">,</span> <span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Comment">// jump/push/call</span> <span id="L236" class="LineNr">236 </span> <span id="L237" class="LineNr">237 </span> <span class="SalientComment">//// Class O: op, ModR/M, subop (not r32) and imm8</span> <span id="L238" class="LineNr">238 </span> <span class="Comment">// imm32 imm8 disp32 |disp16 disp8 subop modrm</span> <span id="L239" class="LineNr">239 </span> <span class="Comment">// 0 1 0 |0 0 1 1</span> -<span id="L240" class="LineNr">240 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"c1"</span><span class="Delimiter">,</span> <span class="Constant">0x23</span><span class="Delimiter">);</span> <span class="Comment">// combine</span> -<span id="L241" class="LineNr">241 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"c6"</span><span class="Delimiter">,</span> <span class="Constant">0x23</span><span class="Delimiter">);</span> <span class="Comment">// copy</span> +<span id="L240" class="LineNr">240 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"c1"</span><span class="Delimiter">,</span> <span class="Constant">0x23</span><span class="Delimiter">);</span> <span class="Comment">// combine</span> +<span id="L241" class="LineNr">241 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"c6"</span><span class="Delimiter">,</span> <span class="Constant">0x23</span><span class="Delimiter">);</span> <span class="Comment">// copy</span> <span id="L242" class="LineNr">242 </span> <span id="L243" class="LineNr">243 </span> <span class="SalientComment">//// Class P: op, ModR/M, subop (not r32) and imm32</span> <span id="L244" class="LineNr">244 </span> <span class="Comment">// imm32 imm8 disp32 |disp16 disp8 subop modrm</span> <span id="L245" class="LineNr">245 </span> <span class="Comment">// 1 0 0 |0 0 1 1</span> -<span id="L246" class="LineNr">246 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"81"</span><span class="Delimiter">,</span> <span class="Constant">0x43</span><span class="Delimiter">);</span> <span class="Comment">// combine</span> -<span id="L247" class="LineNr">247 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"c7"</span><span class="Delimiter">,</span> <span class="Constant">0x43</span><span class="Delimiter">);</span> <span class="Comment">// copy</span> +<span id="L246" class="LineNr">246 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"81"</span><span class="Delimiter">,</span> <span class="Constant">0x43</span><span class="Delimiter">);</span> <span class="Comment">// combine</span> +<span id="L247" class="LineNr">247 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L99'>Permitted_operands</a></span><span class="Delimiter">,</span> <span class="Constant">"c7"</span><span class="Delimiter">,</span> <span class="Constant">0x43</span><span class="Delimiter">);</span> <span class="Comment">// copy</span> <span id="L248" class="LineNr">248 </span> <span id="L249" class="LineNr">249 </span> <span class="Comment">// End Init Permitted Operands</span> <span id="L250" class="LineNr">250 </span><span class="Delimiter">}</span> @@ -329,7 +329,7 @@ if ('onhashchange' in window) { <span id="L268" class="LineNr">268 </span><span class="Comment">//: Many instructions can be checked just by comparing bitvectors.</span> <span id="L269" class="LineNr">269 </span> <span id="L270" class="LineNr">270 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L270'>compare_bitvector</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">,</span> <span class="Normal">uint8_t</span> expected<span class="Delimiter">,</span> <span class="Normal">const</span> word& op<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L271" class="LineNr">271 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L429'>all_hex_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">)</span> && <a href='033check_operands.cc.html#L306'>has_operands</a><span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// deliberately programming in raw hex; we'll raise a warning elsewhere</span> +<span id="L271" class="LineNr">271 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L430'>all_hex_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">)</span> && <a href='033check_operands.cc.html#L306'>has_operands</a><span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// deliberately programming in raw hex; we'll raise a warning elsewhere</span> <span id="L272" class="LineNr">272 </span> <span class="Normal">uint8_t</span> bitvector = <a href='033check_operands.cc.html#L296'>compute_expected_operand_bitvector</a><span class="Delimiter">(</span>inst<span class="Delimiter">);</span> <span id="L273" class="LineNr">273 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// duplicate operand type</span> <span id="L274" class="LineNr">274 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>bitvector == expected<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// all good with this instruction</span> @@ -348,30 +348,30 @@ if ('onhashchange' in window) { <span id="L287" class="LineNr">287 </span> <span id="L288" class="LineNr">288 </span>string <a href='033check_operands.cc.html#L288'>maybe_name</a><span class="Delimiter">(</span><span class="Normal">const</span> word& op<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L289" class="LineNr">289 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_hex_byte<span class="Delimiter">(</span>op<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> -<span id="L290" class="LineNr">290 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> op<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> +<span id="L290" class="LineNr">290 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> op<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> <span id="L291" class="LineNr">291 </span> <span class="Comment">// strip stuff in parens from the name</span> -<span id="L292" class="LineNr">292 </span> <span class="Normal">const</span> string& s = get<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L348'>Name</a></span><span class="Delimiter">,</span> op<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L292" class="LineNr">292 </span> <span class="Normal">const</span> string& s = get<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L342'>Name</a></span><span class="Delimiter">,</span> op<span class="Delimiter">.</span>data<span class="Delimiter">);</span> <span id="L293" class="LineNr">293 </span> <span class="Identifier">return</span> <span class="Constant">" ("</span>+s<span class="Delimiter">.</span>substr<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> s<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">" ("</span><span class="Delimiter">))</span>+<span class="Constant">')'</span><span class="Delimiter">;</span> <span id="L294" class="LineNr">294 </span><span class="Delimiter">}</span> <span id="L295" class="LineNr">295 </span> <span id="L296" class="LineNr">296 </span><span class="Normal">uint32_t</span> <a href='033check_operands.cc.html#L296'>compute_expected_operand_bitvector</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L297" class="LineNr">297 </span> set<string> operands_found<span class="Delimiter">;</span> <span id="L298" class="LineNr">298 </span> <span class="Normal">uint32_t</span> bitvector = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L299" class="LineNr">299 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Comment">/*</span><span class="Comment">skip op</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L300" class="LineNr">300 </span> bitvector = bitvector | <a href='033check_operands.cc.html#L323'>expected_bit_for_received_operand</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> operands_found<span class="Delimiter">,</span> inst<span class="Delimiter">);</span> +<span id="L299" class="LineNr">299 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Comment">/*</span><span class="Comment">skip op</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L300" class="LineNr">300 </span> bitvector = bitvector | <a href='033check_operands.cc.html#L323'>expected_bit_for_received_operand</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> operands_found<span class="Delimiter">,</span> inst<span class="Delimiter">);</span> <span id="L301" class="LineNr">301 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span> <a href='033check_operands.cc.html#L100'>INVALID_OPERANDS</a><span class="Delimiter">;</span> <span class="Comment">// duplicate operand type</span> <span id="L302" class="LineNr">302 </span> <span class="Delimiter">}</span> <span id="L303" class="LineNr">303 </span> <span class="Identifier">return</span> bitvector<span class="Delimiter">;</span> <span id="L304" class="LineNr">304 </span><span class="Delimiter">}</span> <span id="L305" class="LineNr">305 </span> <span id="L306" class="LineNr">306 </span><span class="Normal">bool</span> <a href='033check_operands.cc.html#L306'>has_operands</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L307" class="LineNr">307 </span> <span class="Identifier">return</span> <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">)</span> > <a href='033check_operands.cc.html#L310'>first_operand</a><span class="Delimiter">(</span>inst<span class="Delimiter">);</span> +<span id="L307" class="LineNr">307 </span> <span class="Identifier">return</span> <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">)</span> > <a href='033check_operands.cc.html#L310'>first_operand</a><span class="Delimiter">(</span>inst<span class="Delimiter">);</span> <span id="L308" class="LineNr">308 </span><span class="Delimiter">}</span> <span id="L309" class="LineNr">309 </span> <span id="L310" class="LineNr">310 </span><span class="Normal">int</span> <a href='033check_operands.cc.html#L310'>first_operand</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L311" class="LineNr">311 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">2</span><span class="Delimiter">;</span> -<span id="L312" class="LineNr">312 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f2"</span> || inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f3"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L313" class="LineNr">313 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span><span class="Delimiter">)</span> +<span id="L311" class="LineNr">311 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">2</span><span class="Delimiter">;</span> +<span id="L312" class="LineNr">312 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f2"</span> || inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"f3"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L313" class="LineNr">313 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span><span class="Delimiter">)</span> <span id="L314" class="LineNr">314 </span> <span class="Identifier">return</span> <span class="Constant">3</span><span class="Delimiter">;</span> <span id="L315" class="LineNr">315 </span> <span class="Normal">else</span> <span id="L316" class="LineNr">316 </span> <span class="Identifier">return</span> <span class="Constant">2</span><span class="Delimiter">;</span> @@ -384,7 +384,7 @@ if ('onhashchange' in window) { <span id="L323" class="LineNr">323 </span><span class="Normal">uint32_t</span> <a href='033check_operands.cc.html#L323'>expected_bit_for_received_operand</a><span class="Delimiter">(</span><span class="Normal">const</span> word& w<span class="Delimiter">,</span> set<string>& instruction_operands<span class="Delimiter">,</span> <span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L324" class="LineNr">324 </span> <span class="Normal">uint32_t</span> bv = <span class="Constant">0</span><span class="Delimiter">;</span> <span id="L325" class="LineNr">325 </span> <span class="Normal">bool</span> found = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L326" class="LineNr">326 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L326" class="LineNr">326 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L327" class="LineNr">327 </span> string<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> curr = w<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span id="L328" class="LineNr">328 </span> string expected_metadata = curr<span class="Delimiter">;</span> <span id="L329" class="LineNr">329 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr == <span class="Constant">"mod"</span> || curr == <span class="Constant">"rm32"</span> || curr == <span class="Constant">"r32"</span> || curr == <span class="Constant">"scale"</span> || curr == <span class="Constant">"index"</span> || curr == <span class="Constant">"base"</span><span class="Delimiter">)</span> @@ -407,7 +407,7 @@ if ('onhashchange' in window) { <span id="L346" class="LineNr">346 </span> <span id="L347" class="LineNr">347 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L347'>test_conflicting_operand_type</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L348" class="LineNr">348 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L349" class="LineNr">349 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L349" class="LineNr">349 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L350" class="LineNr">350 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L351" class="LineNr">351 </span> <span class="Constant">"cd/software-interrupt 80/imm8/imm32\n"</span> <span id="L352" class="LineNr">352 </span> <span class="Delimiter">);</span> @@ -421,7 +421,7 @@ if ('onhashchange' in window) { <span id="L360" class="LineNr">360 </span> <span id="L361" class="LineNr">361 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L361'>test_check_missing_mod_operand</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L362" class="LineNr">362 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L363" class="LineNr">363 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L363" class="LineNr">363 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L364" class="LineNr">364 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L365" class="LineNr">365 </span> <span class="Constant">"81 0/add/subop 3/rm32/ebx 1/imm32\n"</span> <span id="L366" class="LineNr">366 </span> <span class="Delimiter">);</span> @@ -431,7 +431,7 @@ if ('onhashchange' in window) { <span id="L370" class="LineNr">370 </span><span class="Delimiter">}</span> <span id="L371" class="LineNr">371 </span> <span id="L372" class="LineNr">372 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L372'>check_operands_modrm</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">,</span> <span class="Normal">const</span> word& op<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L373" class="LineNr">373 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L429'>all_hex_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// deliberately programming in raw hex; we'll raise a warning elsewhere</span> +<span id="L373" class="LineNr">373 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L430'>all_hex_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// deliberately programming in raw hex; we'll raise a warning elsewhere</span> <span id="L374" class="LineNr">374 </span> <a href='033check_operands.cc.html#L432'>check_operand_metadata_present</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">,</span> op<span class="Delimiter">);</span> <span id="L375" class="LineNr">375 </span> <a href='033check_operands.cc.html#L432'>check_operand_metadata_present</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"rm32"</span><span class="Delimiter">,</span> op<span class="Delimiter">);</span> <span id="L376" class="LineNr">376 </span> <span class="Comment">// no check for r32; some instructions don't use it; just assume it's 0 if missing</span> @@ -442,7 +442,7 @@ if ('onhashchange' in window) { <span id="L381" class="LineNr">381 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L382" class="LineNr">382 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"rm32"</span><span class="Delimiter">).</span>data != <span class="Constant">"4"</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L383" class="LineNr">383 </span> <span class="Comment">// SIB byte checks</span> -<span id="L384" class="LineNr">384 </span> <span class="Normal">uint8_t</span> mod = <a href='011run.cc.html#L302'>hex_byte</a><span class="Delimiter">(</span>metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">).</span>data<span class="Delimiter">);</span> +<span id="L384" class="LineNr">384 </span> <span class="Normal">uint8_t</span> mod = <a href='011run.cc.html#L288'>hex_byte</a><span class="Delimiter">(</span>metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">).</span>data<span class="Delimiter">);</span> <span id="L385" class="LineNr">385 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>mod != <span class="Comment">/*</span><span class="Comment">direct</span><span class="Comment">*/</span><span class="Constant">3</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L386" class="LineNr">386 </span> <a href='033check_operands.cc.html#L432'>check_operand_metadata_present</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"base"</span><span class="Delimiter">,</span> op<span class="Delimiter">);</span> <span id="L387" class="LineNr">387 </span> <a href='033check_operands.cc.html#L432'>check_operand_metadata_present</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"index"</span><span class="Delimiter">,</span> op<span class="Delimiter">);</span> <span class="Comment">// otherwise why go to SIB?</span> @@ -457,15 +457,15 @@ if ('onhashchange' in window) { <span id="L396" class="LineNr">396 </span><span class="Comment">// same as compare_bitvector, with one additional exception for modrm-based</span> <span id="L397" class="LineNr">397 </span><span class="Comment">// instructions: they may use an extra displacement on occasion</span> <span id="L398" class="LineNr">398 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L398'>compare_bitvector_modrm</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">,</span> <span class="Normal">uint8_t</span> expected<span class="Delimiter">,</span> <span class="Normal">const</span> word& op<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L399" class="LineNr">399 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L429'>all_hex_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">)</span> && <a href='033check_operands.cc.html#L306'>has_operands</a><span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// deliberately programming in raw hex; we'll raise a warning elsewhere</span> +<span id="L399" class="LineNr">399 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L430'>all_hex_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">)</span> && <a href='033check_operands.cc.html#L306'>has_operands</a><span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// deliberately programming in raw hex; we'll raise a warning elsewhere</span> <span id="L400" class="LineNr">400 </span> <span class="Normal">uint8_t</span> bitvector = <a href='033check_operands.cc.html#L296'>compute_expected_operand_bitvector</a><span class="Delimiter">(</span>inst<span class="Delimiter">);</span> <span id="L401" class="LineNr">401 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// duplicate operand type</span> <span id="L402" class="LineNr">402 </span> <span class="Comment">// update 'expected' bitvector for the additional exception</span> <span id="L403" class="LineNr">403 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L404" class="LineNr">404 </span> <span class="Normal">int32_t</span> mod = <a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span>metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">).</span>data<span class="Delimiter">);</span> +<span id="L404" class="LineNr">404 </span> <span class="Normal">int32_t</span> mod = <a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span>metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">).</span>data<span class="Delimiter">);</span> <span id="L405" class="LineNr">405 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>mod<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L406" class="LineNr">406 </span> <span class="Normal">case</span> <span class="Constant">0</span>: -<span id="L407" class="LineNr">407 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"rm32"</span><span class="Delimiter">)</span> && <a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span>metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"rm32"</span><span class="Delimiter">).</span>data<span class="Delimiter">)</span> == <span class="Constant">5</span><span class="Delimiter">)</span> +<span id="L407" class="LineNr">407 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"rm32"</span><span class="Delimiter">)</span> && <a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span>metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"rm32"</span><span class="Delimiter">).</span>data<span class="Delimiter">)</span> == <span class="Constant">5</span><span class="Delimiter">)</span> <span id="L408" class="LineNr">408 </span> expected |= <span class="Delimiter">(</span><span class="Constant">1</span><<DISP32<span class="Delimiter">);</span> <span id="L409" class="LineNr">409 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L410" class="LineNr">410 </span> <span class="Normal">case</span> <span class="Constant">1</span>: @@ -501,7 +501,7 @@ if ('onhashchange' in window) { <span id="L440" class="LineNr">440 </span><span class="Delimiter">}</span> <span id="L441" class="LineNr">441 </span> <span id="L442" class="LineNr">442 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L442'>test_modrm_with_displacement</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L443" class="LineNr">443 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x1</span><span class="Delimiter">;</span> +<span id="L443" class="LineNr">443 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u = <span class="Constant">0x1</span><span class="Delimiter">;</span> <span id="L444" class="LineNr">444 </span> transform<span class="Delimiter">(</span> <span id="L445" class="LineNr">445 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L446" class="LineNr">446 </span> <span class="Comment">// just avoid null pointer</span> @@ -528,13 +528,13 @@ if ('onhashchange' in window) { <span id="L467" class="LineNr">467 </span> <span class="Constant">"8b/copy 0/mod/indirect 5/rm32/.disp32 2/r32/EDX\n"</span> <span class="Comment">// missing disp32</span> <span id="L468" class="LineNr">468 </span> <span class="Delimiter">);</span> <span id="L469" class="LineNr">469 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L470" class="LineNr">470 </span> <span class="Constant">"error: '8b/copy 0/mod/indirect 5/rm32/.disp32 2/r32/EDX' (copy rm32 to r32): missing <a href='040---tests.cc.html#L84'>disp32</a> operand\n"</span> +<span id="L470" class="LineNr">470 </span> <span class="Constant">"error: '8b/copy 0/mod/indirect 5/rm32/.disp32 2/r32/EDX' (copy rm32 to r32): missing <a href='040---tests.cc.html#L82'>disp32</a> operand\n"</span> <span id="L471" class="LineNr">471 </span> <span class="Delimiter">);</span> <span id="L472" class="LineNr">472 </span><span class="Delimiter">}</span> <span id="L473" class="LineNr">473 </span> <span id="L474" class="LineNr">474 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L474'>test_conflicting_operands_in_modrm_instruction</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L475" class="LineNr">475 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L476" class="LineNr">476 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L476" class="LineNr">476 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L477" class="LineNr">477 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L478" class="LineNr">478 </span> <span class="Constant">"01/add 0/mod 3/mod\n"</span> <span id="L479" class="LineNr">479 </span> <span class="Delimiter">);</span> @@ -545,7 +545,7 @@ if ('onhashchange' in window) { <span id="L484" class="LineNr">484 </span> <span id="L485" class="LineNr">485 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L485'>test_conflicting_operand_type_modrm</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L486" class="LineNr">486 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L487" class="LineNr">487 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L487" class="LineNr">487 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L488" class="LineNr">488 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L489" class="LineNr">489 </span> <span class="Constant">"01/add 0/mod 3/rm32/r32\n"</span> <span id="L490" class="LineNr">490 </span> <span class="Delimiter">);</span> @@ -556,7 +556,7 @@ if ('onhashchange' in window) { <span id="L495" class="LineNr">495 </span> <span id="L496" class="LineNr">496 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L496'>test_check_missing_rm32_operand</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L497" class="LineNr">497 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L498" class="LineNr">498 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L498" class="LineNr">498 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L499" class="LineNr">499 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L500" class="LineNr">500 </span> <span class="Constant">"81 0/add/subop 0/mod 1/imm32\n"</span> <span id="L501" class="LineNr">501 </span> <span class="Delimiter">);</span> @@ -567,7 +567,7 @@ if ('onhashchange' in window) { <span id="L506" class="LineNr">506 </span> <span id="L507" class="LineNr">507 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L507'>test_check_missing_subop_operand</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L508" class="LineNr">508 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L509" class="LineNr">509 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L509" class="LineNr">509 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L510" class="LineNr">510 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L511" class="LineNr">511 </span> <span class="Constant">"81 0/mod 3/rm32/ebx 1/imm32\n"</span> <span id="L512" class="LineNr">512 </span> <span class="Delimiter">);</span> @@ -578,7 +578,7 @@ if ('onhashchange' in window) { <span id="L517" class="LineNr">517 </span> <span id="L518" class="LineNr">518 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L518'>test_check_missing_base_operand</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L519" class="LineNr">519 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L520" class="LineNr">520 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L520" class="LineNr">520 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L521" class="LineNr">521 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L522" class="LineNr">522 </span> <span class="Constant">"81 0/add/subop 0/mod/indirect 4/rm32/use-sib 1/imm32\n"</span> <span id="L523" class="LineNr">523 </span> <span class="Delimiter">);</span> @@ -589,7 +589,7 @@ if ('onhashchange' in window) { <span id="L528" class="LineNr">528 </span> <span id="L529" class="LineNr">529 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L529'>test_check_missing_index_operand</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L530" class="LineNr">530 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L531" class="LineNr">531 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L531" class="LineNr">531 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L532" class="LineNr">532 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L533" class="LineNr">533 </span> <span class="Constant">"81 0/add/subop 0/mod/indirect 4/rm32/use-sib 0/base 1/imm32\n"</span> <span id="L534" class="LineNr">534 </span> <span class="Delimiter">);</span> @@ -600,7 +600,7 @@ if ('onhashchange' in window) { <span id="L539" class="LineNr">539 </span> <span id="L540" class="LineNr">540 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L540'>test_check_missing_base_operand_2</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L541" class="LineNr">541 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L542" class="LineNr">542 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L542" class="LineNr">542 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L543" class="LineNr">543 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L544" class="LineNr">544 </span> <span class="Constant">"81 0/add/subop 0/mod/indirect 4/rm32/use-sib 2/index 3/scale 1/imm32\n"</span> <span id="L545" class="LineNr">545 </span> <span class="Delimiter">);</span> @@ -611,7 +611,7 @@ if ('onhashchange' in window) { <span id="L550" class="LineNr">550 </span> <span id="L551" class="LineNr">551 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L551'>test_check_extra_displacement</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L552" class="LineNr">552 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L553" class="LineNr">553 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L553" class="LineNr">553 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L554" class="LineNr">554 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L555" class="LineNr">555 </span> <span class="Constant">"89/copy 0/mod/indirect 0/rm32/EAX 1/r32/ECX 4/disp8\n"</span> <span id="L556" class="LineNr">556 </span> <span class="Delimiter">);</span> @@ -622,7 +622,7 @@ if ('onhashchange' in window) { <span id="L561" class="LineNr">561 </span> <span id="L562" class="LineNr">562 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L562'>test_check_duplicate_operand</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L563" class="LineNr">563 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L564" class="LineNr">564 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L564" class="LineNr">564 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L565" class="LineNr">565 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L566" class="LineNr">566 </span> <span class="Constant">"89/copy 0/mod/indirect 0/rm32/EAX 1/r32/ECX 1/r32\n"</span> <span id="L567" class="LineNr">567 </span> <span class="Delimiter">);</span> @@ -632,7 +632,7 @@ if ('onhashchange' in window) { <span id="L571" class="LineNr">571 </span><span class="Delimiter">}</span> <span id="L572" class="LineNr">572 </span> <span id="L573" class="LineNr">573 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L573'>test_check_base_operand_not_needed_in_direct_mode</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L574" class="LineNr">574 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L574" class="LineNr">574 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L575" class="LineNr">575 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L576" class="LineNr">576 </span> <span class="Constant">"81 0/add/subop 3/mod/indirect 4/rm32/use-sib 1/imm32\n"</span> <span id="L577" class="LineNr">577 </span> <span class="Delimiter">);</span> @@ -641,25 +641,25 @@ if ('onhashchange' in window) { <span id="L580" class="LineNr">580 </span> <span id="L581" class="LineNr">581 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L581'>test_extra_modrm</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L582" class="LineNr">582 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L583" class="LineNr">583 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L583" class="LineNr">583 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L584" class="LineNr">584 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L585" class="LineNr">585 </span> <span class="Constant">"59/pop-to-ECX 3/mod/direct 1/rm32/ECX 4/r32/ESP\n"</span> <span id="L586" class="LineNr">586 </span> <span class="Delimiter">);</span> <span id="L587" class="LineNr">587 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L588" class="LineNr">588 </span> <span class="Constant">"error: '59/pop-to-ECX 3/mod/direct 1/rm32/ECX 4/r32/ESP' (<a href='013direct_addressing.cc.html#L1272'>pop</a> top of stack to <a href='010---vm.cc.html#L17'>ECX</a>): unexpected modrm operand\n"</span> +<span id="L588" class="LineNr">588 </span> <span class="Constant">"error: '59/pop-to-ECX 3/mod/direct 1/rm32/ECX 4/r32/ESP' (<a href='013direct_addressing.cc.html#L1272'>pop</a> top of stack to <a href='010---vm.cc.html#L11'>ECX</a>): unexpected modrm operand\n"</span> <span id="L589" class="LineNr">589 </span> <span class="Delimiter">);</span> <span id="L590" class="LineNr">590 </span><span class="Delimiter">}</span> <span id="L591" class="LineNr">591 </span> <span id="L592" class="LineNr">592 </span><span class="SalientComment">//:: similarly handle multi-byte opcodes</span> <span id="L593" class="LineNr">593 </span> <span id="L594" class="LineNr">594 </span><span class="Normal">void</span> check_operands_0f<span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L595" class="LineNr">595 </span> assert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span><span class="Delimiter">);</span> -<span id="L596" class="LineNr">596 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L595" class="LineNr">595 </span> assert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data == <span class="Constant">"0f"</span><span class="Delimiter">);</span> +<span id="L596" class="LineNr">596 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">)</span> == <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L597" class="LineNr">597 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"opcode '0f' requires a second opcode\n"</span> << end<span class="Delimiter">();</span> <span id="L598" class="LineNr">598 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L599" class="LineNr">599 </span> <span class="Delimiter">}</span> -<span id="L600" class="LineNr">600 </span> <a href='011run.cc.html#L128'>word</a> op = <a href='033check_operands.cc.html#L41'>preprocess_op</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">));</span> -<span id="L601" class="LineNr">601 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> op<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L600" class="LineNr">600 </span> <a href='011run.cc.html#L127'>word</a> op = <a href='033check_operands.cc.html#L41'>preprocess_op</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">));</span> +<span id="L601" class="LineNr">601 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> op<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L602" class="LineNr">602 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"unknown 2-byte opcode '0f "</span> << op<span class="Delimiter">.</span>data << <span class="Constant">"'\n"</span> << end<span class="Delimiter">();</span> <span id="L603" class="LineNr">603 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L604" class="LineNr">604 </span> <span class="Delimiter">}</span> @@ -672,12 +672,12 @@ if ('onhashchange' in window) { <span id="L611" class="LineNr">611 </span> <span id="L612" class="LineNr">612 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L612'>test_check_missing_disp32_operand</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L613" class="LineNr">613 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L614" class="LineNr">614 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L614" class="LineNr">614 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L615" class="LineNr">615 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L616" class="LineNr">616 </span> <span class="Constant">" 0f 84 # jmp if ZF to ??\n"</span> <span id="L617" class="LineNr">617 </span> <span class="Delimiter">);</span> <span id="L618" class="LineNr">618 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L619" class="LineNr">619 </span> <span class="Constant">"error: '0f 84' (jump <a href='040---tests.cc.html#L84'>disp32</a> bytes away if equal, if <a href='010---vm.cc.html#L86'>ZF</a> is set): missing <a href='040---tests.cc.html#L84'>disp32</a> operand\n"</span> +<span id="L619" class="LineNr">619 </span> <span class="Constant">"error: '0f 84' (jump <a href='040---tests.cc.html#L82'>disp32</a> bytes away if equal, if <a href='010---vm.cc.html#L80'>ZF</a> is set): missing <a href='040---tests.cc.html#L82'>disp32</a> operand\n"</span> <span id="L620" class="LineNr">620 </span> <span class="Delimiter">);</span> <span id="L621" class="LineNr">621 </span><span class="Delimiter">}</span> <span id="L622" class="LineNr">622 </span> @@ -687,21 +687,21 @@ if ('onhashchange' in window) { <span id="L626" class="LineNr">626 </span><span class="SalientComment">//// Class D: just op and disp32</span> <span id="L627" class="LineNr">627 </span><span class="Comment">// imm32 imm8 disp32 |disp16 disp8 subop modrm</span> <span id="L628" class="LineNr">628 </span><span class="Comment">// 0 0 1 |0 0 0 0</span> -<span id="L629" class="LineNr">629 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"82"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> -<span id="L630" class="LineNr">630 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"83"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> -<span id="L631" class="LineNr">631 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"84"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> -<span id="L632" class="LineNr">632 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"85"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> -<span id="L633" class="LineNr">633 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"86"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> -<span id="L634" class="LineNr">634 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"87"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> -<span id="L635" class="LineNr">635 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8c"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> -<span id="L636" class="LineNr">636 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8d"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> -<span id="L637" class="LineNr">637 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8e"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> -<span id="L638" class="LineNr">638 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8f"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L629" class="LineNr">629 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"82"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L630" class="LineNr">630 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"83"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L631" class="LineNr">631 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"84"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L632" class="LineNr">632 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"85"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L633" class="LineNr">633 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"86"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L634" class="LineNr">634 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"87"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L635" class="LineNr">635 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8c"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L636" class="LineNr">636 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8d"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L637" class="LineNr">637 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8e"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> +<span id="L638" class="LineNr">638 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"8f"</span><span class="Delimiter">,</span> <span class="Constant">0x10</span><span class="Delimiter">);</span> <span id="L639" class="LineNr">639 </span> <span id="L640" class="LineNr">640 </span><span class="SalientComment">//// Class M: using ModR/M byte</span> <span id="L641" class="LineNr">641 </span><span class="Comment">// imm32 imm8 disp32 |disp16 disp8 subop modrm</span> <span id="L642" class="LineNr">642 </span><span class="Comment">// 0 0 0 |0 0 0 1</span> -<span id="L643" class="LineNr">643 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"af"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> +<span id="L643" class="LineNr">643 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='033check_operands.cc.html#L624'>Permitted_operands_0f</a></span><span class="Delimiter">,</span> <span class="Constant">"af"</span><span class="Delimiter">,</span> <span class="Constant">0x01</span><span class="Delimiter">);</span> <span id="L644" class="LineNr">644 </span> <span id="L645" class="LineNr">645 </span><span class="Delimiter">:(code)</span> <span id="L646" class="LineNr">646 </span><span class="Normal">void</span> check_operands_0f<span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">,</span> <span class="Normal">const</span> word& op<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -712,7 +712,7 @@ if ('onhashchange' in window) { <span id="L651" class="LineNr">651 </span><span class="Delimiter">}</span> <span id="L652" class="LineNr">652 </span> <span id="L653" class="LineNr">653 </span><span class="Normal">void</span> <a href='033check_operands.cc.html#L653'>compare_bitvector_0f</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">,</span> <span class="Normal">uint8_t</span> expected<span class="Delimiter">,</span> <span class="Normal">const</span> word& op<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L654" class="LineNr">654 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L429'>all_hex_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">)</span> && <a href='033check_operands.cc.html#L306'>has_operands</a><span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// deliberately programming in raw hex; we'll raise a warning elsewhere</span> +<span id="L654" class="LineNr">654 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L430'>all_hex_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">)</span> && <a href='033check_operands.cc.html#L306'>has_operands</a><span class="Delimiter">(</span>inst<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// deliberately programming in raw hex; we'll raise a warning elsewhere</span> <span id="L655" class="LineNr">655 </span> <span class="Normal">uint8_t</span> bitvector = <a href='033check_operands.cc.html#L296'>compute_expected_operand_bitvector</a><span class="Delimiter">(</span>inst<span class="Delimiter">);</span> <span id="L656" class="LineNr">656 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// duplicate operand type</span> <span id="L657" class="LineNr">657 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>bitvector == expected<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// all good with this instruction</span> @@ -731,9 +731,9 @@ if ('onhashchange' in window) { <span id="L670" class="LineNr">670 </span> <span id="L671" class="LineNr">671 </span>string <a href='033check_operands.cc.html#L671'>maybe_name_0f</a><span class="Delimiter">(</span><span class="Normal">const</span> word& op<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L672" class="LineNr">672 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_hex_byte<span class="Delimiter">(</span>op<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> -<span id="L673" class="LineNr">673 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> op<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> +<span id="L673" class="LineNr">673 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> op<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> <span id="L674" class="LineNr">674 </span> <span class="Comment">// strip stuff in parens from the name</span> -<span id="L675" class="LineNr">675 </span> <span class="Normal">const</span> string& s = get<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L349'>Name_0f</a></span><span class="Delimiter">,</span> op<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L675" class="LineNr">675 </span> <span class="Normal">const</span> string& s = get<span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L343'>Name_0f</a></span><span class="Delimiter">,</span> op<span class="Delimiter">.</span>data<span class="Delimiter">);</span> <span id="L676" class="LineNr">676 </span> <span class="Identifier">return</span> <span class="Constant">" ("</span>+s<span class="Delimiter">.</span>substr<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> s<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">" ("</span><span class="Delimiter">))</span>+<span class="Constant">')'</span><span class="Delimiter">;</span> <span id="L677" class="LineNr">677 </span><span class="Delimiter">}</span> <span id="L678" class="LineNr">678 </span> diff --git a/html/034check_operand_bounds.cc.html b/html/034check_operand_bounds.cc.html index cc860053..4f97a676 100644 --- a/html/034check_operand_bounds.cc.html +++ b/html/034check_operand_bounds.cc.html @@ -62,7 +62,7 @@ if ('onhashchange' in window) { <span id="L2" class="LineNr"> 2 </span> <span id="L3" class="LineNr"> 3 </span><span class="Normal">void</span> <a href='034check_operand_bounds.cc.html#L3'>test_check_bitfield_sizes</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L4" class="LineNr"> 4 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L5" class="LineNr"> 5 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L5" class="LineNr"> 5 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L6" class="LineNr"> 6 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L7" class="LineNr"> 7 </span> <span class="Constant">"01/add 4/mod 3/rm32 1/r32\n"</span> <span class="Comment">// add ECX to EBX</span> <span id="L8" class="LineNr"> 8 </span> <span class="Delimiter">);</span> @@ -74,17 +74,17 @@ if ('onhashchange' in window) { <span id="L14" class="LineNr"> 14 </span><span class="Delimiter">:(before "End Globals")</span> <span id="L15" class="LineNr"> 15 </span>map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>> <span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">;</span> <span id="L16" class="LineNr"> 16 </span><span class="Delimiter">:(before "End One-time Setup")</span> -<span id="L17" class="LineNr"> 17 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"subop"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">3</span><span class="Delimiter">);</span> -<span id="L18" class="LineNr"> 18 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">2</span><span class="Delimiter">);</span> -<span id="L19" class="LineNr"> 19 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"rm32"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">3</span><span class="Delimiter">);</span> -<span id="L20" class="LineNr"> 20 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"base"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">3</span><span class="Delimiter">);</span> -<span id="L21" class="LineNr"> 21 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"index"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">3</span><span class="Delimiter">);</span> -<span id="L22" class="LineNr"> 22 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"scale"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">2</span><span class="Delimiter">);</span> -<span id="L23" class="LineNr"> 23 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"r32"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">3</span><span class="Delimiter">);</span> -<span id="L24" class="LineNr"> 24 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"disp8"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">8</span><span class="Delimiter">);</span> -<span id="L25" class="LineNr"> 25 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"disp16"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">16</span><span class="Delimiter">);</span> +<span id="L17" class="LineNr"> 17 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"subop"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">3</span><span class="Delimiter">);</span> +<span id="L18" class="LineNr"> 18 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">2</span><span class="Delimiter">);</span> +<span id="L19" class="LineNr"> 19 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"rm32"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">3</span><span class="Delimiter">);</span> +<span id="L20" class="LineNr"> 20 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"base"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">3</span><span class="Delimiter">);</span> +<span id="L21" class="LineNr"> 21 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"index"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">3</span><span class="Delimiter">);</span> +<span id="L22" class="LineNr"> 22 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"scale"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">2</span><span class="Delimiter">);</span> +<span id="L23" class="LineNr"> 23 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"r32"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">3</span><span class="Delimiter">);</span> +<span id="L24" class="LineNr"> 24 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"disp8"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">8</span><span class="Delimiter">);</span> +<span id="L25" class="LineNr"> 25 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"disp16"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">16</span><span class="Delimiter">);</span> <span id="L26" class="LineNr"> 26 </span><span class="Comment">// no bound needed for disp32</span> -<span id="L27" class="LineNr"> 27 </span><a href='001help.cc.html#L265'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"imm8"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">8</span><span class="Delimiter">);</span> +<span id="L27" class="LineNr"> 27 </span><a href='001help.cc.html#L239'>put_new</a><span class="Delimiter">(</span><span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">,</span> <span class="Constant">"imm8"</span><span class="Delimiter">,</span> <span class="Constant">1</span><<<span class="Constant">8</span><span class="Delimiter">);</span> <span id="L28" class="LineNr"> 28 </span><span class="Comment">// no bound needed for imm32</span> <span id="L29" class="LineNr"> 29 </span> <span id="L30" class="LineNr"> 30 </span><span class="Delimiter">:(before "Pack Operands(segment code)")</span> @@ -93,10 +93,10 @@ if ('onhashchange' in window) { <span id="L33" class="LineNr"> 33 </span><span class="Delimiter">:(code)</span> <span id="L34" class="LineNr"> 34 </span><span class="Normal">void</span> check_operand_bounds<span class="Delimiter">(</span><span class="Normal">const</span> segment& code<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L35" class="LineNr"> 35 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- check operand bounds"</span> << end<span class="Delimiter">();</span> -<span id="L36" class="LineNr"> 36 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L37" class="LineNr"> 37 </span> <span class="Normal">const</span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L38" class="LineNr"> 38 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <a href='033check_operands.cc.html#L310'>first_operand</a><span class="Delimiter">(</span>inst<span class="Delimiter">);</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> -<span id="L39" class="LineNr"> 39 </span> check_operand_bounds<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span> +<span id="L36" class="LineNr"> 36 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L37" class="LineNr"> 37 </span> <span class="Normal">const</span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L38" class="LineNr"> 38 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <a href='033check_operands.cc.html#L310'>first_operand</a><span class="Delimiter">(</span>inst<span class="Delimiter">);</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> +<span id="L39" class="LineNr"> 39 </span> check_operand_bounds<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span> <span id="L40" class="LineNr"> 40 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// stop at the first mal-formed instruction</span> <span id="L41" class="LineNr"> 41 </span> <span class="Delimiter">}</span> <span id="L42" class="LineNr"> 42 </span><span class="Delimiter">}</span> @@ -105,7 +105,7 @@ if ('onhashchange' in window) { <span id="L45" class="LineNr"> 45 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>>::iterator p = <span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='034check_operand_bounds.cc.html#L15'>Operand_bound</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L46" class="LineNr"> 46 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_operand_metadata<span class="Delimiter">(</span>w<span class="Delimiter">,</span> p<span class="Delimiter">-></span>first<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span id="L47" class="LineNr"> 47 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!looks_like_hex_int<span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// later transforms are on their own to do their own bounds checking</span> -<span id="L48" class="LineNr"> 48 </span> <span class="Normal">int32_t</span> x = <a href='032---operands.cc.html#L506'>parse_int</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L48" class="LineNr"> 48 </span> <span class="Normal">int32_t</span> x = <a href='032---operands.cc.html#L507'>parse_int</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>data<span class="Delimiter">);</span> <span id="L49" class="LineNr"> 49 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>x >= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L50" class="LineNr"> 50 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">-></span>first == <span class="Constant">"disp8"</span> || p<span class="Delimiter">-></span>first == <span class="Constant">"disp16"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L51" class="LineNr"> 51 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">uint32_t</span>><span class="Delimiter">(</span>x<span class="Delimiter">)</span> >= p<span class="Delimiter">-></span>second/<span class="Constant">2</span><span class="Delimiter">)</span> @@ -125,7 +125,7 @@ if ('onhashchange' in window) { <span id="L65" class="LineNr"> 65 </span><span class="Delimiter">}</span> <span id="L66" class="LineNr"> 66 </span> <span id="L67" class="LineNr"> 67 </span><span class="Normal">void</span> <a href='034check_operand_bounds.cc.html#L67'>test_check_bitfield_sizes_for_imm8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L68" class="LineNr"> 68 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L68" class="LineNr"> 68 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L69" class="LineNr"> 69 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L70" class="LineNr"> 70 </span> <span class="Constant">"c1/shift 4/subop/left 3/mod/direct 1/rm32/ECX 0xff/imm8"</span> <span class="Comment">// shift EBX left</span> <span id="L71" class="LineNr"> 71 </span> <span class="Delimiter">);</span> @@ -134,7 +134,7 @@ if ('onhashchange' in window) { <span id="L74" class="LineNr"> 74 </span> <span id="L75" class="LineNr"> 75 </span><span class="Normal">void</span> <a href='034check_operand_bounds.cc.html#L75'>test_check_bitfield_sizes_for_imm8_error</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L76" class="LineNr"> 76 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L77" class="LineNr"> 77 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L77" class="LineNr"> 77 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L78" class="LineNr"> 78 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L79" class="LineNr"> 79 </span> <span class="Constant">"c1/shift 4/subop/left 3/mod/direct 1/rm32/ECX 0x100/imm8"</span> <span class="Comment">// shift EBX left</span> <span id="L80" class="LineNr"> 80 </span> <span class="Delimiter">);</span> @@ -144,7 +144,7 @@ if ('onhashchange' in window) { <span id="L84" class="LineNr"> 84 </span><span class="Delimiter">}</span> <span id="L85" class="LineNr"> 85 </span> <span id="L86" class="LineNr"> 86 </span><span class="Normal">void</span> <a href='034check_operand_bounds.cc.html#L86'>test_check_bitfield_sizes_for_negative_imm8</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L87" class="LineNr"> 87 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L87" class="LineNr"> 87 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L88" class="LineNr"> 88 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L89" class="LineNr"> 89 </span> <span class="Constant">"c1/shift 4/subop/left 3/mod/direct 1/rm32/ECX -0x80/imm8"</span> <span class="Comment">// shift EBX left</span> <span id="L90" class="LineNr"> 90 </span> <span class="Delimiter">);</span> @@ -153,7 +153,7 @@ if ('onhashchange' in window) { <span id="L93" class="LineNr"> 93 </span> <span id="L94" class="LineNr"> 94 </span><span class="Normal">void</span> <a href='034check_operand_bounds.cc.html#L94'>test_check_bitfield_sizes_for_negative_imm8_error</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L95" class="LineNr"> 95 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L96" class="LineNr"> 96 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L96" class="LineNr"> 96 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L97" class="LineNr"> 97 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L98" class="LineNr"> 98 </span> <span class="Constant">"c1/shift 4/subop/left 3/mod/direct 1/rm32/ECX -0x81/imm8"</span> <span class="Comment">// shift EBX left</span> <span id="L99" class="LineNr"> 99 </span> <span class="Delimiter">);</span> @@ -173,7 +173,7 @@ if ('onhashchange' in window) { <span id="L113" class="LineNr">113 </span> <span id="L114" class="LineNr">114 </span><span class="Normal">void</span> <a href='034check_operand_bounds.cc.html#L114'>test_check_bitfield_sizes_for_disp8_error</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L115" class="LineNr">115 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L116" class="LineNr">116 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L116" class="LineNr">116 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L117" class="LineNr">117 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L118" class="LineNr">118 </span> <span class="Constant">"01/add 1/mod/*+disp8 3/rm32 1/r32 0x80/disp8\n"</span> <span class="Comment">// add ECX to *(EBX+0x80)</span> <span id="L119" class="LineNr">119 </span> <span class="Delimiter">);</span> @@ -193,7 +193,7 @@ if ('onhashchange' in window) { <span id="L133" class="LineNr">133 </span> <span id="L134" class="LineNr">134 </span><span class="Normal">void</span> <a href='034check_operand_bounds.cc.html#L134'>test_check_bitfield_sizes_for_negative_disp8_error</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L135" class="LineNr">135 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L136" class="LineNr">136 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L136" class="LineNr">136 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L137" class="LineNr">137 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L138" class="LineNr">138 </span> <span class="Constant">"01/add 1/mod/*+disp8 3/rm32 1/r32 -0x81/disp8\n"</span> <span class="Comment">// add ECX to *(EBX-0x81)</span> <span id="L139" class="LineNr">139 </span> <span class="Delimiter">);</span> diff --git a/html/035compute_segment_address.cc.html b/html/035compute_segment_address.cc.html index 6b151fd2..9204ba49 100644 --- a/html/035compute_segment_address.cc.html +++ b/html/035compute_segment_address.cc.html @@ -65,7 +65,7 @@ if ('onhashchange' in window) { <span id="L7" class="LineNr"> 7 </span><span class="Comment">//: This gives up a measure of control in placing code and data.</span> <span id="L8" class="LineNr"> 8 </span> <span id="L9" class="LineNr"> 9 </span><span class="Normal">void</span> <a href='035compute_segment_address.cc.html#L9'>test_segment_name</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L10" class="LineNr">10 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L10" class="LineNr">10 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L11" class="LineNr">11 </span> <span class="Constant">"== code 0x09000000\n"</span> <span id="L12" class="LineNr">12 </span> <span class="Constant">"05/add-to-EAX 0x0d0c0b0a/imm32\n"</span> <span id="L13" class="LineNr">13 </span> <span class="Comment">// code starts at 0x09000000 + p_offset, which is 0x54 for a single-segment binary</span> @@ -83,38 +83,38 @@ if ('onhashchange' in window) { <span id="L25" class="LineNr">25 </span> <span id="L26" class="LineNr">26 </span><span class="Comment">//: compute segment address</span> <span id="L27" class="LineNr">27 </span> -<span id="L28" class="LineNr">28 </span><span class="Delimiter">:(before "End Level-2 Transforms")</span> -<span id="L29" class="LineNr">29 </span><span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='035compute_segment_address.cc.html#L32'>compute_segment_starts</a><span class="Delimiter">);</span> +<span id="L28" class="LineNr">28 </span><span class="Delimiter">:(before "End Transforms")</span> +<span id="L29" class="LineNr">29 </span><span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='035compute_segment_address.cc.html#L32'>compute_segment_starts</a><span class="Delimiter">);</span> <span id="L30" class="LineNr">30 </span> <span id="L31" class="LineNr">31 </span><span class="Delimiter">:(code)</span> <span id="L32" class="LineNr">32 </span><span class="Normal">void</span> <a href='035compute_segment_address.cc.html#L32'>compute_segment_starts</a><span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L33" class="LineNr">33 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- compute segment addresses"</span> << end<span class="Delimiter">();</span> -<span id="L34" class="LineNr">34 </span> <span class="Normal">uint32_t</span> p_offset = <span class="Comment">/*</span><span class="Comment">size of ehdr</span><span class="Comment">*/</span><span class="Constant">0x34</span> + <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">)</span>*<span class="Constant">0x20</span><span class="Comment">/*</span><span class="Comment">size of each phdr</span><span class="Comment">*/</span><span class="Delimiter">;</span> -<span id="L35" class="LineNr">35 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L36" class="LineNr">36 </span> segment& curr = p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L34" class="LineNr">34 </span> <span class="Normal">uint32_t</span> p_offset = <span class="Comment">/*</span><span class="Comment">size of ehdr</span><span class="Comment">*/</span><span class="Constant">0x34</span> + <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">)</span>*<span class="Constant">0x20</span><span class="Comment">/*</span><span class="Comment">size of each phdr</span><span class="Comment">*/</span><span class="Delimiter">;</span> +<span id="L35" class="LineNr">35 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L36" class="LineNr">36 </span> segment& curr = p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span id="L37" class="LineNr">37 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>start >= <span class="Constant">0x08000000</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L38" class="LineNr">38 </span> <span class="Comment">// valid address for user space, so assume we're creating a real ELF binary, not just running a test</span> <span id="L39" class="LineNr">39 </span> curr<span class="Delimiter">.</span>start &= <span class="Constant">0xfffff000</span><span class="Delimiter">;</span> <span class="Comment">// same number of zeros as the p_align used when emitting the ELF binary</span> <span id="L40" class="LineNr">40 </span> curr<span class="Delimiter">.</span>start |= <span class="Delimiter">(</span>p_offset & <span class="Constant">0xfff</span><span class="Delimiter">);</span> -<span id="L41" class="LineNr">41 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"segment "</span> << i << <span class="Constant">" begins at address 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << curr<span class="Delimiter">.</span>start << end<span class="Delimiter">();</span> +<span id="L41" class="LineNr">41 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"segment "</span> << i << <span class="Constant">" begins at address 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << curr<span class="Delimiter">.</span>start << end<span class="Delimiter">();</span> <span id="L42" class="LineNr">42 </span> <span class="Delimiter">}</span> <span id="L43" class="LineNr">43 </span> p_offset += size_of<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> -<span id="L44" class="LineNr">44 </span> assert<span class="Delimiter">(</span>p_offset < <a href='010---vm.cc.html#L95'>SEGMENT_ALIGNMENT</a><span class="Delimiter">);</span> <span class="Comment">// for now we get less and less available space in each successive segment</span> +<span id="L44" class="LineNr">44 </span> assert<span class="Delimiter">(</span>p_offset < <a href='010---vm.cc.html#L89'>SEGMENT_ALIGNMENT</a><span class="Delimiter">);</span> <span class="Comment">// for now we get less and less available space in each successive segment</span> <span id="L45" class="LineNr">45 </span> <span class="Delimiter">}</span> <span id="L46" class="LineNr">46 </span><span class="Delimiter">}</span> <span id="L47" class="LineNr">47 </span> <span id="L48" class="LineNr">48 </span><span class="Normal">uint32_t</span> size_of<span class="Delimiter">(</span><span class="Normal">const</span> segment& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L49" class="LineNr">49 </span> <span class="Normal">uint32_t</span> sum = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L50" class="LineNr">50 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L51" class="LineNr">51 </span> sum += <a href='035compute_segment_address.cc.html#L56'>num_bytes</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> +<span id="L50" class="LineNr">50 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L51" class="LineNr">51 </span> sum += <a href='035compute_segment_address.cc.html#L56'>num_bytes</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span id="L52" class="LineNr">52 </span> <span class="Identifier">return</span> sum<span class="Delimiter">;</span> <span id="L53" class="LineNr">53 </span><span class="Delimiter">}</span> <span id="L54" class="LineNr">54 </span> <span id="L55" class="LineNr">55 </span><span class="Comment">// Assumes all bitfields are packed.</span> <span id="L56" class="LineNr">56 </span><span class="Normal">uint32_t</span> <a href='035compute_segment_address.cc.html#L56'>num_bytes</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L57" class="LineNr">57 </span> <span class="Normal">uint32_t</span> sum = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L58" class="LineNr">58 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> -<span id="L59" class="LineNr">59 </span> sum += size_of<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> +<span id="L58" class="LineNr">58 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L59" class="LineNr">59 </span> sum += size_of<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span id="L60" class="LineNr">60 </span> <span class="Identifier">return</span> sum<span class="Delimiter">;</span> <span id="L61" class="LineNr">61 </span><span class="Delimiter">}</span> <span id="L62" class="LineNr">62 </span> diff --git a/html/036labels.cc.html b/html/036labels.cc.html index ccf0ae1a..96657216 100644 --- a/html/036labels.cc.html +++ b/html/036labels.cc.html @@ -84,7 +84,7 @@ if ('onhashchange' in window) { <span id="L25" class="LineNr"> 25 </span><span class="Comment">//: programs.</span> <span id="L26" class="LineNr"> 26 </span> <span id="L27" class="LineNr"> 27 </span><span class="Normal">void</span> <a href='036labels.cc.html#L27'>test_Entry_label</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L28" class="LineNr"> 28 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L28" class="LineNr"> 28 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L29" class="LineNr"> 29 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L30" class="LineNr"> 30 </span> <span class="Constant">"05 0x0d0c0b0a/imm32\n"</span> <span id="L31" class="LineNr"> 31 </span> <span class="Constant">"Entry:\n"</span> @@ -96,8 +96,8 @@ if ('onhashchange' in window) { <span id="L37" class="LineNr"> 37 </span> <a href='003trace.cc.html#L294'>CHECK_TRACE_DOESNT_CONTAIN</a><span class="Delimiter">(</span><span class="Constant">"run: 0x00000001 opcode: 05"</span><span class="Delimiter">);</span> <span id="L38" class="LineNr"> 38 </span><span class="Delimiter">}</span> <span id="L39" class="LineNr"> 39 </span> -<span id="L40" class="LineNr"> 40 </span><span class="Delimiter">:(before "End <a href='032---operands.cc.html#L489'>looks_like_hex_int</a>(s) Detectors")</span> -<span id="L41" class="LineNr"> 41 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">)</span> == <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L40" class="LineNr"> 40 </span><span class="Delimiter">:(before "End <a href='032---operands.cc.html#L490'>looks_like_hex_int</a>(s) Detectors")</span> +<span id="L41" class="LineNr"> 41 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">)</span> == <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L42" class="LineNr"> 42 </span> <span id="L43" class="LineNr"> 43 </span><span class="Delimiter">:(code)</span> <span id="L44" class="LineNr"> 44 </span><span class="Normal">void</span> <a href='036labels.cc.html#L44'>test_pack_immediate_ignores_single_byte_nondigit_operand</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> @@ -153,7 +153,7 @@ if ('onhashchange' in window) { <span id="L94" class="LineNr"> 94 </span> <span class="Delimiter">}</span> <span id="L95" class="LineNr"> 95 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>isdigit<span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span id="L96" class="LineNr"> 96 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << s << <span class="Constant">"' starts with a digit, and so can be confused with a number; use a different name.\n"</span> << end<span class="Delimiter">();</span> -<span id="L97" class="LineNr"> 97 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">)</span> == <span class="Constant">2</span><span class="Delimiter">)</span> +<span id="L97" class="LineNr"> 97 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">)</span> == <span class="Constant">2</span><span class="Delimiter">)</span> <span id="L98" class="LineNr"> 98 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << s << <span class="Constant">"' is two characters long, which can look like raw hex bytes at a glance; use a different name\n"</span> << end<span class="Delimiter">();</span> <span id="L99" class="LineNr"> 99 </span><span class="Delimiter">}</span> <span id="L100" class="LineNr">100 </span> @@ -170,12 +170,12 @@ if ('onhashchange' in window) { <span id="L111" class="LineNr">111 </span> <span class="Delimiter">);</span> <span id="L112" class="LineNr">112 </span><span class="Delimiter">}</span> <span id="L113" class="LineNr">113 </span> -<span id="L114" class="LineNr">114 </span><span class="Delimiter">:(before "End Level-2 Transforms")</span> -<span id="L115" class="LineNr">115 </span><span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='036labels.cc.html#L117'>rewrite_labels</a><span class="Delimiter">);</span> +<span id="L114" class="LineNr">114 </span><span class="Delimiter">:(before "End Transforms")</span> +<span id="L115" class="LineNr">115 </span><span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='036labels.cc.html#L117'>rewrite_labels</a><span class="Delimiter">);</span> <span id="L116" class="LineNr">116 </span><span class="Delimiter">:(code)</span> <span id="L117" class="LineNr">117 </span><span class="Normal">void</span> <a href='036labels.cc.html#L117'>rewrite_labels</a><span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L118" class="LineNr">118 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- rewrite labels"</span> << end<span class="Delimiter">();</span> -<span id="L119" class="LineNr">119 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L119" class="LineNr">119 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L120" class="LineNr">120 </span> segment& code = *find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">);</span> <span id="L121" class="LineNr">121 </span> map<string<span class="Delimiter">,</span> <span class="Normal">int32_t</span>> byte_index<span class="Delimiter">;</span> <span class="Comment">// values are unsigned, but we're going to do subtractions on them so they need to fit in 31 bits</span> <span id="L122" class="LineNr">122 </span> <a href='036labels.cc.html#L131'>compute_byte_indices_for_labels</a><span class="Delimiter">(</span>code<span class="Delimiter">,</span> byte_index<span class="Delimiter">);</span> @@ -183,18 +183,18 @@ if ('onhashchange' in window) { <span id="L124" class="LineNr">124 </span> <a href='036labels.cc.html#L205'>drop_labels</a><span class="Delimiter">(</span>code<span class="Delimiter">);</span> <span id="L125" class="LineNr">125 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L126" class="LineNr">126 </span> <a href='036labels.cc.html#L217'>replace_labels_with_displacements</a><span class="Delimiter">(</span>code<span class="Delimiter">,</span> byte_index<span class="Delimiter">);</span> -<span id="L127" class="LineNr">127 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> <span class="Constant">"Entry"</span><span class="Delimiter">))</span> -<span id="L128" class="LineNr">128 </span> p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>entry</a> = code<span class="Delimiter">.</span>start + get<span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> <span class="Constant">"Entry"</span><span class="Delimiter">);</span> +<span id="L127" class="LineNr">127 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> <span class="Constant">"Entry"</span><span class="Delimiter">))</span> +<span id="L128" class="LineNr">128 </span> p<span class="Delimiter">.</span><a href='011run.cc.html#L105'>entry</a> = code<span class="Delimiter">.</span>start + get<span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> <span class="Constant">"Entry"</span><span class="Delimiter">);</span> <span id="L129" class="LineNr">129 </span><span class="Delimiter">}</span> <span id="L130" class="LineNr">130 </span> <span id="L131" class="LineNr">131 </span><span class="Normal">void</span> <a href='036labels.cc.html#L131'>compute_byte_indices_for_labels</a><span class="Delimiter">(</span><span class="Normal">const</span> segment& code<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> <span class="Normal">int32_t</span>>& byte_index<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L132" class="LineNr">132 </span> <span class="Normal">int</span> current_byte = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L133" class="LineNr">133 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L134" class="LineNr">134 </span> <span class="Normal">const</span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L135" class="LineNr">135 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span><span class="Delimiter">.</span>is_open<span class="Delimiter">()</span> && !inst<span class="Delimiter">.</span>original<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && <span class="Comment">/*</span><span class="Comment">not a label</span><span class="Comment">*/</span> *inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> != <span class="Constant">':'</span><span class="Delimiter">)</span> -<span id="L136" class="LineNr">136 </span> <span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Delimiter">(</span>code<span class="Delimiter">.</span>start + current_byte<span class="Delimiter">)</span> << <span class="Constant">' '</span> << inst<span class="Delimiter">.</span>original << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L137" class="LineNr">137 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L138" class="LineNr">138 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L133" class="LineNr">133 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L134" class="LineNr">134 </span> <span class="Normal">const</span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L135" class="LineNr">135 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span><span class="Delimiter">.</span>is_open<span class="Delimiter">()</span> && !inst<span class="Delimiter">.</span>original<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && <span class="Comment">/*</span><span class="Comment">not a label</span><span class="Comment">*/</span> *inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> != <span class="Constant">':'</span><span class="Delimiter">)</span> +<span id="L136" class="LineNr">136 </span> <span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Delimiter">(</span>code<span class="Delimiter">.</span>start + current_byte<span class="Delimiter">)</span> << <span class="Constant">' '</span> << inst<span class="Delimiter">.</span>original << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L137" class="LineNr">137 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L138" class="LineNr">138 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> <span id="L139" class="LineNr">139 </span> <span class="Comment">// hack: if we have any operand metadata left after previous transforms,</span> <span id="L140" class="LineNr">140 </span> <span class="Comment">// deduce its size</span> <span id="L141" class="LineNr">141 </span> <span class="Comment">// Maybe we should just move this transform to before instruction</span> @@ -219,17 +219,17 @@ if ('onhashchange' in window) { <span id="L160" class="LineNr">160 </span> <span class="Comment">// ensure labels look sufficiently different from raw hex</span> <span id="L161" class="LineNr">161 </span> <a href='036labels.cc.html#L84'>check_valid_name</a><span class="Delimiter">(</span>label<span class="Delimiter">);</span> <span id="L162" class="LineNr">162 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L163" class="LineNr">163 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L446'>contains_any_operand_metadata</a><span class="Delimiter">(</span>curr<span class="Delimiter">))</span> +<span id="L163" class="LineNr">163 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L447'>contains_any_operand_metadata</a><span class="Delimiter">(</span>curr<span class="Delimiter">))</span> <span id="L164" class="LineNr">164 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"': label definition (':') not allowed in operand\n"</span> << end<span class="Delimiter">();</span> <span id="L165" class="LineNr">165 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>j > <span class="Constant">0</span><span class="Delimiter">)</span> -<span id="L166" class="LineNr">166 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"': labels can only be the first <a href='011run.cc.html#L128'>word</a> in a line.\n"</span> << end<span class="Delimiter">();</span> +<span id="L166" class="LineNr">166 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"': labels can only be the first <a href='011run.cc.html#L127'>word</a> in a line.\n"</span> << end<span class="Delimiter">();</span> <span id="L167" class="LineNr">167 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span><span class="Delimiter">.</span>is_open<span class="Delimiter">())</span> -<span id="L168" class="LineNr">168 </span> <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Delimiter">(</span>code<span class="Delimiter">.</span>start + current_byte<span class="Delimiter">)</span> << <span class="Constant">' '</span> << label << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L169" class="LineNr">169 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> label<span class="Delimiter">)</span> && label != <span class="Constant">"Entry"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L168" class="LineNr">168 </span> <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Delimiter">(</span>code<span class="Delimiter">.</span>start + current_byte<span class="Delimiter">)</span> << <span class="Constant">' '</span> << label << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L169" class="LineNr">169 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> label<span class="Delimiter">)</span> && label != <span class="Constant">"Entry"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L170" class="LineNr">170 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"duplicate label '"</span> << label << <span class="Constant">"'\n"</span> << end<span class="Delimiter">();</span> <span id="L171" class="LineNr">171 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L172" class="LineNr">172 </span> <span class="Delimiter">}</span> -<span id="L173" class="LineNr">173 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> label<span class="Delimiter">,</span> current_byte<span class="Delimiter">);</span> +<span id="L173" class="LineNr">173 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> label<span class="Delimiter">,</span> current_byte<span class="Delimiter">);</span> <span id="L174" class="LineNr">174 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"label '"</span> << label << <span class="Constant">"' is at address "</span> << <span class="Delimiter">(</span>current_byte+code<span class="Delimiter">.</span>start<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L175" class="LineNr">175 </span> <span class="Comment">// no modifying current_byte; label definitions won't be in the final binary</span> <span id="L176" class="LineNr">176 </span> <span class="Delimiter">}</span> @@ -238,23 +238,23 @@ if ('onhashchange' in window) { <span id="L179" class="LineNr">179 </span><span class="Delimiter">}</span> <span id="L180" class="LineNr">180 </span> <span id="L181" class="LineNr">181 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L182" class="LineNr">182 </span><span class="Normal">bool</span> <span class="Special"><a href='036labels.cc.html#L182'>Dump_debug_info</a></span> = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// currently used only by 'subx translate'</span> +<span id="L182" class="LineNr">182 </span><span class="Normal">bool</span> <span class="Special"><a href='036labels.cc.html#L182'>Dump_debug_info</a></span> = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// currently used only by 'bootstrap translate'</span> <span id="L183" class="LineNr">183 </span>ofstream <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span><span class="Delimiter">;</span> <span id="L184" class="LineNr">184 </span>ofstream <span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span><span class="Delimiter">;</span> <span id="L185" class="LineNr">185 </span><span class="Delimiter">:(before "End Commandline Options")</span> -<span id="L186" class="LineNr">186 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L101'>is_equal</a><span class="Delimiter">(</span>*arg<span class="Delimiter">,</span> <span class="Constant">"--debug"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L186" class="LineNr">186 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L102'>is_equal</a><span class="Delimiter">(</span>*arg<span class="Delimiter">,</span> <span class="Constant">"--debug"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L187" class="LineNr">187 </span> <span class="Special"><a href='036labels.cc.html#L182'>Dump_debug_info</a></span> = <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L188" class="LineNr">188 </span> <span class="Comment">// End --debug Settings</span> <span id="L189" class="LineNr">189 </span><span class="Delimiter">}</span> <span id="L190" class="LineNr">190 </span><span class="Comment">//: wait to open "labels" for writing until we're sure we aren't trying to read it</span> -<span id="L191" class="LineNr">191 </span><span class="Delimiter">:(after "Begin subx translate")</span> +<span id="L191" class="LineNr">191 </span><span class="Delimiter">:(after "Begin bootstrap translate")</span> <span id="L192" class="LineNr">192 </span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L182'>Dump_debug_info</a></span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L193" class="LineNr">193 </span> cerr << <span class="Constant">"saving address->label information to 'labels'\n"</span><span class="Delimiter">;</span> <span id="L194" class="LineNr">194 </span> <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span><span class="Delimiter">.</span>open<span class="Delimiter">(</span><span class="Constant">"labels"</span><span class="Delimiter">);</span> <span id="L195" class="LineNr">195 </span> cerr << <span class="Constant">"saving address->source information to 'source_lines'\n"</span><span class="Delimiter">;</span> <span id="L196" class="LineNr">196 </span> <span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span><span class="Delimiter">.</span>open<span class="Delimiter">(</span><span class="Constant">"source_lines"</span><span class="Delimiter">);</span> <span id="L197" class="LineNr">197 </span><span class="Delimiter">}</span> -<span id="L198" class="LineNr">198 </span><span class="Delimiter">:(before "End subx translate")</span> +<span id="L198" class="LineNr">198 </span><span class="Delimiter">:(before "End bootstrap translate")</span> <span id="L199" class="LineNr">199 </span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L182'>Dump_debug_info</a></span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L200" class="LineNr">200 </span> <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span><span class="Delimiter">.</span>close<span class="Delimiter">();</span> <span id="L201" class="LineNr">201 </span> <span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span><span class="Delimiter">.</span>close<span class="Delimiter">();</span> @@ -262,10 +262,10 @@ if ('onhashchange' in window) { <span id="L203" class="LineNr">203 </span> <span id="L204" class="LineNr">204 </span><span class="Delimiter">:(code)</span> <span id="L205" class="LineNr">205 </span><span class="Normal">void</span> <a href='036labels.cc.html#L205'>drop_labels</a><span class="Delimiter">(</span>segment& code<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L206" class="LineNr">206 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L207" class="LineNr">207 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L208" class="LineNr">208 </span> vector<word>::iterator new_end = remove_if<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>end<span class="Delimiter">(),</span> <a href='036labels.cc.html#L213'>is_label</a><span class="Delimiter">);</span> -<span id="L209" class="LineNr">209 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>erase<span class="Delimiter">(</span>new_end<span class="Delimiter">,</span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>end<span class="Delimiter">());</span> +<span id="L206" class="LineNr">206 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L207" class="LineNr">207 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L208" class="LineNr">208 </span> vector<word>::iterator new_end = remove_if<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>end<span class="Delimiter">(),</span> <a href='036labels.cc.html#L213'>is_label</a><span class="Delimiter">);</span> +<span id="L209" class="LineNr">209 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>erase<span class="Delimiter">(</span>new_end<span class="Delimiter">,</span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>end<span class="Delimiter">());</span> <span id="L210" class="LineNr">210 </span> <span class="Delimiter">}</span> <span id="L211" class="LineNr">211 </span><span class="Delimiter">}</span> <span id="L212" class="LineNr">212 </span> @@ -275,13 +275,13 @@ if ('onhashchange' in window) { <span id="L216" class="LineNr">216 </span> <span id="L217" class="LineNr">217 </span><span class="Normal">void</span> <a href='036labels.cc.html#L217'>replace_labels_with_displacements</a><span class="Delimiter">(</span>segment& code<span class="Delimiter">,</span> <span class="Normal">const</span> map<string<span class="Delimiter">,</span> <span class="Normal">int32_t</span>>& byte_index<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L218" class="LineNr">218 </span> <span class="Normal">int32_t</span> byte_index_next_instruction_starts_at = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L219" class="LineNr">219 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L220" class="LineNr">220 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L219" class="LineNr">219 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L220" class="LineNr">220 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span id="L221" class="LineNr">221 </span> byte_index_next_instruction_starts_at += <a href='035compute_segment_address.cc.html#L56'>num_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">);</span> -<span id="L222" class="LineNr">222 </span> <a href='011run.cc.html#L122'>line</a> new_inst<span class="Delimiter">;</span> -<span id="L223" class="LineNr">223 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L224" class="LineNr">224 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> -<span id="L225" class="LineNr">225 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L222" class="LineNr">222 </span> <a href='011run.cc.html#L121'>line</a> new_inst<span class="Delimiter">;</span> +<span id="L223" class="LineNr">223 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L224" class="LineNr">224 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L225" class="LineNr">225 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L226" class="LineNr">226 </span> <span class="Normal">int32_t</span> displacement = <span class="Normal">static_cast</span><<span class="Normal">int32_t</span>><span class="Delimiter">(</span>get<span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> - byte_index_next_instruction_starts_at<span class="Delimiter">;</span> <span id="L227" class="LineNr">227 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"disp8"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L228" class="LineNr">228 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>displacement > <span class="Constant">0x7f</span> || displacement < -<span class="Constant">0x7f</span><span class="Delimiter">)</span> @@ -302,19 +302,19 @@ if ('onhashchange' in window) { <span id="L243" class="LineNr">243 </span> <span class="Delimiter">}</span> <span id="L244" class="LineNr">244 </span> <span class="Delimiter">}</span> <span id="L245" class="LineNr">245 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L246" class="LineNr">246 </span> new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> +<span id="L246" class="LineNr">246 </span> new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> <span id="L247" class="LineNr">247 </span> <span class="Delimiter">}</span> <span id="L248" class="LineNr">248 </span> <span class="Delimiter">}</span> -<span id="L249" class="LineNr">249 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> +<span id="L249" class="LineNr">249 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> <span id="L250" class="LineNr">250 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"instruction after transform: '"</span> << data_to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> <span id="L251" class="LineNr">251 </span> <span class="Delimiter">}</span> <span id="L252" class="LineNr">252 </span><span class="Delimiter">}</span> <span id="L253" class="LineNr">253 </span> <span id="L254" class="LineNr">254 </span>string <a href='036labels.cc.html#L254'>data_to_string</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L255" class="LineNr">255 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L256" class="LineNr">256 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L256" class="LineNr">256 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L257" class="LineNr">257 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L258" class="LineNr">258 </span> out << inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">;</span> +<span id="L258" class="LineNr">258 </span> out << inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">;</span> <span id="L259" class="LineNr">259 </span> <span class="Delimiter">}</span> <span id="L260" class="LineNr">260 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span id="L261" class="LineNr">261 </span><span class="Delimiter">}</span> @@ -432,7 +432,7 @@ if ('onhashchange' in window) { <span id="L373" class="LineNr">373 </span><span class="Delimiter">}</span> <span id="L374" class="LineNr">374 </span> <span id="L375" class="LineNr">375 </span><span class="Comment">// This test could do with some refactoring.</span> -<span id="L376" class="LineNr">376 </span><span class="Comment">// We're duplicating the flow inside `subx translate`, but without</span> +<span id="L376" class="LineNr">376 </span><span class="Comment">// We're duplicating the flow inside `bootstrap translate`, but without</span> <span id="L377" class="LineNr">377 </span><span class="Comment">// reading/writing files.</span> <span id="L378" class="LineNr">378 </span><span class="Comment">// We can't just use run(string) because most of our tests allow programs</span> <span id="L379" class="LineNr">379 </span><span class="Comment">// without 'Entry' labels, as a convenience.</span> @@ -470,7 +470,7 @@ if ('onhashchange' in window) { <span id="L411" class="LineNr">411 </span> <span class="Delimiter">);</span> <span id="L412" class="LineNr">412 </span><span class="Delimiter">}</span> <span id="L413" class="LineNr">413 </span> -<span id="L414" class="LineNr">414 </span><span class="Delimiter">:(before "End size_of(<a href='011run.cc.html#L128'>word</a> w) Special-cases")</span> +<span id="L414" class="LineNr">414 </span><span class="Delimiter">:(before "End size_of(<a href='011run.cc.html#L127'>word</a> w) Special-cases")</span> <span id="L415" class="LineNr">415 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='036labels.cc.html#L213'>is_label</a><span class="Delimiter">(</span>w<span class="Delimiter">))</span> <span id="L416" class="LineNr">416 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> </pre> diff --git a/html/037global_variables.cc.html b/html/037global_variables.cc.html index 3ac86f25..eefe9f03 100644 --- a/html/037global_variables.cc.html +++ b/html/037global_variables.cc.html @@ -69,7 +69,7 @@ if ('onhashchange' in window) { <span id="L8" class="LineNr"> 8 </span> <span id="L9" class="LineNr"> 9 </span><span class="Delimiter">:(code)</span> <span id="L10" class="LineNr"> 10 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L10'>test_global_variable</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L11" class="LineNr"> 11 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L11" class="LineNr"> 11 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L12" class="LineNr"> 12 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L13" class="LineNr"> 13 </span> <span class="Constant">"b9 x/imm32\n"</span> <span id="L14" class="LineNr"> 14 </span> <span class="Constant">"== data 0x2000\n"</span> @@ -81,8 +81,8 @@ if ('onhashchange' in window) { <span id="L20" class="LineNr"> 20 </span> <span class="Delimiter">);</span> <span id="L21" class="LineNr"> 21 </span><span class="Delimiter">}</span> <span id="L22" class="LineNr"> 22 </span> -<span id="L23" class="LineNr"> 23 </span><span class="Delimiter">:(before "End Level-2 Transforms")</span> -<span id="L24" class="LineNr"> 24 </span><span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='037global_variables.cc.html#L26'>rewrite_global_variables</a><span class="Delimiter">);</span> +<span id="L23" class="LineNr"> 23 </span><span class="Delimiter">:(before "End Transforms")</span> +<span id="L24" class="LineNr"> 24 </span><span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='037global_variables.cc.html#L26'>rewrite_global_variables</a><span class="Delimiter">);</span> <span id="L25" class="LineNr"> 25 </span><span class="Delimiter">:(code)</span> <span id="L26" class="LineNr"> 26 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L26'>rewrite_global_variables</a><span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L27" class="LineNr"> 27 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- rewrite global variables"</span> << end<span class="Delimiter">();</span> @@ -95,18 +95,18 @@ if ('onhashchange' in window) { <span id="L34" class="LineNr"> 34 </span><span class="Delimiter">}</span> <span id="L35" class="LineNr"> 35 </span> <span id="L36" class="LineNr"> 36 </span><span class="Normal">void</span> compute_addresses_for_global_variables<span class="Delimiter">(</span><span class="Normal">const</span> program& p<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>>& address<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L37" class="LineNr"> 37 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L38" class="LineNr"> 38 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L112'>name</a> != <span class="Constant">"code"</span><span class="Delimiter">)</span> -<span id="L39" class="LineNr"> 39 </span> compute_addresses_for_global_variables<span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> address<span class="Delimiter">);</span> +<span id="L37" class="LineNr"> 37 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L38" class="LineNr"> 38 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L111'>name</a> != <span class="Constant">"code"</span><span class="Delimiter">)</span> +<span id="L39" class="LineNr"> 39 </span> compute_addresses_for_global_variables<span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> address<span class="Delimiter">);</span> <span id="L40" class="LineNr"> 40 </span> <span class="Delimiter">}</span> <span id="L41" class="LineNr"> 41 </span><span class="Delimiter">}</span> <span id="L42" class="LineNr"> 42 </span> <span id="L43" class="LineNr"> 43 </span><span class="Normal">void</span> compute_addresses_for_global_variables<span class="Delimiter">(</span><span class="Normal">const</span> segment& s<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>>& address<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L44" class="LineNr"> 44 </span> <span class="Normal">int</span> current_address = s<span class="Delimiter">.</span>start<span class="Delimiter">;</span> -<span id="L45" class="LineNr"> 45 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L46" class="LineNr"> 46 </span> <span class="Normal">const</span> line& inst = s<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L47" class="LineNr"> 47 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L48" class="LineNr"> 48 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L45" class="LineNr"> 45 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L46" class="LineNr"> 46 </span> <span class="Normal">const</span> line& inst = s<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L47" class="LineNr"> 47 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L48" class="LineNr"> 48 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> <span id="L49" class="LineNr"> 49 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*curr<span class="Delimiter">.</span>data<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> != <span class="Constant">':'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L50" class="LineNr"> 50 </span> current_address += size_of<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> <span id="L51" class="LineNr"> 51 </span> <span class="Delimiter">}</span> @@ -116,15 +116,15 @@ if ('onhashchange' in window) { <span id="L55" class="LineNr"> 55 </span> <a href='036labels.cc.html#L84'>check_valid_name</a><span class="Delimiter">(</span>variable<span class="Delimiter">);</span> <span id="L56" class="LineNr"> 56 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L57" class="LineNr"> 57 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>j > <span class="Constant">0</span><span class="Delimiter">)</span> -<span id="L58" class="LineNr"> 58 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"': global variable names can only be the first <a href='011run.cc.html#L128'>word</a> in a line.\n"</span> << end<span class="Delimiter">();</span> +<span id="L58" class="LineNr"> 58 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"': global variable names can only be the first <a href='011run.cc.html#L127'>word</a> in a line.\n"</span> << end<span class="Delimiter">();</span> <span id="L59" class="LineNr"> 59 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span><span class="Delimiter">.</span>is_open<span class="Delimiter">())</span> -<span id="L60" class="LineNr"> 60 </span> <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << current_address << <span class="Constant">' '</span> << variable << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L61" class="LineNr"> 61 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span>address<span class="Delimiter">,</span> variable<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L60" class="LineNr"> 60 </span> <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << current_address << <span class="Constant">' '</span> << variable << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L61" class="LineNr"> 61 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span>address<span class="Delimiter">,</span> variable<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L62" class="LineNr"> 62 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"duplicate global '"</span> << variable << <span class="Constant">"'\n"</span> << end<span class="Delimiter">();</span> <span id="L63" class="LineNr"> 63 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L64" class="LineNr"> 64 </span> <span class="Delimiter">}</span> -<span id="L65" class="LineNr"> 65 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span>address<span class="Delimiter">,</span> variable<span class="Delimiter">,</span> current_address<span class="Delimiter">);</span> -<span id="L66" class="LineNr"> 66 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"global variable '"</span> << variable << <span class="Constant">"' is at address 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << current_address << end<span class="Delimiter">();</span> +<span id="L65" class="LineNr"> 65 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span>address<span class="Delimiter">,</span> variable<span class="Delimiter">,</span> current_address<span class="Delimiter">);</span> +<span id="L66" class="LineNr"> 66 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"global variable '"</span> << variable << <span class="Constant">"' is at address 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << current_address << end<span class="Delimiter">();</span> <span id="L67" class="LineNr"> 67 </span> <span class="Comment">// no modifying current_address; global variable definitions won't be in the final binary</span> <span id="L68" class="LineNr"> 68 </span> <span class="Delimiter">}</span> <span id="L69" class="LineNr"> 69 </span> <span class="Delimiter">}</span> @@ -132,17 +132,17 @@ if ('onhashchange' in window) { <span id="L71" class="LineNr"> 71 </span><span class="Delimiter">}</span> <span id="L72" class="LineNr"> 72 </span> <span id="L73" class="LineNr"> 73 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L73'>drop_global_variables</a><span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L74" class="LineNr"> 74 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L75" class="LineNr"> 75 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L112'>name</a> != <span class="Constant">"code"</span><span class="Delimiter">)</span> -<span id="L76" class="LineNr"> 76 </span> <a href='036labels.cc.html#L205'>drop_labels</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> +<span id="L74" class="LineNr"> 74 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L75" class="LineNr"> 75 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span><a href='011run.cc.html#L111'>name</a> != <span class="Constant">"code"</span><span class="Delimiter">)</span> +<span id="L76" class="LineNr"> 76 </span> <a href='036labels.cc.html#L205'>drop_labels</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span id="L77" class="LineNr"> 77 </span> <span class="Delimiter">}</span> <span id="L78" class="LineNr"> 78 </span><span class="Delimiter">}</span> <span id="L79" class="LineNr"> 79 </span> <span id="L80" class="LineNr"> 80 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L80'>replace_global_variables_with_addresses</a><span class="Delimiter">(</span>program& p<span class="Delimiter">,</span> <span class="Normal">const</span> map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>>& address<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L81" class="LineNr"> 81 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L82" class="LineNr"> 82 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L83" class="LineNr"> 83 </span> segment& curr = p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L84" class="LineNr"> 84 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span><a href='011run.cc.html#L112'>name</a> == <span class="Constant">"code"</span><span class="Delimiter">)</span> +<span id="L81" class="LineNr"> 81 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L82" class="LineNr"> 82 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L83" class="LineNr"> 83 </span> segment& curr = p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L84" class="LineNr"> 84 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span><a href='011run.cc.html#L111'>name</a> == <span class="Constant">"code"</span><span class="Delimiter">)</span> <span id="L85" class="LineNr"> 85 </span> <a href='037global_variables.cc.html#L91'>replace_global_variables_in_code_segment</a><span class="Delimiter">(</span>curr<span class="Delimiter">,</span> address<span class="Delimiter">);</span> <span id="L86" class="LineNr"> 86 </span> <span class="Normal">else</span> <span id="L87" class="LineNr"> 87 </span> <a href='037global_variables.cc.html#L114'>replace_global_variables_in_data_segment</a><span class="Delimiter">(</span>curr<span class="Delimiter">,</span> address<span class="Delimiter">);</span> @@ -150,15 +150,15 @@ if ('onhashchange' in window) { <span id="L89" class="LineNr"> 89 </span><span class="Delimiter">}</span> <span id="L90" class="LineNr"> 90 </span> <span id="L91" class="LineNr"> 91 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L91'>replace_global_variables_in_code_segment</a><span class="Delimiter">(</span>segment& code<span class="Delimiter">,</span> <span class="Normal">const</span> map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>>& address<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L92" class="LineNr"> 92 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L93" class="LineNr"> 93 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L94" class="LineNr"> 94 </span> <a href='011run.cc.html#L122'>line</a> new_inst<span class="Delimiter">;</span> -<span id="L95" class="LineNr"> 95 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L96" class="LineNr"> 96 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L92" class="LineNr"> 92 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L93" class="LineNr"> 93 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L94" class="LineNr"> 94 </span> <a href='011run.cc.html#L121'>line</a> new_inst<span class="Delimiter">;</span> +<span id="L95" class="LineNr"> 95 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L96" class="LineNr"> 96 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> <span id="L97" class="LineNr"> 97 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>address<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L98" class="LineNr"> 98 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!looks_like_hex_int<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span id="L99" class="LineNr"> 99 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"missing reference to global '"</span> << curr<span class="Delimiter">.</span>data << <span class="Constant">"'\n"</span> << end<span class="Delimiter">();</span> -<span id="L100" class="LineNr">100 </span> new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> +<span id="L100" class="LineNr">100 </span> new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> <span id="L101" class="LineNr">101 </span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span id="L102" class="LineNr">102 </span> <span class="Delimiter">}</span> <span id="L103" class="LineNr">103 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!valid_use_of_global_variable<span class="Delimiter">(</span>curr<span class="Delimiter">))</span> <span class="Delimiter">{</span> @@ -167,19 +167,19 @@ if ('onhashchange' in window) { <span id="L106" class="LineNr">106 </span> <span class="Delimiter">}</span> <span id="L107" class="LineNr">107 </span> emit_hex_bytes<span class="Delimiter">(</span>new_inst<span class="Delimiter">,</span> get<span class="Delimiter">(</span>address<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">),</span> <span class="Constant">4</span><span class="Delimiter">);</span> <span id="L108" class="LineNr">108 </span> <span class="Delimiter">}</span> -<span id="L109" class="LineNr">109 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> +<span id="L109" class="LineNr">109 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> <span id="L110" class="LineNr">110 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"instruction after transform: '"</span> << data_to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> <span id="L111" class="LineNr">111 </span> <span class="Delimiter">}</span> <span id="L112" class="LineNr">112 </span><span class="Delimiter">}</span> <span id="L113" class="LineNr">113 </span> <span id="L114" class="LineNr">114 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L114'>replace_global_variables_in_data_segment</a><span class="Delimiter">(</span>segment& data<span class="Delimiter">,</span> <span class="Normal">const</span> map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>>& address<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L115" class="LineNr">115 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>data<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L116" class="LineNr">116 </span> line& l = data<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L117" class="LineNr">117 </span> <a href='011run.cc.html#L122'>line</a> new_l<span class="Delimiter">;</span> -<span id="L118" class="LineNr">118 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>l<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L119" class="LineNr">119 </span> <span class="Normal">const</span> word& curr = l<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L115" class="LineNr">115 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>data<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L116" class="LineNr">116 </span> line& l = data<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L117" class="LineNr">117 </span> <a href='011run.cc.html#L121'>line</a> new_l<span class="Delimiter">;</span> +<span id="L118" class="LineNr">118 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>l<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L119" class="LineNr">119 </span> <span class="Normal">const</span> word& curr = l<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> <span id="L120" class="LineNr">120 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>address<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L121" class="LineNr">121 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L489'>looks_like_hex_int</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L121" class="LineNr">121 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L490'>looks_like_hex_int</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L122" class="LineNr">122 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"imm32"</span><span class="Delimiter">))</span> <span id="L123" class="LineNr">123 </span> emit_hex_bytes<span class="Delimiter">(</span>new_l<span class="Delimiter">,</span> curr<span class="Delimiter">,</span> <span class="Constant">4</span><span class="Delimiter">);</span> <span id="L124" class="LineNr">124 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"imm16"</span><span class="Delimiter">))</span> @@ -193,18 +193,18 @@ if ('onhashchange' in window) { <span id="L132" class="LineNr">132 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"disp32"</span><span class="Delimiter">))</span> <span id="L133" class="LineNr">133 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"can't use /disp32 in a non-code segment\n"</span> << end<span class="Delimiter">();</span> <span id="L134" class="LineNr">134 </span> <span class="Normal">else</span> -<span id="L135" class="LineNr">135 </span> new_l<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> +<span id="L135" class="LineNr">135 </span> new_l<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> <span id="L136" class="LineNr">136 </span> <span class="Delimiter">}</span> <span id="L137" class="LineNr">137 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> <span id="L138" class="LineNr">138 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"missing reference to global '"</span> << curr<span class="Delimiter">.</span>data << <span class="Constant">"'\n"</span> << end<span class="Delimiter">();</span> -<span id="L139" class="LineNr">139 </span> new_l<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> +<span id="L139" class="LineNr">139 </span> new_l<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> <span id="L140" class="LineNr">140 </span> <span class="Delimiter">}</span> <span id="L141" class="LineNr">141 </span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span id="L142" class="LineNr">142 </span> <span class="Delimiter">}</span> -<span id="L143" class="LineNr">143 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << curr<span class="Delimiter">.</span>data << <span class="Constant">" maps to "</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << get<span class="Delimiter">(</span>address<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L143" class="LineNr">143 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << curr<span class="Delimiter">.</span>data << <span class="Constant">" maps to "</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << get<span class="Delimiter">(</span>address<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L144" class="LineNr">144 </span> emit_hex_bytes<span class="Delimiter">(</span>new_l<span class="Delimiter">,</span> get<span class="Delimiter">(</span>address<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">),</span> <span class="Constant">4</span><span class="Delimiter">);</span> <span id="L145" class="LineNr">145 </span> <span class="Delimiter">}</span> -<span id="L146" class="LineNr">146 </span> l<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_l<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> +<span id="L146" class="LineNr">146 </span> l<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_l<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> <span id="L147" class="LineNr">147 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"after transform: '"</span> << data_to_string<span class="Delimiter">(</span>l<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> <span id="L148" class="LineNr">148 </span> <span class="Delimiter">}</span> <span id="L149" class="LineNr">149 </span><span class="Delimiter">}</span> @@ -218,16 +218,16 @@ if ('onhashchange' in window) { <span id="L157" class="LineNr">157 </span><span class="SalientComment">//:: a more complex sanity check for how we use global variables</span> <span id="L158" class="LineNr">158 </span><span class="Comment">//: requires first saving some data early before we pack operands</span> <span id="L159" class="LineNr">159 </span> -<span id="L160" class="LineNr">160 </span><span class="Delimiter">:(after "Begin Level-2 Transforms")</span> -<span id="L161" class="LineNr">161 </span><span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='037global_variables.cc.html#L163'>correlate_disp32_with_mod</a><span class="Delimiter">);</span> +<span id="L160" class="LineNr">160 </span><span class="Delimiter">:(after "Begin Transforms")</span> +<span id="L161" class="LineNr">161 </span><span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='037global_variables.cc.html#L163'>correlate_disp32_with_mod</a><span class="Delimiter">);</span> <span id="L162" class="LineNr">162 </span><span class="Delimiter">:(code)</span> <span id="L163" class="LineNr">163 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L163'>correlate_disp32_with_mod</a><span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L164" class="LineNr">164 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L164" class="LineNr">164 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L165" class="LineNr">165 </span> segment& code = *find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">);</span> -<span id="L166" class="LineNr">166 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L167" class="LineNr">167 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L168" class="LineNr">168 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L169" class="LineNr">169 </span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L166" class="LineNr">166 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L167" class="LineNr">167 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L168" class="LineNr">168 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L169" class="LineNr">169 </span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> <span id="L170" class="LineNr">170 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"disp32"</span><span class="Delimiter">)</span> <span id="L171" class="LineNr">171 </span> && has_operand_metadata<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> <span class="Constant">"mod"</span><span class="Delimiter">))</span> <span id="L172" class="LineNr">172 </span> curr<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"has_mod"</span><span class="Delimiter">);</span> @@ -243,14 +243,14 @@ if ('onhashchange' in window) { <span id="L182" class="LineNr">182 </span> <span id="L183" class="LineNr">183 </span><span class="Delimiter">:(code)</span> <span id="L184" class="LineNr">184 </span><span class="Normal">bool</span> <a href='037global_variables.cc.html#L184'>has_metadata</a><span class="Delimiter">(</span><span class="Normal">const</span> word& w<span class="Delimiter">,</span> <span class="Normal">const</span> string& m<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L185" class="LineNr">185 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> +<span id="L185" class="LineNr">185 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span id="L186" class="LineNr">186 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>w<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == m<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L187" class="LineNr">187 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L188" class="LineNr">188 </span><span class="Delimiter">}</span> <span id="L189" class="LineNr">189 </span> <span id="L190" class="LineNr">190 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L190'>test_global_variable_disallowed_in_jump</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L191" class="LineNr">191 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L192" class="LineNr">192 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L192" class="LineNr">192 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L193" class="LineNr">193 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L194" class="LineNr">194 </span> <span class="Constant">"eb/jump x/disp8\n"</span> <span id="L195" class="LineNr">195 </span> <span class="Constant">"== data 0x2000\n"</span> @@ -266,7 +266,7 @@ if ('onhashchange' in window) { <span id="L205" class="LineNr">205 </span> <span id="L206" class="LineNr">206 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L206'>test_global_variable_disallowed_in_call</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L207" class="LineNr">207 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L208" class="LineNr">208 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L208" class="LineNr">208 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L209" class="LineNr">209 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L210" class="LineNr">210 </span> <span class="Constant">"e8/call x/disp32\n"</span> <span id="L211" class="LineNr">211 </span> <span class="Constant">"== data 0x2000\n"</span> @@ -281,7 +281,7 @@ if ('onhashchange' in window) { <span id="L220" class="LineNr">220 </span><span class="Delimiter">}</span> <span id="L221" class="LineNr">221 </span> <span id="L222" class="LineNr">222 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L222'>test_global_variable_in_data_segment</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L223" class="LineNr">223 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L223" class="LineNr">223 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L224" class="LineNr">224 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L225" class="LineNr">225 </span> <span class="Constant">"b9 x/imm32\n"</span> <span id="L226" class="LineNr">226 </span> <span class="Constant">"== data 0x2000\n"</span> @@ -301,7 +301,7 @@ if ('onhashchange' in window) { <span id="L240" class="LineNr">240 </span><span class="Delimiter">}</span> <span id="L241" class="LineNr">241 </span> <span id="L242" class="LineNr">242 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L242'>test_raw_number_with_imm32_in_data_segment</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L243" class="LineNr">243 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L243" class="LineNr">243 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L244" class="LineNr">244 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L245" class="LineNr">245 </span> <span class="Constant">"b9 x/imm32\n"</span> <span id="L246" class="LineNr">246 </span> <span class="Constant">"== data 0x2000\n"</span> @@ -320,7 +320,7 @@ if ('onhashchange' in window) { <span id="L259" class="LineNr">259 </span> <span id="L260" class="LineNr">260 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L260'>test_duplicate_global_variable</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L261" class="LineNr">261 </span> <span class="Special">Hide_errors</span> = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L262" class="LineNr">262 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L262" class="LineNr">262 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L263" class="LineNr">263 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L264" class="LineNr">264 </span> <span class="Constant">"40/increment-EAX\n"</span> <span id="L265" class="LineNr">265 </span> <span class="Constant">"== data 0x2000\n"</span> @@ -334,7 +334,7 @@ if ('onhashchange' in window) { <span id="L273" class="LineNr">273 </span><span class="Delimiter">}</span> <span id="L274" class="LineNr">274 </span> <span id="L275" class="LineNr">275 </span><span class="Normal">void</span> <a href='037global_variables.cc.html#L275'>test_global_variable_disp32_with_modrm</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L276" class="LineNr">276 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L276" class="LineNr">276 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L277" class="LineNr">277 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L278" class="LineNr">278 </span> <span class="Constant">"8b/copy 0/mod/indirect 5/rm32/.disp32 2/r32/EDX x/disp32\n"</span> <span id="L279" class="LineNr">279 </span> <span class="Constant">"== data 0x2000\n"</span> @@ -356,11 +356,11 @@ if ('onhashchange' in window) { <span id="L295" class="LineNr">295 </span> <span id="L296" class="LineNr">296 </span>string <a href='037global_variables.cc.html#L296'>to_full_string</a><span class="Delimiter">(</span><span class="Normal">const</span> line& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L297" class="LineNr">297 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L298" class="LineNr">298 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L298" class="LineNr">298 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L299" class="LineNr">299 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L300" class="LineNr">300 </span> out << in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">;</span> -<span id="L301" class="LineNr">301 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>metadata<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> -<span id="L302" class="LineNr">302 </span> out << <span class="Constant">'/'</span> << in<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>metadata<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L300" class="LineNr">300 </span> out << in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">;</span> +<span id="L301" class="LineNr">301 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>metadata<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> +<span id="L302" class="LineNr">302 </span> out << <span class="Constant">'/'</span> << in<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>metadata<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> <span id="L303" class="LineNr">303 </span> <span class="Delimiter">}</span> <span id="L304" class="LineNr">304 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span id="L305" class="LineNr">305 </span><span class="Delimiter">}</span> diff --git a/html/038---literal_strings.cc.html b/html/038---literal_strings.cc.html index 67b6c458..2cf9e245 100644 --- a/html/038---literal_strings.cc.html +++ b/html/038---literal_strings.cc.html @@ -64,7 +64,7 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="Comment">//: always be the second segment).</span> <span id="L5" class="LineNr"> 5 </span> <span id="L6" class="LineNr"> 6 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L6'>test_transform_literal_string</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L7" class="LineNr"> 7 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L7" class="LineNr"> 7 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L8" class="LineNr"> 8 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L9" class="LineNr"> 9 </span> <span class="Constant">"b8/copy \"</span>test\<span class="Constant">"/imm32\n"</span> <span id="L10" class="LineNr"> 10 </span> <span class="Constant">"== data 0x2000\n"</span> <span class="Comment">// need an empty segment</span> @@ -72,7 +72,7 @@ if ('onhashchange' in window) { <span id="L12" class="LineNr"> 12 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L13" class="LineNr"> 13 </span> <span class="Constant">"transform: -- move literal strings to data segment\n"</span> <span id="L14" class="LineNr"> 14 </span> <span class="Constant">"transform: adding global variable '__subx_global_1' containing \"</span>test\<span class="Constant">"\n"</span> -<span id="L15" class="LineNr"> 15 </span> <span class="Constant">"transform: <a href='011run.cc.html#L122'>line</a> after transform: 'b8 __subx_global_1'\n"</span> +<span id="L15" class="LineNr"> 15 </span> <span class="Constant">"transform: <a href='011run.cc.html#L121'>line</a> after transform: 'b8 __subx_global_1'\n"</span> <span id="L16" class="LineNr"> 16 </span> <span class="Delimiter">);</span> <span id="L17" class="LineNr"> 17 </span><span class="Delimiter">}</span> <span id="L18" class="LineNr"> 18 </span> @@ -80,332 +80,330 @@ if ('onhashchange' in window) { <span id="L20" class="LineNr"> 20 </span><span class="Comment">//: knows about labels and global variables and will emit them for previous</span> <span id="L21" class="LineNr"> 21 </span><span class="Comment">//: layers to transform.</span> <span id="L22" class="LineNr"> 22 </span><span class="Delimiter">:(after "Begin Transforms")</span> -<span id="L23" class="LineNr"> 23 </span><span class="Comment">// Begin Level-3 Transforms</span> -<span id="L24" class="LineNr"> 24 </span><span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='038---literal_strings.cc.html#L32'>transform_literal_strings</a><span class="Delimiter">);</span> -<span id="L25" class="LineNr"> 25 </span><span class="Comment">// End Level-3 Transforms</span> -<span id="L26" class="LineNr"> 26 </span> -<span id="L27" class="LineNr"> 27 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L28" class="LineNr"> 28 </span><span class="Normal">int</span> <span class="Special">Next_auto_global</span> = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L29" class="LineNr"> 29 </span><span class="Delimiter">:(before "End Reset")</span> -<span id="L30" class="LineNr"> 30 </span><span class="Special">Next_auto_global</span> = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L31" class="LineNr"> 31 </span><span class="Delimiter">:(code)</span> -<span id="L32" class="LineNr"> 32 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L32'>transform_literal_strings</a><span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L33" class="LineNr"> 33 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- move literal strings to data segment"</span> << end<span class="Delimiter">();</span> -<span id="L34" class="LineNr"> 34 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L35" class="LineNr"> 35 </span> vector<line> new_lines<span class="Delimiter">;</span> -<span id="L36" class="LineNr"> 36 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> s = <span class="Constant">0</span><span class="Delimiter">;</span> s < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">);</span> ++s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L37" class="LineNr"> 37 </span> segment& seg = p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>s<span class="Delimiter">);</span> -<span id="L38" class="LineNr"> 38 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"segment '"</span> << seg<span class="Delimiter">.</span>name << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> -<span id="L39" class="LineNr"> 39 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>seg<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L40" class="LineNr"> 40 </span><span class="CommentedCode">//? cerr << seg.name << '/' << i << '\n';</span> -<span id="L41" class="LineNr"> 41 </span> line& <a href='011run.cc.html#L122'>line</a> = seg<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L42" class="LineNr"> 42 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span><a href='011run.cc.html#L122'>line</a><span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L43" class="LineNr"> 43 </span> word& curr = <a href='011run.cc.html#L122'>line</a><span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> -<span id="L44" class="LineNr"> 44 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> != <span class="Constant">'"'</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L45" class="LineNr"> 45 </span> ostringstream global_name<span class="Delimiter">;</span> -<span id="L46" class="LineNr"> 46 </span> global_name << <span class="Constant">"__subx_global_"</span> << <span class="Special">Next_auto_global</span><span class="Delimiter">;</span> -<span id="L47" class="LineNr"> 47 </span> ++<span class="Special">Next_auto_global</span><span class="Delimiter">;</span> -<span id="L48" class="LineNr"> 48 </span> <a href='038---literal_strings.cc.html#L59'>add_global_to_data_segment</a><span class="Delimiter">(</span>global_name<span class="Delimiter">.</span>str<span class="Delimiter">(),</span> curr<span class="Delimiter">,</span> new_lines<span class="Delimiter">);</span> -<span id="L49" class="LineNr"> 49 </span> curr<span class="Delimiter">.</span>data = global_name<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L50" class="LineNr"> 50 </span> <span class="Delimiter">}</span> -<span id="L51" class="LineNr"> 51 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"line after transform: '"</span> << data_to_string<span class="Delimiter">(</span>line<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> -<span id="L52" class="LineNr"> 52 </span> <span class="Delimiter">}</span> -<span id="L53" class="LineNr"> 53 </span> <span class="Delimiter">}</span> -<span id="L54" class="LineNr"> 54 </span> segment* data = find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"data"</span><span class="Delimiter">);</span> -<span id="L55" class="LineNr"> 55 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>data<span class="Delimiter">)</span> -<span id="L56" class="LineNr"> 56 </span> data<span class="Delimiter">-></span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>insert<span class="Delimiter">(</span>data<span class="Delimiter">-></span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>end<span class="Delimiter">(),</span> new_lines<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> new_lines<span class="Delimiter">.</span>end<span class="Delimiter">());</span> -<span id="L57" class="LineNr"> 57 </span><span class="Delimiter">}</span> -<span id="L58" class="LineNr"> 58 </span> -<span id="L59" class="LineNr"> 59 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L59'>add_global_to_data_segment</a><span class="Delimiter">(</span><span class="Normal">const</span> string& <a href='011run.cc.html#L112'>name</a><span class="Delimiter">,</span> <span class="Normal">const</span> word& value<span class="Delimiter">,</span> vector<line>& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L60" class="LineNr"> 60 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"adding global variable '"</span> << name << <span class="Constant">"' containing "</span> << value<span class="Delimiter">.</span>data << end<span class="Delimiter">();</span> -<span id="L61" class="LineNr"> 61 </span> <span class="Comment">// emit label</span> -<span id="L62" class="LineNr"> 62 </span> out<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>label<span class="Delimiter">(</span><a href='011run.cc.html#L112'>name</a><span class="Delimiter">));</span> -<span id="L63" class="LineNr"> 63 </span> <span class="Comment">// emit size for size-prefixed array</span> -<span id="L64" class="LineNr"> 64 </span> out<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L122'>line</a><span class="Delimiter">());</span> -<span id="L65" class="LineNr"> 65 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">.</span>back<span class="Delimiter">(),</span> <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>value<span class="Delimiter">.</span>data<span class="Delimiter">)</span>-<span class="Comment">/*</span><span class="Comment">skip quotes</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">4</span><span class="Comment">/*</span><span class="Comment">bytes</span><span class="Comment">*/</span><span class="Delimiter">);</span> -<span id="L66" class="LineNr"> 66 </span> <span class="Comment">// emit data byte by byte</span> -<span id="L67" class="LineNr"> 67 </span> out<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L122'>line</a><span class="Delimiter">());</span> -<span id="L68" class="LineNr"> 68 </span> line& curr = out<span class="Delimiter">.</span>back<span class="Delimiter">();</span> -<span id="L69" class="LineNr"> 69 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Comment">/*</span><span class="Comment">skip start quote</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>value<span class="Delimiter">.</span>data<span class="Delimiter">)</span>-<span class="Comment">/*</span><span class="Comment">skip end quote</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L70" class="LineNr"> 70 </span> <span class="Normal">char</span> c = value<span class="Delimiter">.</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L71" class="LineNr"> 71 </span> curr<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L128'>word</a><span class="Delimiter">());</span> -<span id="L72" class="LineNr"> 72 </span> curr<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>data = <a href='032---operands.cc.html#L295'>hex_byte_to_string</a><span class="Delimiter">(</span>c<span class="Delimiter">);</span> -<span id="L73" class="LineNr"> 73 </span> curr<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>string<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">,</span> c<span class="Delimiter">));</span> -<span id="L74" class="LineNr"> 74 </span> <span class="Delimiter">}</span> -<span id="L75" class="LineNr"> 75 </span><span class="Delimiter">}</span> -<span id="L76" class="LineNr"> 76 </span> -<span id="L77" class="LineNr"> 77 </span><span class="Comment">//: Within strings, whitespace is significant. So we need to redo our instruction</span> -<span id="L78" class="LineNr"> 78 </span><span class="Comment">//: parsing.</span> -<span id="L79" class="LineNr"> 79 </span> -<span id="L80" class="LineNr"> 80 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L80'>test_instruction_with_string_literal</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L81" class="LineNr"> 81 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L82" class="LineNr"> 82 </span> <span class="Constant">"a \"</span>abc def\<span class="Constant">" z\n"</span> <span class="Comment">// two spaces inside string</span> -<span id="L83" class="LineNr"> 83 </span> <span class="Delimiter">);</span> -<span id="L84" class="LineNr"> 84 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L85" class="LineNr"> 85 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: a\n"</span> -<span id="L86" class="LineNr"> 86 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: \"</span>abc def\<span class="Constant">"\n"</span> -<span id="L87" class="LineNr"> 87 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: z\n"</span> -<span id="L88" class="LineNr"> 88 </span> <span class="Delimiter">);</span> -<span id="L89" class="LineNr"> 89 </span> <span class="Comment">// no other words</span> -<span id="L90" class="LineNr"> 90 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"parse2"</span><span class="Delimiter">,</span> <span class="Constant">3</span><span class="Delimiter">);</span> -<span id="L91" class="LineNr"> 91 </span><span class="Delimiter">}</span> -<span id="L92" class="LineNr"> 92 </span> -<span id="L93" class="LineNr"> 93 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L93'>test_string_literal_in_data_segment</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L94" class="LineNr"> 94 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> -<span id="L95" class="LineNr"> 95 </span> <span class="Constant">"== code 0x1\n"</span> -<span id="L96" class="LineNr"> 96 </span> <span class="Constant">"b8/copy X/imm32\n"</span> -<span id="L97" class="LineNr"> 97 </span> <span class="Constant">"== data 0x2000\n"</span> -<span id="L98" class="LineNr"> 98 </span> <span class="Constant">"X:\n"</span> -<span id="L99" class="LineNr"> 99 </span> <span class="Constant">"\"</span>test\<span class="Constant">"/imm32\n"</span> -<span id="L100" class="LineNr">100 </span> <span class="Delimiter">);</span> -<span id="L101" class="LineNr">101 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L102" class="LineNr">102 </span> <span class="Constant">"transform: -- move literal strings to data segment\n"</span> -<span id="L103" class="LineNr">103 </span> <span class="Constant">"transform: adding global variable '__subx_global_1' containing \"</span>test\<span class="Constant">"\n"</span> -<span id="L104" class="LineNr">104 </span> <span class="Constant">"transform: <a href='011run.cc.html#L122'>line</a> after transform: '__subx_global_1'\n"</span> -<span id="L105" class="LineNr">105 </span> <span class="Delimiter">);</span> -<span id="L106" class="LineNr">106 </span><span class="Delimiter">}</span> -<span id="L107" class="LineNr">107 </span> -<span id="L108" class="LineNr">108 </span><span class="Delimiter">:(before "End Line Parsing Special-cases(line_data -> l)")</span> -<span id="L109" class="LineNr">109 </span><span class="Normal">if</span> <span class="Delimiter">(</span>line_data<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">'"'</span><span class="Delimiter">)</span> != string::npos<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// can cause false-positives, but we can handle them</span> -<span id="L110" class="LineNr">110 </span> parse_instruction_character_by_character<span class="Delimiter">(</span>line_data<span class="Delimiter">,</span> l<span class="Delimiter">);</span> -<span id="L111" class="LineNr">111 </span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L112" class="LineNr">112 </span><span class="Delimiter">}</span> -<span id="L113" class="LineNr">113 </span> -<span id="L114" class="LineNr">114 </span><span class="Delimiter">:(code)</span> -<span id="L115" class="LineNr">115 </span><span class="Normal">void</span> parse_instruction_character_by_character<span class="Delimiter">(</span><span class="Normal">const</span> string& line_data<span class="Delimiter">,</span> vector<line>& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L116" class="LineNr">116 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>line_data<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="cSpecial">'\n'</span><span class="Delimiter">)</span> != string::npos && line_data<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="cSpecial">'\n'</span><span class="Delimiter">)</span> != line_data<span class="Delimiter">.</span>size<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L117" class="LineNr">117 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"parse_instruction_character_by_character: should receive only a single line\n"</span> << end<span class="Delimiter">();</span> -<span id="L118" class="LineNr">118 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L119" class="LineNr">119 </span> <span class="Delimiter">}</span> -<span id="L120" class="LineNr">120 </span> <span class="Comment">// parse literals</span> -<span id="L121" class="LineNr">121 </span> istringstream in<span class="Delimiter">(</span>line_data<span class="Delimiter">);</span> -<span id="L122" class="LineNr">122 </span> in >> std::noskipws<span class="Delimiter">;</span> -<span id="L123" class="LineNr">123 </span> <a href='011run.cc.html#L122'>line</a> result<span class="Delimiter">;</span> -<span id="L124" class="LineNr">124 </span> result<span class="Delimiter">.</span>original = line_data<span class="Delimiter">;</span> -<span id="L125" class="LineNr">125 </span> <span class="Comment">// add tokens (words or strings) one by one</span> -<span id="L126" class="LineNr">126 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L127" class="LineNr">127 </span> <a href='038---literal_strings.cc.html#L191'>skip_whitespace</a><span class="Delimiter">(</span>in<span class="Delimiter">);</span> -<span id="L128" class="LineNr">128 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L129" class="LineNr">129 </span> <span class="Normal">char</span> c = in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> -<span id="L130" class="LineNr">130 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// comment; drop rest of line</span> -<span id="L131" class="LineNr">131 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">':'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// line metadata; skip for now</span> -<span id="L132" class="LineNr">132 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'.'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L133" class="LineNr">133 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// comment token at end of line</span> -<span id="L134" class="LineNr">134 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()))</span> -<span id="L135" class="LineNr">135 </span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// '.' followed by space is comment token; skip</span> -<span id="L136" class="LineNr">136 </span> <span class="Delimiter">}</span> -<span id="L137" class="LineNr">137 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L128'>word</a><span class="Delimiter">());</span> -<span id="L138" class="LineNr">138 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'"'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L139" class="LineNr">139 </span> <span class="Comment">// string literal; slurp everything between quotes into data</span> -<span id="L140" class="LineNr">140 </span> ostringstream d<span class="Delimiter">;</span> -<span id="L141" class="LineNr">141 </span> d << c<span class="Delimiter">;</span> -<span id="L142" class="LineNr">142 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L143" class="LineNr">143 </span> in >> c<span class="Delimiter">;</span> -<span id="L144" class="LineNr">144 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="cSpecial">'\\'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L145" class="LineNr">145 </span> in >> c<span class="Delimiter">;</span> -<span id="L146" class="LineNr">146 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'n'</span><span class="Delimiter">)</span> d << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L147" class="LineNr">147 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'"'</span><span class="Delimiter">)</span> d << <span class="Constant">'"'</span><span class="Delimiter">;</span> -<span id="L148" class="LineNr">148 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="cSpecial">'\\'</span><span class="Delimiter">)</span> d << <span class="cSpecial">'\\'</span><span class="Delimiter">;</span> -<span id="L149" class="LineNr">149 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L150" class="LineNr">150 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"parse_instruction_character_by_character: unknown escape sequence '\\"</span> << c << <span class="Constant">"'\n"</span> << end<span class="Delimiter">();</span> -<span id="L151" class="LineNr">151 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L152" class="LineNr">152 </span> <span class="Delimiter">}</span> -<span id="L153" class="LineNr">153 </span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L154" class="LineNr">154 </span> <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L155" class="LineNr">155 </span> d << c<span class="Delimiter">;</span> -<span id="L156" class="LineNr">156 </span> <span class="Delimiter">}</span> -<span id="L157" class="LineNr">157 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'"'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L158" class="LineNr">158 </span> <span class="Delimiter">}</span> -<span id="L159" class="LineNr">159 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>data = d<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L160" class="LineNr">160 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>original = d<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L161" class="LineNr">161 </span> <span class="Comment">// slurp metadata</span> -<span id="L162" class="LineNr">162 </span> ostringstream m<span class="Delimiter">;</span> -<span id="L163" class="LineNr">163 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>!isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">())</span> && <a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// peek can sometimes trigger eof(), so do it first</span> -<span id="L164" class="LineNr">164 </span> in >> c<span class="Delimiter">;</span> -<span id="L165" class="LineNr">165 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'/'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L166" class="LineNr">166 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!m<span class="Delimiter">.</span>str<span class="Delimiter">().</span>empty<span class="Delimiter">())</span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>m<span class="Delimiter">.</span>str<span class="Delimiter">());</span> -<span id="L167" class="LineNr">167 </span> m<span class="Delimiter">.</span>str<span class="Delimiter">(</span><span class="Constant">""</span><span class="Delimiter">);</span> -<span id="L168" class="LineNr">168 </span> <span class="Delimiter">}</span> -<span id="L169" class="LineNr">169 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L170" class="LineNr">170 </span> m << c<span class="Delimiter">;</span> -<span id="L171" class="LineNr">171 </span> <span class="Delimiter">}</span> -<span id="L172" class="LineNr">172 </span> <span class="Delimiter">}</span> -<span id="L173" class="LineNr">173 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!m<span class="Delimiter">.</span>str<span class="Delimiter">().</span>empty<span class="Delimiter">())</span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>m<span class="Delimiter">.</span>str<span class="Delimiter">());</span> -<span id="L174" class="LineNr">174 </span> <span class="Delimiter">}</span> -<span id="L175" class="LineNr">175 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L176" class="LineNr">176 </span> <span class="Comment">// not a string literal; slurp all characters until whitespace</span> -<span id="L177" class="LineNr">177 </span> ostringstream w<span class="Delimiter">;</span> -<span id="L178" class="LineNr">178 </span> w << c<span class="Delimiter">;</span> -<span id="L179" class="LineNr">179 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>!isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">())</span> && <a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// peek can sometimes trigger eof(), so do it first</span> -<span id="L180" class="LineNr">180 </span> in >> c<span class="Delimiter">;</span> -<span id="L181" class="LineNr">181 </span> w << c<span class="Delimiter">;</span> -<span id="L182" class="LineNr">182 </span> <span class="Delimiter">}</span> -<span id="L183" class="LineNr">183 </span> <a href='011run.cc.html#L210'>parse_word</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>str<span class="Delimiter">(),</span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">());</span> -<span id="L184" class="LineNr">184 </span> <span class="Delimiter">}</span> -<span id="L185" class="LineNr">185 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"parse2"</span><span class="Delimiter">)</span> << <span class="Constant">"word: "</span> << to_string<span class="Delimiter">(</span>result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">())</span> << end<span class="Delimiter">();</span> -<span id="L186" class="LineNr">186 </span> <span class="Delimiter">}</span> -<span id="L187" class="LineNr">187 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> -<span id="L188" class="LineNr">188 </span> out<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> -<span id="L189" class="LineNr">189 </span><span class="Delimiter">}</span> -<span id="L190" class="LineNr">190 </span> -<span id="L191" class="LineNr">191 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L191'>skip_whitespace</a><span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L192" class="LineNr">192 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">)</span> && isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()))</span> <span class="Delimiter">{</span> -<span id="L193" class="LineNr">193 </span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> -<span id="L194" class="LineNr">194 </span> <span class="Delimiter">}</span> -<span id="L195" class="LineNr">195 </span><span class="Delimiter">}</span> -<span id="L196" class="LineNr">196 </span> -<span id="L197" class="LineNr">197 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L197'>skip_comment</a><span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L198" class="LineNr">198 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">)</span> && in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L199" class="LineNr">199 </span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> -<span id="L200" class="LineNr">200 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">)</span> && in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> in<span class="Delimiter">.</span>get<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 id="L204" class="LineNr">204 </span><a href='011run.cc.html#L122'>line</a> label<span class="Delimiter">(</span>string s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L205" class="LineNr">205 </span> <a href='011run.cc.html#L122'>line</a> result<span class="Delimiter">;</span> -<span id="L206" class="LineNr">206 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L128'>word</a><span class="Delimiter">());</span> -<span id="L207" class="LineNr">207 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>data = <span class="Delimiter">(</span>s+<span class="Constant">":"</span><span class="Delimiter">);</span> -<span id="L208" class="LineNr">208 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L209" class="LineNr">209 </span><span class="Delimiter">}</span> -<span id="L210" class="LineNr">210 </span> -<span id="L211" class="LineNr">211 </span><span class="Comment">// helper for tests</span> -<span id="L212" class="LineNr">212 </span><span class="Normal">void</span> parse_instruction_character_by_character<span class="Delimiter">(</span><span class="Normal">const</span> string& line_data<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L213" class="LineNr">213 </span> vector<line> out<span class="Delimiter">;</span> -<span id="L214" class="LineNr">214 </span> parse_instruction_character_by_character<span class="Delimiter">(</span>line_data<span class="Delimiter">,</span> out<span class="Delimiter">);</span> -<span id="L215" class="LineNr">215 </span><span class="Delimiter">}</span> -<span id="L216" class="LineNr">216 </span> -<span id="L217" class="LineNr">217 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L217'>test_parse2_comment_token_in_middle</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L218" class="LineNr">218 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L219" class="LineNr">219 </span> <span class="Constant">"a . z\n"</span> -<span id="L220" class="LineNr">220 </span> <span class="Delimiter">);</span> -<span id="L221" class="LineNr">221 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L222" class="LineNr">222 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: a\n"</span> -<span id="L223" class="LineNr">223 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: z\n"</span> -<span id="L224" class="LineNr">224 </span> <span class="Delimiter">);</span> -<span id="L225" class="LineNr">225 </span> <a href='003trace.cc.html#L294'>CHECK_TRACE_DOESNT_CONTAIN</a><span class="Delimiter">(</span><span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: ."</span><span class="Delimiter">);</span> -<span id="L226" class="LineNr">226 </span> <span class="Comment">// no other words</span> -<span id="L227" class="LineNr">227 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"parse2"</span><span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> -<span id="L228" class="LineNr">228 </span><span class="Delimiter">}</span> -<span id="L229" class="LineNr">229 </span> -<span id="L230" class="LineNr">230 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L230'>test_parse2_word_starting_with_dot</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L231" class="LineNr">231 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L232" class="LineNr">232 </span> <span class="Constant">"a .b c\n"</span> -<span id="L233" class="LineNr">233 </span> <span class="Delimiter">);</span> -<span id="L234" class="LineNr">234 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L235" class="LineNr">235 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: a\n"</span> -<span id="L236" class="LineNr">236 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: .b\n"</span> -<span id="L237" class="LineNr">237 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: c\n"</span> -<span id="L238" class="LineNr">238 </span> <span class="Delimiter">);</span> -<span id="L239" class="LineNr">239 </span><span class="Delimiter">}</span> -<span id="L240" class="LineNr">240 </span> -<span id="L241" class="LineNr">241 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L241'>test_parse2_comment_token_at_start</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L242" class="LineNr">242 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L243" class="LineNr">243 </span> <span class="Constant">". a b\n"</span> -<span id="L244" class="LineNr">244 </span> <span class="Delimiter">);</span> -<span id="L245" class="LineNr">245 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L246" class="LineNr">246 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: a\n"</span> -<span id="L247" class="LineNr">247 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: b\n"</span> -<span id="L248" class="LineNr">248 </span> <span class="Delimiter">);</span> -<span id="L249" class="LineNr">249 </span> <a href='003trace.cc.html#L294'>CHECK_TRACE_DOESNT_CONTAIN</a><span class="Delimiter">(</span><span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: ."</span><span class="Delimiter">);</span> -<span id="L250" class="LineNr">250 </span><span class="Delimiter">}</span> -<span id="L251" class="LineNr">251 </span> -<span id="L252" class="LineNr">252 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L252'>test_parse2_comment_token_at_end</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L253" class="LineNr">253 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L254" class="LineNr">254 </span> <span class="Constant">"a b .\n"</span> -<span id="L255" class="LineNr">255 </span> <span class="Delimiter">);</span> -<span id="L256" class="LineNr">256 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L257" class="LineNr">257 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: a\n"</span> -<span id="L258" class="LineNr">258 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: b\n"</span> -<span id="L259" class="LineNr">259 </span> <span class="Delimiter">);</span> -<span id="L260" class="LineNr">260 </span> <a href='003trace.cc.html#L294'>CHECK_TRACE_DOESNT_CONTAIN</a><span class="Delimiter">(</span><span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: ."</span><span class="Delimiter">);</span> -<span id="L261" class="LineNr">261 </span><span class="Delimiter">}</span> -<span id="L262" class="LineNr">262 </span> -<span id="L263" class="LineNr">263 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L263'>test_parse2_word_starting_with_dot_at_start</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L264" class="LineNr">264 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L265" class="LineNr">265 </span> <span class="Constant">".a b c\n"</span> -<span id="L266" class="LineNr">266 </span> <span class="Delimiter">);</span> -<span id="L267" class="LineNr">267 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L268" class="LineNr">268 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: .a\n"</span> -<span id="L269" class="LineNr">269 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: b\n"</span> -<span id="L270" class="LineNr">270 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: c\n"</span> -<span id="L271" class="LineNr">271 </span> <span class="Delimiter">);</span> -<span id="L272" class="LineNr">272 </span><span class="Delimiter">}</span> -<span id="L273" class="LineNr">273 </span> -<span id="L274" class="LineNr">274 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L274'>test_parse2_metadata</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L275" class="LineNr">275 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L276" class="LineNr">276 </span> <span class="Constant">".a b/c d\n"</span> -<span id="L277" class="LineNr">277 </span> <span class="Delimiter">);</span> -<span id="L278" class="LineNr">278 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L279" class="LineNr">279 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: .a\n"</span> -<span id="L280" class="LineNr">280 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: b /c\n"</span> -<span id="L281" class="LineNr">281 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: d\n"</span> -<span id="L282" class="LineNr">282 </span> <span class="Delimiter">);</span> -<span id="L283" class="LineNr">283 </span><span class="Delimiter">}</span> -<span id="L284" class="LineNr">284 </span> -<span id="L285" class="LineNr">285 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L285'>test_parse2_string_with_metadata</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L286" class="LineNr">286 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L287" class="LineNr">287 </span> <span class="Constant">"a \"</span>bc def\<span class="Constant">"/disp32 g\n"</span> -<span id="L288" class="LineNr">288 </span> <span class="Delimiter">);</span> -<span id="L289" class="LineNr">289 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L290" class="LineNr">290 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: a\n"</span> -<span id="L291" class="LineNr">291 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: \"</span>bc def\<span class="Constant">" /disp32\n"</span> -<span id="L292" class="LineNr">292 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: g\n"</span> -<span id="L293" class="LineNr">293 </span> <span class="Delimiter">);</span> -<span id="L294" class="LineNr">294 </span><span class="Delimiter">}</span> -<span id="L295" class="LineNr">295 </span> -<span id="L296" class="LineNr">296 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L296'>test_parse2_string_with_metadata_at_end</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L297" class="LineNr">297 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L298" class="LineNr">298 </span> <span class="Constant">"a \"</span>bc def\<span class="Constant">"/disp32\n"</span> -<span id="L299" class="LineNr">299 </span> <span class="Delimiter">);</span> -<span id="L300" class="LineNr">300 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L301" class="LineNr">301 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: a\n"</span> -<span id="L302" class="LineNr">302 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: \"</span>bc def\<span class="Constant">" /disp32\n"</span> -<span id="L303" class="LineNr">303 </span> <span class="Delimiter">);</span> -<span id="L304" class="LineNr">304 </span><span class="Delimiter">}</span> -<span id="L305" class="LineNr">305 </span> -<span id="L306" class="LineNr">306 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L306'>test_parse2_string_with_metadata_at_end_of_line_without_newline</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L307" class="LineNr">307 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L308" class="LineNr">308 </span> <span class="Constant">"68/push \"</span>test\<span class="Constant">"/f"</span> <span class="Comment">// no newline, which is how calls from parse() will look</span> -<span id="L309" class="LineNr">309 </span> <span class="Delimiter">);</span> -<span id="L310" class="LineNr">310 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L311" class="LineNr">311 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: 68 /push\n"</span> -<span id="L312" class="LineNr">312 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: \"</span>test\<span class="Constant">" /f\n"</span> -<span id="L313" class="LineNr">313 </span> <span class="Delimiter">);</span> -<span id="L314" class="LineNr">314 </span><span class="Delimiter">}</span> -<span id="L315" class="LineNr">315 </span> -<span id="L316" class="LineNr">316 </span><span class="Comment">//: Make sure slashes inside strings don't trigger adding stuff from inside the</span> -<span id="L317" class="LineNr">317 </span><span class="Comment">//: string to metadata.</span> -<span id="L318" class="LineNr">318 </span> -<span id="L319" class="LineNr">319 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L319'>test_parse2_string_containing_slashes</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L320" class="LineNr">320 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L321" class="LineNr">321 </span> <span class="Constant">"a \"</span>bc/def\<span class="Constant">"/disp32\n"</span> -<span id="L322" class="LineNr">322 </span> <span class="Delimiter">);</span> -<span id="L323" class="LineNr">323 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L324" class="LineNr">324 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: \"</span>bc/def\<span class="Constant">" /disp32\n"</span> -<span id="L325" class="LineNr">325 </span> <span class="Delimiter">);</span> -<span id="L326" class="LineNr">326 </span><span class="Delimiter">}</span> -<span id="L327" class="LineNr">327 </span> -<span id="L328" class="LineNr">328 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L328'>test_instruction_with_string_literal_with_escaped_quote</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L329" class="LineNr">329 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L330" class="LineNr">330 </span> <span class="Constant">"\"</span>a\\\<span class="Constant">"b\"</span>\n<span class="Constant">" // escaped quote inside string</span> -<span id="L331" class="LineNr">331 </span><span class="Constant"> );</span> -<span id="L332" class="LineNr">332 </span><span class="Constant"> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a>(</span> -<span id="L333" class="LineNr">333 </span><span class="Constant"> "</span>parse2: <a href='011run.cc.html#L128'>word</a>: \<span class="Constant">"a\"</span>b\<span class="Constant">"\n"</span> -<span id="L334" class="LineNr">334 </span> <span class="Delimiter">);</span> -<span id="L335" class="LineNr">335 </span> <span class="Comment">// no other words</span> -<span id="L336" class="LineNr">336 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"parse2"</span><span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L337" class="LineNr">337 </span><span class="Delimiter">}</span> -<span id="L338" class="LineNr">338 </span> -<span id="L339" class="LineNr">339 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L339'>test_instruction_with_string_literal_with_escaped_backslash</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L340" class="LineNr">340 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> -<span id="L341" class="LineNr">341 </span> <span class="Constant">"\"</span>a\\\\b\<span class="Constant">"\n"</span> <span class="Comment">// escaped backslash inside string</span> -<span id="L342" class="LineNr">342 </span> <span class="Delimiter">);</span> -<span id="L343" class="LineNr">343 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L344" class="LineNr">344 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L128'>word</a>: \"</span>a\\b\<span class="Constant">"\n"</span> -<span id="L345" class="LineNr">345 </span> <span class="Delimiter">);</span> -<span id="L346" class="LineNr">346 </span> <span class="Comment">// no other words</span> -<span id="L347" class="LineNr">347 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"parse2"</span><span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L348" class="LineNr">348 </span><span class="Delimiter">}</span> +<span id="L23" class="LineNr"> 23 </span><span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='038---literal_strings.cc.html#L30'>transform_literal_strings</a><span class="Delimiter">);</span> +<span id="L24" class="LineNr"> 24 </span> +<span id="L25" class="LineNr"> 25 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L26" class="LineNr"> 26 </span><span class="Normal">int</span> <span class="Special">Next_auto_global</span> = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L27" class="LineNr"> 27 </span><span class="Delimiter">:(before "End Reset")</span> +<span id="L28" class="LineNr"> 28 </span><span class="Special">Next_auto_global</span> = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L29" class="LineNr"> 29 </span><span class="Delimiter">:(code)</span> +<span id="L30" class="LineNr"> 30 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L30'>transform_literal_strings</a><span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L31" class="LineNr"> 31 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- move literal strings to data segment"</span> << end<span class="Delimiter">();</span> +<span id="L32" class="LineNr"> 32 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L33" class="LineNr"> 33 </span> vector<line> new_lines<span class="Delimiter">;</span> +<span id="L34" class="LineNr"> 34 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> s = <span class="Constant">0</span><span class="Delimiter">;</span> s < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">);</span> ++s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L35" class="LineNr"> 35 </span> segment& seg = p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>s<span class="Delimiter">);</span> +<span id="L36" class="LineNr"> 36 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"segment '"</span> << seg<span class="Delimiter">.</span>name << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> +<span id="L37" class="LineNr"> 37 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>seg<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L38" class="LineNr"> 38 </span><span class="CommentedCode">//? cerr << seg.name << '/' << i << '\n';</span> +<span id="L39" class="LineNr"> 39 </span> line& <a href='011run.cc.html#L121'>line</a> = seg<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L40" class="LineNr"> 40 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span><a href='011run.cc.html#L121'>line</a><span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L41" class="LineNr"> 41 </span> word& curr = <a href='011run.cc.html#L121'>line</a><span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L42" class="LineNr"> 42 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> != <span class="Constant">'"'</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L43" class="LineNr"> 43 </span> ostringstream global_name<span class="Delimiter">;</span> +<span id="L44" class="LineNr"> 44 </span> global_name << <span class="Constant">"__subx_global_"</span> << <span class="Special">Next_auto_global</span><span class="Delimiter">;</span> +<span id="L45" class="LineNr"> 45 </span> ++<span class="Special">Next_auto_global</span><span class="Delimiter">;</span> +<span id="L46" class="LineNr"> 46 </span> <a href='038---literal_strings.cc.html#L57'>add_global_to_data_segment</a><span class="Delimiter">(</span>global_name<span class="Delimiter">.</span>str<span class="Delimiter">(),</span> curr<span class="Delimiter">,</span> new_lines<span class="Delimiter">);</span> +<span id="L47" class="LineNr"> 47 </span> curr<span class="Delimiter">.</span>data = global_name<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L48" class="LineNr"> 48 </span> <span class="Delimiter">}</span> +<span id="L49" class="LineNr"> 49 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"line after transform: '"</span> << data_to_string<span class="Delimiter">(</span>line<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> +<span id="L50" class="LineNr"> 50 </span> <span class="Delimiter">}</span> +<span id="L51" class="LineNr"> 51 </span> <span class="Delimiter">}</span> +<span id="L52" class="LineNr"> 52 </span> segment* data = find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"data"</span><span class="Delimiter">);</span> +<span id="L53" class="LineNr"> 53 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>data<span class="Delimiter">)</span> +<span id="L54" class="LineNr"> 54 </span> data<span class="Delimiter">-></span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>insert<span class="Delimiter">(</span>data<span class="Delimiter">-></span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>end<span class="Delimiter">(),</span> new_lines<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> new_lines<span class="Delimiter">.</span>end<span class="Delimiter">());</span> +<span id="L55" class="LineNr"> 55 </span><span class="Delimiter">}</span> +<span id="L56" class="LineNr"> 56 </span> +<span id="L57" class="LineNr"> 57 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L57'>add_global_to_data_segment</a><span class="Delimiter">(</span><span class="Normal">const</span> string& <a href='011run.cc.html#L111'>name</a><span class="Delimiter">,</span> <span class="Normal">const</span> word& value<span class="Delimiter">,</span> vector<line>& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L58" class="LineNr"> 58 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"adding global variable '"</span> << name << <span class="Constant">"' containing "</span> << value<span class="Delimiter">.</span>data << end<span class="Delimiter">();</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Comment">// emit label</span> +<span id="L60" class="LineNr"> 60 </span> out<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>label<span class="Delimiter">(</span><a href='011run.cc.html#L111'>name</a><span class="Delimiter">));</span> +<span id="L61" class="LineNr"> 61 </span> <span class="Comment">// emit size for size-prefixed array</span> +<span id="L62" class="LineNr"> 62 </span> out<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L121'>line</a><span class="Delimiter">());</span> +<span id="L63" class="LineNr"> 63 </span> emit_hex_bytes<span class="Delimiter">(</span>out<span class="Delimiter">.</span>back<span class="Delimiter">(),</span> <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>value<span class="Delimiter">.</span>data<span class="Delimiter">)</span>-<span class="Comment">/*</span><span class="Comment">skip quotes</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">4</span><span class="Comment">/*</span><span class="Comment">bytes</span><span class="Comment">*/</span><span class="Delimiter">);</span> +<span id="L64" class="LineNr"> 64 </span> <span class="Comment">// emit data byte by byte</span> +<span id="L65" class="LineNr"> 65 </span> out<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L121'>line</a><span class="Delimiter">());</span> +<span id="L66" class="LineNr"> 66 </span> line& curr = out<span class="Delimiter">.</span>back<span class="Delimiter">();</span> +<span id="L67" class="LineNr"> 67 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Comment">/*</span><span class="Comment">skip start quote</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>value<span class="Delimiter">.</span>data<span class="Delimiter">)</span>-<span class="Comment">/*</span><span class="Comment">skip end quote</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L68" class="LineNr"> 68 </span> <span class="Normal">char</span> c = value<span class="Delimiter">.</span>data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L69" class="LineNr"> 69 </span> curr<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L127'>word</a><span class="Delimiter">());</span> +<span id="L70" class="LineNr"> 70 </span> curr<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>data = <a href='032---operands.cc.html#L296'>hex_byte_to_string</a><span class="Delimiter">(</span>c<span class="Delimiter">);</span> +<span id="L71" class="LineNr"> 71 </span> curr<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>string<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">,</span> c<span class="Delimiter">));</span> +<span id="L72" class="LineNr"> 72 </span> <span class="Delimiter">}</span> +<span id="L73" class="LineNr"> 73 </span><span class="Delimiter">}</span> +<span id="L74" class="LineNr"> 74 </span> +<span id="L75" class="LineNr"> 75 </span><span class="Comment">//: Within strings, whitespace is significant. So we need to redo our instruction</span> +<span id="L76" class="LineNr"> 76 </span><span class="Comment">//: parsing.</span> +<span id="L77" class="LineNr"> 77 </span> +<span id="L78" class="LineNr"> 78 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L78'>test_instruction_with_string_literal</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L79" class="LineNr"> 79 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L80" class="LineNr"> 80 </span> <span class="Constant">"a \"</span>abc def\<span class="Constant">" z\n"</span> <span class="Comment">// two spaces inside string</span> +<span id="L81" class="LineNr"> 81 </span> <span class="Delimiter">);</span> +<span id="L82" class="LineNr"> 82 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L83" class="LineNr"> 83 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: a\n"</span> +<span id="L84" class="LineNr"> 84 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: \"</span>abc def\<span class="Constant">"\n"</span> +<span id="L85" class="LineNr"> 85 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: z\n"</span> +<span id="L86" class="LineNr"> 86 </span> <span class="Delimiter">);</span> +<span id="L87" class="LineNr"> 87 </span> <span class="Comment">// no other words</span> +<span id="L88" class="LineNr"> 88 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"parse2"</span><span class="Delimiter">,</span> <span class="Constant">3</span><span class="Delimiter">);</span> +<span id="L89" class="LineNr"> 89 </span><span class="Delimiter">}</span> +<span id="L90" class="LineNr"> 90 </span> +<span id="L91" class="LineNr"> 91 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L91'>test_string_literal_in_data_segment</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L92" class="LineNr"> 92 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> +<span id="L93" class="LineNr"> 93 </span> <span class="Constant">"== code 0x1\n"</span> +<span id="L94" class="LineNr"> 94 </span> <span class="Constant">"b8/copy X/imm32\n"</span> +<span id="L95" class="LineNr"> 95 </span> <span class="Constant">"== data 0x2000\n"</span> +<span id="L96" class="LineNr"> 96 </span> <span class="Constant">"X:\n"</span> +<span id="L97" class="LineNr"> 97 </span> <span class="Constant">"\"</span>test\<span class="Constant">"/imm32\n"</span> +<span id="L98" class="LineNr"> 98 </span> <span class="Delimiter">);</span> +<span id="L99" class="LineNr"> 99 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L100" class="LineNr">100 </span> <span class="Constant">"transform: -- move literal strings to data segment\n"</span> +<span id="L101" class="LineNr">101 </span> <span class="Constant">"transform: adding global variable '__subx_global_1' containing \"</span>test\<span class="Constant">"\n"</span> +<span id="L102" class="LineNr">102 </span> <span class="Constant">"transform: <a href='011run.cc.html#L121'>line</a> after transform: '__subx_global_1'\n"</span> +<span id="L103" class="LineNr">103 </span> <span class="Delimiter">);</span> +<span id="L104" class="LineNr">104 </span><span class="Delimiter">}</span> +<span id="L105" class="LineNr">105 </span> +<span id="L106" class="LineNr">106 </span><span class="Delimiter">:(before "End Line Parsing Special-cases(line_data -> l)")</span> +<span id="L107" class="LineNr">107 </span><span class="Normal">if</span> <span class="Delimiter">(</span>line_data<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">'"'</span><span class="Delimiter">)</span> != string::npos<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// can cause false-positives, but we can handle them</span> +<span id="L108" class="LineNr">108 </span> parse_instruction_character_by_character<span class="Delimiter">(</span>line_data<span class="Delimiter">,</span> l<span class="Delimiter">);</span> +<span id="L109" class="LineNr">109 </span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L110" class="LineNr">110 </span><span class="Delimiter">}</span> +<span id="L111" class="LineNr">111 </span> +<span id="L112" class="LineNr">112 </span><span class="Delimiter">:(code)</span> +<span id="L113" class="LineNr">113 </span><span class="Normal">void</span> parse_instruction_character_by_character<span class="Delimiter">(</span><span class="Normal">const</span> string& line_data<span class="Delimiter">,</span> vector<line>& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L114" class="LineNr">114 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>line_data<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="cSpecial">'\n'</span><span class="Delimiter">)</span> != string::npos && line_data<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="cSpecial">'\n'</span><span class="Delimiter">)</span> != line_data<span class="Delimiter">.</span>size<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L115" class="LineNr">115 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"parse_instruction_character_by_character: should receive only a single line\n"</span> << end<span class="Delimiter">();</span> +<span id="L116" class="LineNr">116 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L117" class="LineNr">117 </span> <span class="Delimiter">}</span> +<span id="L118" class="LineNr">118 </span> <span class="Comment">// parse literals</span> +<span id="L119" class="LineNr">119 </span> istringstream in<span class="Delimiter">(</span>line_data<span class="Delimiter">);</span> +<span id="L120" class="LineNr">120 </span> in >> std::noskipws<span class="Delimiter">;</span> +<span id="L121" class="LineNr">121 </span> <a href='011run.cc.html#L121'>line</a> result<span class="Delimiter">;</span> +<span id="L122" class="LineNr">122 </span> result<span class="Delimiter">.</span>original = line_data<span class="Delimiter">;</span> +<span id="L123" class="LineNr">123 </span> <span class="Comment">// add tokens (words or strings) one by one</span> +<span id="L124" class="LineNr">124 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L125" class="LineNr">125 </span> <a href='038---literal_strings.cc.html#L189'>skip_whitespace</a><span class="Delimiter">(</span>in<span class="Delimiter">);</span> +<span id="L126" class="LineNr">126 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L127" class="LineNr">127 </span> <span class="Normal">char</span> c = in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> +<span id="L128" class="LineNr">128 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// comment; drop rest of line</span> +<span id="L129" class="LineNr">129 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">':'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// line metadata; skip for now</span> +<span id="L130" class="LineNr">130 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'.'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L131" class="LineNr">131 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// comment token at end of line</span> +<span id="L132" class="LineNr">132 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()))</span> +<span id="L133" class="LineNr">133 </span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// '.' followed by space is comment token; skip</span> +<span id="L134" class="LineNr">134 </span> <span class="Delimiter">}</span> +<span id="L135" class="LineNr">135 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L127'>word</a><span class="Delimiter">());</span> +<span id="L136" class="LineNr">136 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'"'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L137" class="LineNr">137 </span> <span class="Comment">// string literal; slurp everything between quotes into data</span> +<span id="L138" class="LineNr">138 </span> ostringstream d<span class="Delimiter">;</span> +<span id="L139" class="LineNr">139 </span> d << c<span class="Delimiter">;</span> +<span id="L140" class="LineNr">140 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L141" class="LineNr">141 </span> in >> c<span class="Delimiter">;</span> +<span id="L142" class="LineNr">142 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="cSpecial">'\\'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L143" class="LineNr">143 </span> in >> c<span class="Delimiter">;</span> +<span id="L144" class="LineNr">144 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'n'</span><span class="Delimiter">)</span> d << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L145" class="LineNr">145 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'"'</span><span class="Delimiter">)</span> d << <span class="Constant">'"'</span><span class="Delimiter">;</span> +<span id="L146" class="LineNr">146 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="cSpecial">'\\'</span><span class="Delimiter">)</span> d << <span class="cSpecial">'\\'</span><span class="Delimiter">;</span> +<span id="L147" class="LineNr">147 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> +<span id="L148" class="LineNr">148 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"parse_instruction_character_by_character: unknown escape sequence '\\"</span> << c << <span class="Constant">"'\n"</span> << end<span class="Delimiter">();</span> +<span id="L149" class="LineNr">149 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L150" class="LineNr">150 </span> <span class="Delimiter">}</span> +<span id="L151" class="LineNr">151 </span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L152" class="LineNr">152 </span> <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Delimiter">{</span> +<span id="L153" class="LineNr">153 </span> d << c<span class="Delimiter">;</span> +<span id="L154" class="LineNr">154 </span> <span class="Delimiter">}</span> +<span id="L155" class="LineNr">155 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'"'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L156" class="LineNr">156 </span> <span class="Delimiter">}</span> +<span id="L157" class="LineNr">157 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>data = d<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L158" class="LineNr">158 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>original = d<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L159" class="LineNr">159 </span> <span class="Comment">// slurp metadata</span> +<span id="L160" class="LineNr">160 </span> ostringstream m<span class="Delimiter">;</span> +<span id="L161" class="LineNr">161 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>!isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">())</span> && <a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// peek can sometimes trigger eof(), so do it first</span> +<span id="L162" class="LineNr">162 </span> in >> c<span class="Delimiter">;</span> +<span id="L163" class="LineNr">163 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'/'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L164" class="LineNr">164 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!m<span class="Delimiter">.</span>str<span class="Delimiter">().</span>empty<span class="Delimiter">())</span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>m<span class="Delimiter">.</span>str<span class="Delimiter">());</span> +<span id="L165" class="LineNr">165 </span> m<span class="Delimiter">.</span>str<span class="Delimiter">(</span><span class="Constant">""</span><span class="Delimiter">);</span> +<span id="L166" class="LineNr">166 </span> <span class="Delimiter">}</span> +<span id="L167" class="LineNr">167 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> +<span id="L168" class="LineNr">168 </span> m << c<span class="Delimiter">;</span> +<span id="L169" class="LineNr">169 </span> <span class="Delimiter">}</span> +<span id="L170" class="LineNr">170 </span> <span class="Delimiter">}</span> +<span id="L171" class="LineNr">171 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!m<span class="Delimiter">.</span>str<span class="Delimiter">().</span>empty<span class="Delimiter">())</span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>m<span class="Delimiter">.</span>str<span class="Delimiter">());</span> +<span id="L172" class="LineNr">172 </span> <span class="Delimiter">}</span> +<span id="L173" class="LineNr">173 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> +<span id="L174" class="LineNr">174 </span> <span class="Comment">// not a string literal; slurp all characters until whitespace</span> +<span id="L175" class="LineNr">175 </span> ostringstream w<span class="Delimiter">;</span> +<span id="L176" class="LineNr">176 </span> w << c<span class="Delimiter">;</span> +<span id="L177" class="LineNr">177 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>!isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">())</span> && <a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// peek can sometimes trigger eof(), so do it first</span> +<span id="L178" class="LineNr">178 </span> in >> c<span class="Delimiter">;</span> +<span id="L179" class="LineNr">179 </span> w << c<span class="Delimiter">;</span> +<span id="L180" class="LineNr">180 </span> <span class="Delimiter">}</span> +<span id="L181" class="LineNr">181 </span> <a href='011run.cc.html#L209'>parse_word</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>str<span class="Delimiter">(),</span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">());</span> +<span id="L182" class="LineNr">182 </span> <span class="Delimiter">}</span> +<span id="L183" class="LineNr">183 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"parse2"</span><span class="Delimiter">)</span> << <span class="Constant">"word: "</span> << to_string<span class="Delimiter">(</span>result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">())</span> << end<span class="Delimiter">();</span> +<span id="L184" class="LineNr">184 </span> <span class="Delimiter">}</span> +<span id="L185" class="LineNr">185 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> +<span id="L186" class="LineNr">186 </span> out<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> +<span id="L187" class="LineNr">187 </span><span class="Delimiter">}</span> +<span id="L188" class="LineNr">188 </span> +<span id="L189" class="LineNr">189 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L189'>skip_whitespace</a><span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L190" class="LineNr">190 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">)</span> && isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()))</span> <span class="Delimiter">{</span> +<span id="L191" class="LineNr">191 </span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> +<span id="L192" class="LineNr">192 </span> <span class="Delimiter">}</span> +<span id="L193" class="LineNr">193 </span><span class="Delimiter">}</span> +<span id="L194" class="LineNr">194 </span> +<span id="L195" class="LineNr">195 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L195'>skip_comment</a><span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L196" class="LineNr">196 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">)</span> && in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L197" class="LineNr">197 </span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> +<span id="L198" class="LineNr">198 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>in<span class="Delimiter">)</span> && in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> +<span id="L199" class="LineNr">199 </span> <span class="Delimiter">}</span> +<span id="L200" class="LineNr">200 </span><span class="Delimiter">}</span> +<span id="L201" class="LineNr">201 </span> +<span id="L202" class="LineNr">202 </span><a href='011run.cc.html#L121'>line</a> label<span class="Delimiter">(</span>string s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L203" class="LineNr">203 </span> <a href='011run.cc.html#L121'>line</a> result<span class="Delimiter">;</span> +<span id="L204" class="LineNr">204 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L127'>word</a><span class="Delimiter">());</span> +<span id="L205" class="LineNr">205 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>data = <span class="Delimiter">(</span>s+<span class="Constant">":"</span><span class="Delimiter">);</span> +<span id="L206" class="LineNr">206 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L207" class="LineNr">207 </span><span class="Delimiter">}</span> +<span id="L208" class="LineNr">208 </span> +<span id="L209" class="LineNr">209 </span><span class="Comment">// helper for tests</span> +<span id="L210" class="LineNr">210 </span><span class="Normal">void</span> parse_instruction_character_by_character<span class="Delimiter">(</span><span class="Normal">const</span> string& line_data<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L211" class="LineNr">211 </span> vector<line> out<span class="Delimiter">;</span> +<span id="L212" class="LineNr">212 </span> parse_instruction_character_by_character<span class="Delimiter">(</span>line_data<span class="Delimiter">,</span> out<span class="Delimiter">);</span> +<span id="L213" class="LineNr">213 </span><span class="Delimiter">}</span> +<span id="L214" class="LineNr">214 </span> +<span id="L215" class="LineNr">215 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L215'>test_parse2_comment_token_in_middle</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L216" class="LineNr">216 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L217" class="LineNr">217 </span> <span class="Constant">"a . z\n"</span> +<span id="L218" class="LineNr">218 </span> <span class="Delimiter">);</span> +<span id="L219" class="LineNr">219 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L220" class="LineNr">220 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: a\n"</span> +<span id="L221" class="LineNr">221 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: z\n"</span> +<span id="L222" class="LineNr">222 </span> <span class="Delimiter">);</span> +<span id="L223" class="LineNr">223 </span> <a href='003trace.cc.html#L294'>CHECK_TRACE_DOESNT_CONTAIN</a><span class="Delimiter">(</span><span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: ."</span><span class="Delimiter">);</span> +<span id="L224" class="LineNr">224 </span> <span class="Comment">// no other words</span> +<span id="L225" class="LineNr">225 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"parse2"</span><span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> +<span id="L226" class="LineNr">226 </span><span class="Delimiter">}</span> +<span id="L227" class="LineNr">227 </span> +<span id="L228" class="LineNr">228 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L228'>test_parse2_word_starting_with_dot</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L229" class="LineNr">229 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L230" class="LineNr">230 </span> <span class="Constant">"a .b c\n"</span> +<span id="L231" class="LineNr">231 </span> <span class="Delimiter">);</span> +<span id="L232" class="LineNr">232 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L233" class="LineNr">233 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: a\n"</span> +<span id="L234" class="LineNr">234 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: .b\n"</span> +<span id="L235" class="LineNr">235 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: c\n"</span> +<span id="L236" class="LineNr">236 </span> <span class="Delimiter">);</span> +<span id="L237" class="LineNr">237 </span><span class="Delimiter">}</span> +<span id="L238" class="LineNr">238 </span> +<span id="L239" class="LineNr">239 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L239'>test_parse2_comment_token_at_start</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L240" class="LineNr">240 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L241" class="LineNr">241 </span> <span class="Constant">". a b\n"</span> +<span id="L242" class="LineNr">242 </span> <span class="Delimiter">);</span> +<span id="L243" class="LineNr">243 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L244" class="LineNr">244 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: a\n"</span> +<span id="L245" class="LineNr">245 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: b\n"</span> +<span id="L246" class="LineNr">246 </span> <span class="Delimiter">);</span> +<span id="L247" class="LineNr">247 </span> <a href='003trace.cc.html#L294'>CHECK_TRACE_DOESNT_CONTAIN</a><span class="Delimiter">(</span><span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: ."</span><span class="Delimiter">);</span> +<span id="L248" class="LineNr">248 </span><span class="Delimiter">}</span> +<span id="L249" class="LineNr">249 </span> +<span id="L250" class="LineNr">250 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L250'>test_parse2_comment_token_at_end</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L251" class="LineNr">251 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L252" class="LineNr">252 </span> <span class="Constant">"a b .\n"</span> +<span id="L253" class="LineNr">253 </span> <span class="Delimiter">);</span> +<span id="L254" class="LineNr">254 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L255" class="LineNr">255 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: a\n"</span> +<span id="L256" class="LineNr">256 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: b\n"</span> +<span id="L257" class="LineNr">257 </span> <span class="Delimiter">);</span> +<span id="L258" class="LineNr">258 </span> <a href='003trace.cc.html#L294'>CHECK_TRACE_DOESNT_CONTAIN</a><span class="Delimiter">(</span><span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: ."</span><span class="Delimiter">);</span> +<span id="L259" class="LineNr">259 </span><span class="Delimiter">}</span> +<span id="L260" class="LineNr">260 </span> +<span id="L261" class="LineNr">261 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L261'>test_parse2_word_starting_with_dot_at_start</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L262" class="LineNr">262 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L263" class="LineNr">263 </span> <span class="Constant">".a b c\n"</span> +<span id="L264" class="LineNr">264 </span> <span class="Delimiter">);</span> +<span id="L265" class="LineNr">265 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L266" class="LineNr">266 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: .a\n"</span> +<span id="L267" class="LineNr">267 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: b\n"</span> +<span id="L268" class="LineNr">268 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: c\n"</span> +<span id="L269" class="LineNr">269 </span> <span class="Delimiter">);</span> +<span id="L270" class="LineNr">270 </span><span class="Delimiter">}</span> +<span id="L271" class="LineNr">271 </span> +<span id="L272" class="LineNr">272 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L272'>test_parse2_metadata</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L273" class="LineNr">273 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L274" class="LineNr">274 </span> <span class="Constant">".a b/c d\n"</span> +<span id="L275" class="LineNr">275 </span> <span class="Delimiter">);</span> +<span id="L276" class="LineNr">276 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L277" class="LineNr">277 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: .a\n"</span> +<span id="L278" class="LineNr">278 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: b /c\n"</span> +<span id="L279" class="LineNr">279 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: d\n"</span> +<span id="L280" class="LineNr">280 </span> <span class="Delimiter">);</span> +<span id="L281" class="LineNr">281 </span><span class="Delimiter">}</span> +<span id="L282" class="LineNr">282 </span> +<span id="L283" class="LineNr">283 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L283'>test_parse2_string_with_metadata</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L284" class="LineNr">284 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L285" class="LineNr">285 </span> <span class="Constant">"a \"</span>bc def\<span class="Constant">"/disp32 g\n"</span> +<span id="L286" class="LineNr">286 </span> <span class="Delimiter">);</span> +<span id="L287" class="LineNr">287 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L288" class="LineNr">288 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: a\n"</span> +<span id="L289" class="LineNr">289 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: \"</span>bc def\<span class="Constant">" /disp32\n"</span> +<span id="L290" class="LineNr">290 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: g\n"</span> +<span id="L291" class="LineNr">291 </span> <span class="Delimiter">);</span> +<span id="L292" class="LineNr">292 </span><span class="Delimiter">}</span> +<span id="L293" class="LineNr">293 </span> +<span id="L294" class="LineNr">294 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L294'>test_parse2_string_with_metadata_at_end</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L295" class="LineNr">295 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L296" class="LineNr">296 </span> <span class="Constant">"a \"</span>bc def\<span class="Constant">"/disp32\n"</span> +<span id="L297" class="LineNr">297 </span> <span class="Delimiter">);</span> +<span id="L298" class="LineNr">298 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L299" class="LineNr">299 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: a\n"</span> +<span id="L300" class="LineNr">300 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: \"</span>bc def\<span class="Constant">" /disp32\n"</span> +<span id="L301" class="LineNr">301 </span> <span class="Delimiter">);</span> +<span id="L302" class="LineNr">302 </span><span class="Delimiter">}</span> +<span id="L303" class="LineNr">303 </span> +<span id="L304" class="LineNr">304 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L304'>test_parse2_string_with_metadata_at_end_of_line_without_newline</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L305" class="LineNr">305 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L306" class="LineNr">306 </span> <span class="Constant">"68/push \"</span>test\<span class="Constant">"/f"</span> <span class="Comment">// no newline, which is how calls from parse() will look</span> +<span id="L307" class="LineNr">307 </span> <span class="Delimiter">);</span> +<span id="L308" class="LineNr">308 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L309" class="LineNr">309 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: 68 /push\n"</span> +<span id="L310" class="LineNr">310 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: \"</span>test\<span class="Constant">" /f\n"</span> +<span id="L311" class="LineNr">311 </span> <span class="Delimiter">);</span> +<span id="L312" class="LineNr">312 </span><span class="Delimiter">}</span> +<span id="L313" class="LineNr">313 </span> +<span id="L314" class="LineNr">314 </span><span class="Comment">//: Make sure slashes inside strings don't trigger adding stuff from inside the</span> +<span id="L315" class="LineNr">315 </span><span class="Comment">//: string to metadata.</span> +<span id="L316" class="LineNr">316 </span> +<span id="L317" class="LineNr">317 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L317'>test_parse2_string_containing_slashes</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L318" class="LineNr">318 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L319" class="LineNr">319 </span> <span class="Constant">"a \"</span>bc/def\<span class="Constant">"/disp32\n"</span> +<span id="L320" class="LineNr">320 </span> <span class="Delimiter">);</span> +<span id="L321" class="LineNr">321 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L322" class="LineNr">322 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: \"</span>bc/def\<span class="Constant">" /disp32\n"</span> +<span id="L323" class="LineNr">323 </span> <span class="Delimiter">);</span> +<span id="L324" class="LineNr">324 </span><span class="Delimiter">}</span> +<span id="L325" class="LineNr">325 </span> +<span id="L326" class="LineNr">326 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L326'>test_instruction_with_string_literal_with_escaped_quote</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L327" class="LineNr">327 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L328" class="LineNr">328 </span> <span class="Constant">"\"</span>a\\\<span class="Constant">"b\"</span>\n<span class="Constant">" // escaped quote inside string</span> +<span id="L329" class="LineNr">329 </span><span class="Constant"> );</span> +<span id="L330" class="LineNr">330 </span><span class="Constant"> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a>(</span> +<span id="L331" class="LineNr">331 </span><span class="Constant"> "</span>parse2: <a href='011run.cc.html#L127'>word</a>: \<span class="Constant">"a\"</span>b\<span class="Constant">"\n"</span> +<span id="L332" class="LineNr">332 </span> <span class="Delimiter">);</span> +<span id="L333" class="LineNr">333 </span> <span class="Comment">// no other words</span> +<span id="L334" class="LineNr">334 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"parse2"</span><span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L335" class="LineNr">335 </span><span class="Delimiter">}</span> +<span id="L336" class="LineNr">336 </span> +<span id="L337" class="LineNr">337 </span><span class="Normal">void</span> <a href='038---literal_strings.cc.html#L337'>test_instruction_with_string_literal_with_escaped_backslash</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L338" class="LineNr">338 </span> parse_instruction_character_by_character<span class="Delimiter">(</span> +<span id="L339" class="LineNr">339 </span> <span class="Constant">"\"</span>a\\\\b\<span class="Constant">"\n"</span> <span class="Comment">// escaped backslash inside string</span> +<span id="L340" class="LineNr">340 </span> <span class="Delimiter">);</span> +<span id="L341" class="LineNr">341 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L342" class="LineNr">342 </span> <span class="Constant">"parse2: <a href='011run.cc.html#L127'>word</a>: \"</span>a\\b\<span class="Constant">"\n"</span> +<span id="L343" class="LineNr">343 </span> <span class="Delimiter">);</span> +<span id="L344" class="LineNr">344 </span> <span class="Comment">// no other words</span> +<span id="L345" class="LineNr">345 </span> <a href='003trace.cc.html#L296'>CHECK_TRACE_COUNT</a><span class="Delimiter">(</span><span class="Constant">"parse2"</span><span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L346" class="LineNr">346 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/039debug.cc.html b/html/039debug.cc.html index 34cb62e0..9552da5c 100644 --- a/html/039debug.cc.html +++ b/html/039debug.cc.html @@ -60,151 +60,153 @@ if ('onhashchange' in window) { <pre id='vimCodeElement'> <span id="L1" class="LineNr"> 1 </span><span class="SalientComment">//:: Some helpers for debugging.</span> <span id="L2" class="LineNr"> 2 </span> -<span id="L3" class="LineNr"> 3 </span><span class="Comment">//: Load the 'map' file generated during 'subx --debug translate' when running</span> -<span id="L4" class="LineNr"> 4 </span><span class="Comment">//: 'subx --debug --trace run'.</span> +<span id="L3" class="LineNr"> 3 </span><span class="Comment">//: Load the 'map' file generated during 'bootstrap --debug translate' when running</span> +<span id="L4" class="LineNr"> 4 </span><span class="Comment">//: 'bootstrap --trace run'.</span> <span id="L5" class="LineNr"> 5 </span><span class="Comment">//: (It'll only affect the trace.)</span> <span id="L6" class="LineNr"> 6 </span> <span id="L7" class="LineNr"> 7 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L8" class="LineNr"> 8 </span>map<<span class="Comment">/*</span><span class="Comment">address</span><span class="Comment">*/</span><span class="Normal">uint32_t</span><span class="Delimiter">,</span> string> <span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">;</span> <span class="Comment">// used only by 'subx run'</span> -<span id="L9" class="LineNr"> 9 </span>map<<span class="Comment">/*</span><span class="Comment">address</span><span class="Comment">*/</span><span class="Normal">uint32_t</span><span class="Delimiter">,</span> string> <span class="Special"><a href='039debug.cc.html#L9'>Source_line</a></span><span class="Delimiter">;</span> <span class="Comment">// used only by 'subx run'</span> -<span id="L10" class="LineNr"> 10 </span><span class="Delimiter">:(before "End --debug Settings")</span> +<span id="L8" class="LineNr"> 8 </span>map<<span class="Comment">/*</span><span class="Comment">address</span><span class="Comment">*/</span><span class="Normal">uint32_t</span><span class="Delimiter">,</span> string> <span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">;</span> <span class="Comment">// used only by 'bootstrap run'</span> +<span id="L9" class="LineNr"> 9 </span>map<<span class="Comment">/*</span><span class="Comment">address</span><span class="Comment">*/</span><span class="Normal">uint32_t</span><span class="Delimiter">,</span> string> <span class="Special"><a href='039debug.cc.html#L9'>Source_line</a></span><span class="Delimiter">;</span> <span class="Comment">// used only by 'bootstrap run'</span> +<span id="L10" class="LineNr"> 10 </span><span class="Delimiter">:(before "End --trace Settings")</span> <span id="L11" class="LineNr"> 11 </span><a href='039debug.cc.html#L14'>load_labels</a><span class="Delimiter">();</span> -<span id="L12" class="LineNr"> 12 </span><a href='039debug.cc.html#L26'>load_source_lines</a><span class="Delimiter">();</span> +<span id="L12" class="LineNr"> 12 </span><a href='039debug.cc.html#L27'>load_source_lines</a><span class="Delimiter">();</span> <span id="L13" class="LineNr"> 13 </span><span class="Delimiter">:(code)</span> <span id="L14" class="LineNr"> 14 </span><span class="Normal">void</span> <a href='039debug.cc.html#L14'>load_labels</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> <span id="L15" class="LineNr"> 15 </span> ifstream fin<span class="Delimiter">(</span><span class="Constant">"labels"</span><span class="Delimiter">);</span> -<span id="L16" class="LineNr"> 16 </span> fin >> std::hex<span class="Delimiter">;</span> -<span id="L17" class="LineNr"> 17 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>fin<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L18" class="LineNr"> 18 </span> <span class="Normal">uint32_t</span> addr = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L19" class="LineNr"> 19 </span> fin >> addr<span class="Delimiter">;</span> -<span id="L20" class="LineNr"> 20 </span> string <a href='011run.cc.html#L112'>name</a><span class="Delimiter">;</span> -<span id="L21" class="LineNr"> 21 </span> fin >> <a href='011run.cc.html#L112'>name</a><span class="Delimiter">;</span> -<span id="L22" class="LineNr"> 22 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> addr<span class="Delimiter">,</span> <a href='011run.cc.html#L112'>name</a><span class="Delimiter">);</span> -<span id="L23" class="LineNr"> 23 </span> <span class="Delimiter">}</span> -<span id="L24" class="LineNr"> 24 </span><span class="Delimiter">}</span> -<span id="L25" class="LineNr"> 25 </span> -<span id="L26" class="LineNr"> 26 </span><span class="Normal">void</span> <a href='039debug.cc.html#L26'>load_source_lines</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L27" class="LineNr"> 27 </span> ifstream fin<span class="Delimiter">(</span><span class="Constant">"source_lines"</span><span class="Delimiter">);</span> -<span id="L28" class="LineNr"> 28 </span> fin >> std::hex<span class="Delimiter">;</span> -<span id="L29" class="LineNr"> 29 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L277'>has_data</a><span class="Delimiter">(</span>fin<span class="Delimiter">))</span> <span class="Delimiter">{</span> -<span id="L30" class="LineNr"> 30 </span> <span class="Normal">uint32_t</span> addr = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L31" class="LineNr"> 31 </span> fin >> addr<span class="Delimiter">;</span> -<span id="L32" class="LineNr"> 32 </span> string <a href='011run.cc.html#L122'>line</a><span class="Delimiter">;</span> -<span id="L33" class="LineNr"> 33 </span> getline<span class="Delimiter">(</span>fin<span class="Delimiter">,</span> <a href='011run.cc.html#L122'>line</a><span class="Delimiter">);</span> -<span id="L34" class="LineNr"> 34 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L9'>Source_line</a></span><span class="Delimiter">,</span> addr<span class="Delimiter">,</span> <a href='039debug.cc.html#L111'>hacky_squeeze_out_whitespace</a><span class="Delimiter">(</span><a href='011run.cc.html#L122'>line</a><span class="Delimiter">));</span> -<span id="L35" class="LineNr"> 35 </span> <span class="Delimiter">}</span> -<span id="L36" class="LineNr"> 36 </span><span class="Delimiter">}</span> -<span id="L37" class="LineNr"> 37 </span> -<span id="L38" class="LineNr"> 38 </span><span class="Delimiter">:(after "Run One Instruction")</span> -<span id="L39" class="LineNr"> 39 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">))</span> -<span id="L40" class="LineNr"> 40 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"== label "</span> << get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L41" class="LineNr"> 41 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L9'>Source_line</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">))</span> -<span id="L42" class="LineNr"> 42 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L32'>EIP</a> << <span class="Constant">": "</span> << get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L9'>Source_line</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L43" class="LineNr"> 43 </span><span class="Normal">else</span> -<span id="L44" class="LineNr"> 44 </span> <span class="Comment">// no source line info; do what you can</span> -<span id="L45" class="LineNr"> 45 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L32'>EIP</a> << <span class="Constant">": "</span> << <a href='039debug.cc.html#L48'>debug_info</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L46" class="LineNr"> 46 </span> -<span id="L47" class="LineNr"> 47 </span><span class="Delimiter">:(code)</span> -<span id="L48" class="LineNr"> 48 </span>string <a href='039debug.cc.html#L48'>debug_info</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> inst_address<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L49" class="LineNr"> 49 </span> <span class="Normal">uint8_t</span> op = <a href='010---vm.cc.html#L171'>read_mem_u8</a><span class="Delimiter">(</span>inst_address<span class="Delimiter">);</span> -<span id="L50" class="LineNr"> 50 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>op != <span class="Constant">0xe8</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L51" class="LineNr"> 51 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L52" class="LineNr"> 52 </span> out << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span>op<span class="Delimiter">);</span> -<span id="L53" class="LineNr"> 53 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L54" class="LineNr"> 54 </span> <span class="Delimiter">}</span> -<span id="L55" class="LineNr"> 55 </span> <span class="Normal">int32_t</span> offset = <a href='010---vm.cc.html#L182'>read_mem_i32</a><span class="Delimiter">(</span>inst_address+<span class="Comment">/*</span><span class="Comment">skip op</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> -<span id="L56" class="LineNr"> 56 </span> <span class="Normal">uint32_t</span> next_eip = inst_address+<span class="Comment">/*</span><span class="Comment">inst length</span><span class="Comment">*/</span><span class="Constant">5</span>+offset<span class="Delimiter">;</span> -<span id="L57" class="LineNr"> 57 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> next_eip<span class="Delimiter">))</span> -<span id="L58" class="LineNr"> 58 </span> <span class="Identifier">return</span> <span class="Constant">"e8/call "</span>+get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> next_eip<span class="Delimiter">);</span> -<span id="L59" class="LineNr"> 59 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L60" class="LineNr"> 60 </span> out << <span class="Constant">"e8/call 0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << next_eip<span class="Delimiter">;</span> -<span id="L61" class="LineNr"> 61 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L62" class="LineNr"> 62 </span><span class="Delimiter">}</span> -<span id="L63" class="LineNr"> 63 </span> -<span id="L64" class="LineNr"> 64 </span><span class="Comment">//: If a label starts with '$watch-', make a note of the effective address</span> -<span id="L65" class="LineNr"> 65 </span><span class="Comment">//: computed by the next instruction. Start dumping out its contents to the</span> -<span id="L66" class="LineNr"> 66 </span><span class="Comment">//: trace after every subsequent instruction.</span> -<span id="L67" class="LineNr"> 67 </span> -<span id="L68" class="LineNr"> 68 </span><span class="Delimiter">:(after "Run One Instruction")</span> -<span id="L69" class="LineNr"> 69 </span><a href='039debug.cc.html#L75'>dump_watch_points</a><span class="Delimiter">();</span> -<span id="L70" class="LineNr"> 70 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L71" class="LineNr"> 71 </span>map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>> <span class="Special"><a href='039debug.cc.html#L71'>Watch_points</a></span><span class="Delimiter">;</span> -<span id="L72" class="LineNr"> 72 </span><span class="Delimiter">:(before "End Reset")</span> -<span id="L73" class="LineNr"> 73 </span><span class="Special"><a href='039debug.cc.html#L71'>Watch_points</a></span><span class="Delimiter">.</span>clear<span class="Delimiter">();</span> -<span id="L74" class="LineNr"> 74 </span><span class="Delimiter">:(code)</span> -<span id="L75" class="LineNr"> 75 </span><span class="Normal">void</span> <a href='039debug.cc.html#L75'>dump_watch_points</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L76" class="LineNr"> 76 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L71'>Watch_points</a></span><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L77" class="LineNr"> 77 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span><span class="Delimiter">,</span> <span class="Constant">"dbg"</span><span class="Delimiter">)</span> << <span class="Constant">"watch points:"</span> << end<span class="Delimiter">();</span> -<span id="L78" class="LineNr"> 78 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>>::iterator p = <span class="Special"><a href='039debug.cc.html#L71'>Watch_points</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='039debug.cc.html#L71'>Watch_points</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> -<span id="L79" class="LineNr"> 79 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span><span class="Delimiter">,</span> <span class="Constant">"dbg"</span><span class="Delimiter">)</span> << <span class="Constant">" "</span> << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << p<span class="Delimiter">-></span>second << <span class="Constant">" -> "</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <a href='010---vm.cc.html#L178'>read_mem_u32</a><span class="Delimiter">(</span>p<span class="Delimiter">-></span>second<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> -<span id="L80" class="LineNr"> 80 </span><span class="Delimiter">}</span> -<span id="L81" class="LineNr"> 81 </span> -<span id="L82" class="LineNr"> 82 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L83" class="LineNr"> 83 </span>string <span class="Special">Watch_this_effective_address</span><span class="Delimiter">;</span> -<span id="L84" class="LineNr"> 84 </span><span class="Delimiter">:(after "Run One Instruction")</span> -<span id="L85" class="LineNr"> 85 </span><span class="Special">Watch_this_effective_address</span> = <span class="Constant">""</span><span class="Delimiter">;</span> -<span id="L86" class="LineNr"> 86 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">)</span> && <a href='001help.cc.html#L105'>starts_with</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">),</span> <span class="Constant">"$watch-"</span><span class="Delimiter">))</span> -<span id="L87" class="LineNr"> 87 </span> <span class="Special">Watch_this_effective_address</span> = get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">);</span> -<span id="L88" class="LineNr"> 88 </span><span class="Delimiter">:(after "Found <a href='013direct_addressing.cc.html#L101'>effective_address</a>(addr)")</span> -<span id="L89" class="LineNr"> 89 </span><span class="Normal">if</span> <span class="Delimiter">(</span>!<span class="Special">Watch_this_effective_address</span><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L90" class="LineNr"> 90 </span> <a href='003trace.cc.html#L441'>dbg</a> << <span class="Constant">"now watching "</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << addr << <span class="Constant">" for "</span> << <span class="Special">Watch_this_effective_address</span> << end<span class="Delimiter">();</span> -<span id="L91" class="LineNr"> 91 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L71'>Watch_points</a></span><span class="Delimiter">,</span> <span class="Special">Watch_this_effective_address</span><span class="Delimiter">,</span> addr<span class="Delimiter">);</span> -<span id="L92" class="LineNr"> 92 </span><span class="Delimiter">}</span> -<span id="L93" class="LineNr"> 93 </span> -<span id="L94" class="LineNr"> 94 </span><span class="Comment">//: Special label that dumps regions of memory.</span> -<span id="L95" class="LineNr"> 95 </span><span class="Comment">//: Not a general mechanism; by the time you get here you're willing to hack</span> -<span id="L96" class="LineNr"> 96 </span><span class="Comment">//: on the emulator.</span> -<span id="L97" class="LineNr"> 97 </span><span class="Delimiter">:(after "Run One Instruction")</span> -<span id="L98" class="LineNr"> 98 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">)</span> && get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L32'>EIP</a><span class="Delimiter">)</span> == <span class="Constant">"$dump-stream-at-EAX"</span><span class="Delimiter">)</span> -<span id="L99" class="LineNr"> 99 </span> <a href='039debug.cc.html#L101'>dump_stream_at</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> -<span id="L100" class="LineNr">100 </span><span class="Delimiter">:(code)</span> -<span id="L101" class="LineNr">101 </span><span class="Normal">void</span> <a href='039debug.cc.html#L101'>dump_stream_at</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> stream_start<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L102" class="LineNr">102 </span> <span class="Normal">int32_t</span> stream_length = <a href='010---vm.cc.html#L182'>read_mem_i32</a><span class="Delimiter">(</span>stream_start + <span class="Constant">8</span><span class="Delimiter">);</span> -<span id="L103" class="LineNr">103 </span> <a href='003trace.cc.html#L441'>dbg</a> << <span class="Constant">"stream length: "</span> << std::dec << stream_length << end<span class="Delimiter">();</span> -<span id="L104" class="LineNr">104 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < stream_length + <span class="Constant">12</span><span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> -<span id="L105" class="LineNr">105 </span> <a href='003trace.cc.html#L441'>dbg</a> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Delimiter">(</span>stream_start+i<span class="Delimiter">)</span> << <span class="Constant">": "</span> << <a href='010---vm.cc.html#L400'>HEXBYTE</a> << <a href='010---vm.cc.html#L403'>NUM</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L171'>read_mem_u8</a><span class="Delimiter">(</span>stream_start+i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> -<span id="L106" class="LineNr">106 </span><span class="Delimiter">}</span> -<span id="L107" class="LineNr">107 </span> -<span id="L108" class="LineNr">108 </span><span class="Comment">//: helpers</span> +<span id="L16" class="LineNr"> 16 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>fin<span class="Delimiter">.</span>fail<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L17" class="LineNr"> 17 </span> fin >> std::hex<span class="Delimiter">;</span> +<span id="L18" class="LineNr"> 18 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>fin<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L19" class="LineNr"> 19 </span> <span class="Normal">uint32_t</span> addr = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L20" class="LineNr"> 20 </span> fin >> addr<span class="Delimiter">;</span> +<span id="L21" class="LineNr"> 21 </span> string <a href='011run.cc.html#L111'>name</a><span class="Delimiter">;</span> +<span id="L22" class="LineNr"> 22 </span> fin >> <a href='011run.cc.html#L111'>name</a><span class="Delimiter">;</span> +<span id="L23" class="LineNr"> 23 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> addr<span class="Delimiter">,</span> <a href='011run.cc.html#L111'>name</a><span class="Delimiter">);</span> +<span id="L24" class="LineNr"> 24 </span> <span class="Delimiter">}</span> +<span id="L25" class="LineNr"> 25 </span><span class="Delimiter">}</span> +<span id="L26" class="LineNr"> 26 </span> +<span id="L27" class="LineNr"> 27 </span><span class="Normal">void</span> <a href='039debug.cc.html#L27'>load_source_lines</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L28" class="LineNr"> 28 </span> ifstream fin<span class="Delimiter">(</span><span class="Constant">"source_lines"</span><span class="Delimiter">);</span> +<span id="L29" class="LineNr"> 29 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>fin<span class="Delimiter">.</span>fail<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L30" class="LineNr"> 30 </span> fin >> std::hex<span class="Delimiter">;</span> +<span id="L31" class="LineNr"> 31 </span> <span class="Normal">while</span> <span class="Delimiter">(</span><a href='001help.cc.html#L251'>has_data</a><span class="Delimiter">(</span>fin<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L32" class="LineNr"> 32 </span> <span class="Normal">uint32_t</span> addr = <span class="Constant">0</span><span class="Delimiter">;</span> +<span id="L33" class="LineNr"> 33 </span> fin >> addr<span class="Delimiter">;</span> +<span id="L34" class="LineNr"> 34 </span> string <a href='011run.cc.html#L121'>line</a><span class="Delimiter">;</span> +<span id="L35" class="LineNr"> 35 </span> getline<span class="Delimiter">(</span>fin<span class="Delimiter">,</span> <a href='011run.cc.html#L121'>line</a><span class="Delimiter">);</span> +<span id="L36" class="LineNr"> 36 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L9'>Source_line</a></span><span class="Delimiter">,</span> addr<span class="Delimiter">,</span> <a href='039debug.cc.html#L113'>hacky_squeeze_out_whitespace</a><span class="Delimiter">(</span><a href='011run.cc.html#L121'>line</a><span class="Delimiter">));</span> +<span id="L37" class="LineNr"> 37 </span> <span class="Delimiter">}</span> +<span id="L38" class="LineNr"> 38 </span><span class="Delimiter">}</span> +<span id="L39" class="LineNr"> 39 </span> +<span id="L40" class="LineNr"> 40 </span><span class="Delimiter">:(after "Run One Instruction")</span> +<span id="L41" class="LineNr"> 41 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">))</span> +<span id="L42" class="LineNr"> 42 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"== label "</span> << get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L43" class="LineNr"> 43 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L9'>Source_line</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">))</span> +<span id="L44" class="LineNr"> 44 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"inst: "</span> << get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L9'>Source_line</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L45" class="LineNr"> 45 </span><span class="Normal">else</span> +<span id="L46" class="LineNr"> 46 </span> <span class="Comment">// no source line info; do what you can</span> +<span id="L47" class="LineNr"> 47 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"inst: "</span> << <a href='039debug.cc.html#L50'>debug_info</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L48" class="LineNr"> 48 </span> +<span id="L49" class="LineNr"> 49 </span><span class="Delimiter">:(code)</span> +<span id="L50" class="LineNr"> 50 </span>string <a href='039debug.cc.html#L50'>debug_info</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> inst_address<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L51" class="LineNr"> 51 </span> <span class="Normal">uint8_t</span> op = <a href='010---vm.cc.html#L165'>read_mem_u8</a><span class="Delimiter">(</span>inst_address<span class="Delimiter">);</span> +<span id="L52" class="LineNr"> 52 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>op != <span class="Constant">0xe8</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L53" class="LineNr"> 53 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L54" class="LineNr"> 54 </span> out << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span>op<span class="Delimiter">);</span> +<span id="L55" class="LineNr"> 55 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L56" class="LineNr"> 56 </span> <span class="Delimiter">}</span> +<span id="L57" class="LineNr"> 57 </span> <span class="Normal">int32_t</span> offset = <a href='010---vm.cc.html#L176'>read_mem_i32</a><span class="Delimiter">(</span>inst_address+<span class="Comment">/*</span><span class="Comment">skip op</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span id="L58" class="LineNr"> 58 </span> <span class="Normal">uint32_t</span> next_eip = inst_address+<span class="Comment">/*</span><span class="Comment">inst length</span><span class="Comment">*/</span><span class="Constant">5</span>+offset<span class="Delimiter">;</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> next_eip<span class="Delimiter">))</span> +<span id="L60" class="LineNr"> 60 </span> <span class="Identifier">return</span> <span class="Constant">"e8/call "</span>+get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> next_eip<span class="Delimiter">);</span> +<span id="L61" class="LineNr"> 61 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L62" class="LineNr"> 62 </span> out << <span class="Constant">"e8/call 0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << next_eip<span class="Delimiter">;</span> +<span id="L63" class="LineNr"> 63 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L64" class="LineNr"> 64 </span><span class="Delimiter">}</span> +<span id="L65" class="LineNr"> 65 </span> +<span id="L66" class="LineNr"> 66 </span><span class="Comment">//: If a label starts with '$watch-', make a note of the effective address</span> +<span id="L67" class="LineNr"> 67 </span><span class="Comment">//: computed by the next instruction. Start dumping out its contents to the</span> +<span id="L68" class="LineNr"> 68 </span><span class="Comment">//: trace after every subsequent instruction.</span> +<span id="L69" class="LineNr"> 69 </span> +<span id="L70" class="LineNr"> 70 </span><span class="Delimiter">:(after "Run One Instruction")</span> +<span id="L71" class="LineNr"> 71 </span><a href='039debug.cc.html#L77'>dump_watch_points</a><span class="Delimiter">();</span> +<span id="L72" class="LineNr"> 72 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L73" class="LineNr"> 73 </span>map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>> <span class="Special"><a href='039debug.cc.html#L73'>Watch_points</a></span><span class="Delimiter">;</span> +<span id="L74" class="LineNr"> 74 </span><span class="Delimiter">:(before "End Reset")</span> +<span id="L75" class="LineNr"> 75 </span><span class="Special"><a href='039debug.cc.html#L73'>Watch_points</a></span><span class="Delimiter">.</span>clear<span class="Delimiter">();</span> +<span id="L76" class="LineNr"> 76 </span><span class="Delimiter">:(code)</span> +<span id="L77" class="LineNr"> 77 </span><span class="Normal">void</span> <a href='039debug.cc.html#L77'>dump_watch_points</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L78" class="LineNr"> 78 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L73'>Watch_points</a></span><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L79" class="LineNr"> 79 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span><span class="Delimiter">,</span> <span class="Constant">"dbg"</span><span class="Delimiter">)</span> << <span class="Constant">"watch points:"</span> << end<span class="Delimiter">();</span> +<span id="L80" class="LineNr"> 80 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> <span class="Normal">uint32_t</span>>::iterator p = <span class="Special"><a href='039debug.cc.html#L73'>Watch_points</a></span><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <span class="Special"><a href='039debug.cc.html#L73'>Watch_points</a></span><span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> +<span id="L81" class="LineNr"> 81 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Special">Callstack_depth</span><span class="Delimiter">,</span> <span class="Constant">"dbg"</span><span class="Delimiter">)</span> << <span class="Constant">" "</span> << p<span class="Delimiter">-></span>first << <span class="Constant">": "</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << p<span class="Delimiter">-></span>second << <span class="Constant">" -> "</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <a href='010---vm.cc.html#L172'>read_mem_u32</a><span class="Delimiter">(</span>p<span class="Delimiter">-></span>second<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> +<span id="L82" class="LineNr"> 82 </span><span class="Delimiter">}</span> +<span id="L83" class="LineNr"> 83 </span> +<span id="L84" class="LineNr"> 84 </span><span class="Delimiter">:(before "End Globals")</span> +<span id="L85" class="LineNr"> 85 </span>string <span class="Special">Watch_this_effective_address</span><span class="Delimiter">;</span> +<span id="L86" class="LineNr"> 86 </span><span class="Delimiter">:(after "Run One Instruction")</span> +<span id="L87" class="LineNr"> 87 </span><span class="Special">Watch_this_effective_address</span> = <span class="Constant">""</span><span class="Delimiter">;</span> +<span id="L88" class="LineNr"> 88 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">)</span> && <a href='001help.cc.html#L106'>starts_with</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">),</span> <span class="Constant">"$watch-"</span><span class="Delimiter">))</span> +<span id="L89" class="LineNr"> 89 </span> <span class="Special">Watch_this_effective_address</span> = get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">);</span> +<span id="L90" class="LineNr"> 90 </span><span class="Delimiter">:(after "Found <a href='013direct_addressing.cc.html#L101'>effective_address</a>(addr)")</span> +<span id="L91" class="LineNr"> 91 </span><span class="Normal">if</span> <span class="Delimiter">(</span>!<span class="Special">Watch_this_effective_address</span><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L92" class="LineNr"> 92 </span> <a href='003trace.cc.html#L441'>dbg</a> << <span class="Constant">"now watching "</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << addr << <span class="Constant">" for "</span> << <span class="Special">Watch_this_effective_address</span> << end<span class="Delimiter">();</span> +<span id="L93" class="LineNr"> 93 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L73'>Watch_points</a></span><span class="Delimiter">,</span> <span class="Special">Watch_this_effective_address</span><span class="Delimiter">,</span> addr<span class="Delimiter">);</span> +<span id="L94" class="LineNr"> 94 </span><span class="Delimiter">}</span> +<span id="L95" class="LineNr"> 95 </span> +<span id="L96" class="LineNr"> 96 </span><span class="Comment">//: Special label that dumps regions of memory.</span> +<span id="L97" class="LineNr"> 97 </span><span class="Comment">//: Not a general mechanism; by the time you get here you're willing to hack</span> +<span id="L98" class="LineNr"> 98 </span><span class="Comment">//: on the emulator.</span> +<span id="L99" class="LineNr"> 99 </span><span class="Delimiter">:(after "Run One Instruction")</span> +<span id="L100" class="LineNr">100 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">)</span> && get<span class="Delimiter">(</span><span class="Special"><a href='039debug.cc.html#L8'>Symbol_name</a></span><span class="Delimiter">,</span> <a href='010---vm.cc.html#L26'>EIP</a><span class="Delimiter">)</span> == <span class="Constant">"$dump-stream-at-EAX"</span><span class="Delimiter">)</span> +<span id="L101" class="LineNr">101 </span> <a href='039debug.cc.html#L103'>dump_stream_at</a><span class="Delimiter">(</span><span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[EAX]<span class="Delimiter">.</span>u<span class="Delimiter">);</span> +<span id="L102" class="LineNr">102 </span><span class="Delimiter">:(code)</span> +<span id="L103" class="LineNr">103 </span><span class="Normal">void</span> <a href='039debug.cc.html#L103'>dump_stream_at</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> stream_start<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L104" class="LineNr">104 </span> <span class="Normal">int32_t</span> stream_length = <a href='010---vm.cc.html#L176'>read_mem_i32</a><span class="Delimiter">(</span>stream_start + <span class="Constant">8</span><span class="Delimiter">);</span> +<span id="L105" class="LineNr">105 </span> <a href='003trace.cc.html#L441'>dbg</a> << <span class="Constant">"stream length: "</span> << std::dec << stream_length << end<span class="Delimiter">();</span> +<span id="L106" class="LineNr">106 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < stream_length + <span class="Constant">12</span><span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> +<span id="L107" class="LineNr">107 </span> <a href='003trace.cc.html#L441'>dbg</a> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Delimiter">(</span>stream_start+i<span class="Delimiter">)</span> << <span class="Constant">": "</span> << <a href='010---vm.cc.html#L394'>HEXBYTE</a> << <a href='010---vm.cc.html#L397'>NUM</a><span class="Delimiter">(</span><a href='010---vm.cc.html#L165'>read_mem_u8</a><span class="Delimiter">(</span>stream_start+i<span class="Delimiter">))</span> << end<span class="Delimiter">();</span> +<span id="L108" class="LineNr">108 </span><span class="Delimiter">}</span> <span id="L109" class="LineNr">109 </span> -<span id="L110" class="LineNr">110 </span><span class="Delimiter">:(code)</span> -<span id="L111" class="LineNr">111 </span>string <a href='039debug.cc.html#L111'>hacky_squeeze_out_whitespace</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L112" class="LineNr">112 </span> <span class="Comment">// strip whitespace at start</span> -<span id="L113" class="LineNr">113 </span> string::const_iterator first = s<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> -<span id="L114" class="LineNr">114 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>first != s<span class="Delimiter">.</span>end<span class="Delimiter">()</span> && isspace<span class="Delimiter">(</span>*first<span class="Delimiter">))</span> -<span id="L115" class="LineNr">115 </span> ++first<span class="Delimiter">;</span> -<span id="L116" class="LineNr">116 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>first == s<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> -<span id="L117" class="LineNr">117 </span> -<span id="L118" class="LineNr">118 </span> <span class="Comment">// strip whitespace at end</span> -<span id="L119" class="LineNr">119 </span> string::const_iterator last = --s<span class="Delimiter">.</span>end<span class="Delimiter">();</span> -<span id="L120" class="LineNr">120 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>last != s<span class="Delimiter">.</span>begin<span class="Delimiter">()</span> && isspace<span class="Delimiter">(</span>*last<span class="Delimiter">))</span> -<span id="L121" class="LineNr">121 </span> --last<span class="Delimiter">;</span> -<span id="L122" class="LineNr">122 </span> ++last<span class="Delimiter">;</span> -<span id="L123" class="LineNr">123 </span> -<span id="L124" class="LineNr">124 </span> <span class="Comment">// replace runs of spaces/dots with single space until comment or string</span> -<span id="L125" class="LineNr">125 </span> <span class="Comment">// </span><span class="Todo">TODO</span><span class="Comment">:</span> -<span id="L126" class="LineNr">126 </span> <span class="Comment">// leave alone dots not surrounded by whitespace</span> -<span id="L127" class="LineNr">127 </span> <span class="Comment">// leave alone '#' within word</span> -<span id="L128" class="LineNr">128 </span> <span class="Comment">// leave alone '"' within word</span> -<span id="L129" class="LineNr">129 </span> <span class="Comment">// squeeze spaces after end of string</span> -<span id="L130" class="LineNr">130 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L131" class="LineNr">131 </span> <span class="Normal">bool</span> previous_was_space = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L132" class="LineNr">132 </span> <span class="Normal">bool</span> in_comment_or_string = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L133" class="LineNr">133 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>string::const_iterator curr = first<span class="Delimiter">;</span> curr != last<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L134" class="LineNr">134 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in_comment_or_string<span class="Delimiter">)</span> -<span id="L135" class="LineNr">135 </span> out << *curr<span class="Delimiter">;</span> -<span id="L136" class="LineNr">136 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>isspace<span class="Delimiter">(</span>*curr<span class="Delimiter">)</span> || *curr == <span class="Constant">'.'</span><span class="Delimiter">)</span> -<span id="L137" class="LineNr">137 </span> previous_was_space = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L138" class="LineNr">138 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L139" class="LineNr">139 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>previous_was_space<span class="Delimiter">)</span> -<span id="L140" class="LineNr">140 </span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L141" class="LineNr">141 </span> out << *curr<span class="Delimiter">;</span> -<span id="L142" class="LineNr">142 </span> previous_was_space = <span class="Constant">false</span><span class="Delimiter">;</span> -<span id="L143" class="LineNr">143 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*curr == <span class="Constant">'#'</span> || *curr == <span class="Constant">'"'</span><span class="Delimiter">)</span> in_comment_or_string = <span class="Constant">true</span><span class="Delimiter">;</span> -<span id="L144" class="LineNr">144 </span> <span class="Delimiter">}</span> -<span id="L145" class="LineNr">145 </span> <span class="Delimiter">}</span> -<span id="L146" class="LineNr">146 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L147" class="LineNr">147 </span><span class="Delimiter">}</span> +<span id="L110" class="LineNr">110 </span><span class="Comment">//: helpers</span> +<span id="L111" class="LineNr">111 </span> +<span id="L112" class="LineNr">112 </span><span class="Delimiter">:(code)</span> +<span id="L113" class="LineNr">113 </span>string <a href='039debug.cc.html#L113'>hacky_squeeze_out_whitespace</a><span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L114" class="LineNr">114 </span> <span class="Comment">// strip whitespace at start</span> +<span id="L115" class="LineNr">115 </span> string::const_iterator first = s<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> +<span id="L116" class="LineNr">116 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>first != s<span class="Delimiter">.</span>end<span class="Delimiter">()</span> && isspace<span class="Delimiter">(</span>*first<span class="Delimiter">))</span> +<span id="L117" class="LineNr">117 </span> ++first<span class="Delimiter">;</span> +<span id="L118" class="LineNr">118 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>first == s<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> +<span id="L119" class="LineNr">119 </span> +<span id="L120" class="LineNr">120 </span> <span class="Comment">// strip whitespace at end</span> +<span id="L121" class="LineNr">121 </span> string::const_iterator last = --s<span class="Delimiter">.</span>end<span class="Delimiter">();</span> +<span id="L122" class="LineNr">122 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>last != s<span class="Delimiter">.</span>begin<span class="Delimiter">()</span> && isspace<span class="Delimiter">(</span>*last<span class="Delimiter">))</span> +<span id="L123" class="LineNr">123 </span> --last<span class="Delimiter">;</span> +<span id="L124" class="LineNr">124 </span> ++last<span class="Delimiter">;</span> +<span id="L125" class="LineNr">125 </span> +<span id="L126" class="LineNr">126 </span> <span class="Comment">// replace runs of spaces/dots with single space until comment or string</span> +<span id="L127" class="LineNr">127 </span> <span class="Comment">// </span><span class="Todo">TODO</span><span class="Comment">:</span> +<span id="L128" class="LineNr">128 </span> <span class="Comment">// leave alone dots not surrounded by whitespace</span> +<span id="L129" class="LineNr">129 </span> <span class="Comment">// leave alone '#' within word</span> +<span id="L130" class="LineNr">130 </span> <span class="Comment">// leave alone '"' within word</span> +<span id="L131" class="LineNr">131 </span> <span class="Comment">// squeeze spaces after end of string</span> +<span id="L132" class="LineNr">132 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L133" class="LineNr">133 </span> <span class="Normal">bool</span> previous_was_space = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L134" class="LineNr">134 </span> <span class="Normal">bool</span> in_comment_or_string = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L135" class="LineNr">135 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>string::const_iterator curr = first<span class="Delimiter">;</span> curr != last<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L136" class="LineNr">136 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>in_comment_or_string<span class="Delimiter">)</span> +<span id="L137" class="LineNr">137 </span> out << *curr<span class="Delimiter">;</span> +<span id="L138" class="LineNr">138 </span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>isspace<span class="Delimiter">(</span>*curr<span class="Delimiter">)</span> || *curr == <span class="Constant">'.'</span><span class="Delimiter">)</span> +<span id="L139" class="LineNr">139 </span> previous_was_space = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L140" class="LineNr">140 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> +<span id="L141" class="LineNr">141 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>previous_was_space<span class="Delimiter">)</span> +<span id="L142" class="LineNr">142 </span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L143" class="LineNr">143 </span> out << *curr<span class="Delimiter">;</span> +<span id="L144" class="LineNr">144 </span> previous_was_space = <span class="Constant">false</span><span class="Delimiter">;</span> +<span id="L145" class="LineNr">145 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*curr == <span class="Constant">'#'</span> || *curr == <span class="Constant">'"'</span><span class="Delimiter">)</span> in_comment_or_string = <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L146" class="LineNr">146 </span> <span class="Delimiter">}</span> +<span id="L147" class="LineNr">147 </span> <span class="Delimiter">}</span> +<span id="L148" class="LineNr">148 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L149" class="LineNr">149 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/040---tests.cc.html b/html/040---tests.cc.html index a0cb8a6f..e2dbd53e 100644 --- a/html/040---tests.cc.html +++ b/html/040---tests.cc.html @@ -69,91 +69,89 @@ if ('onhashchange' in window) { <span id="L10" class="LineNr">10 </span><span class="Comment">//: We don't rely on any transforms running in previous layers, but this layer</span> <span id="L11" class="LineNr">11 </span><span class="Comment">//: knows about labels and will emit labels for previous layers to transform.</span> <span id="L12" class="LineNr">12 </span><span class="Delimiter">:(after "Begin Transforms")</span> -<span id="L13" class="LineNr">13 </span><span class="Comment">// Begin Level-4 Transforms</span> -<span id="L14" class="LineNr">14 </span><span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='040---tests.cc.html#L36'>create_test_function</a><span class="Delimiter">);</span> -<span id="L15" class="LineNr">15 </span><span class="Comment">// End Level-4 Transforms</span> -<span id="L16" class="LineNr">16 </span> -<span id="L17" class="LineNr">17 </span><span class="Delimiter">:(code)</span> -<span id="L18" class="LineNr">18 </span><span class="Normal">void</span> <a href='040---tests.cc.html#L18'>test_run_test</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L19" class="LineNr">19 </span> <span class="Special"><a href='010---vm.cc.html#L160'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> -<span id="L20" class="LineNr">20 </span> <span class="Special"><a href='010---vm.cc.html#L31'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000100</span><span class="Delimiter">;</span> -<span id="L21" class="LineNr">21 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> -<span id="L22" class="LineNr">22 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> -<span id="L23" class="LineNr">23 </span> <span class="Constant">"main:\n"</span> -<span id="L24" class="LineNr">24 </span> <span class="Constant">" e8/call run-tests/disp32\n"</span> <span class="Comment">// 5 bytes</span> -<span id="L25" class="LineNr">25 </span> <span class="Constant">" f4/halt\n"</span> <span class="Comment">// 1 byte</span> -<span id="L26" class="LineNr">26 </span> <span class="Constant">"test-foo:\n"</span> <span class="Comment">// offset 7</span> -<span id="L27" class="LineNr">27 </span> <span class="Constant">" 01 d8\n"</span> <span class="Comment">// just some unique instruction: add EBX to EAX</span> -<span id="L28" class="LineNr">28 </span> <span class="Constant">" c3/return\n"</span> -<span id="L29" class="LineNr">29 </span> <span class="Delimiter">);</span> -<span id="L30" class="LineNr">30 </span> <span class="Comment">// check that code in test-foo ran (implicitly called by run-tests)</span> -<span id="L31" class="LineNr">31 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> -<span id="L32" class="LineNr">32 </span> <span class="Constant">"run: 0x00000007 opcode: 01\n"</span> -<span id="L33" class="LineNr">33 </span> <span class="Delimiter">);</span> -<span id="L34" class="LineNr">34 </span><span class="Delimiter">}</span> -<span id="L35" class="LineNr">35 </span> -<span id="L36" class="LineNr">36 </span><span class="Normal">void</span> <a href='040---tests.cc.html#L36'>create_test_function</a><span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L37" class="LineNr">37 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L38" class="LineNr">38 </span> segment& code = *find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">);</span> -<span id="L39" class="LineNr">39 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- create 'run-tests'"</span> << end<span class="Delimiter">();</span> -<span id="L40" class="LineNr">40 </span> vector<line> new_insts<span class="Delimiter">;</span> -<span id="L41" class="LineNr">41 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L42" class="LineNr">42 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L43" class="LineNr">43 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L44" class="LineNr">44 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> -<span id="L45" class="LineNr">45 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*curr<span class="Delimiter">.</span>data<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> != <span class="Constant">':'</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// not a label</span> -<span id="L46" class="LineNr">46 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!starts_with<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">,</span> <span class="Constant">"test-"</span><span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L47" class="LineNr">47 </span> string fn = <a href='036labels.cc.html#L263'>drop_last</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> -<span id="L48" class="LineNr">48 </span> new_insts<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>call<span class="Delimiter">(</span>fn<span class="Delimiter">));</span> -<span id="L49" class="LineNr">49 </span> <span class="Delimiter">}</span> -<span id="L50" class="LineNr">50 </span> <span class="Delimiter">}</span> -<span id="L51" class="LineNr">51 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>new_insts<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// no tests found</span> -<span id="L52" class="LineNr">52 </span> code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>label<span class="Delimiter">(</span><span class="Constant">"run-tests"</span><span class="Delimiter">));</span> -<span id="L53" class="LineNr">53 </span> code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>insert<span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>end<span class="Delimiter">(),</span> new_insts<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> new_insts<span class="Delimiter">.</span>end<span class="Delimiter">());</span> -<span id="L54" class="LineNr">54 </span> code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='040---tests.cc.html#L91'>ret</a><span class="Delimiter">());</span> -<span id="L55" class="LineNr">55 </span><span class="Delimiter">}</span> -<span id="L56" class="LineNr">56 </span> -<span id="L57" class="LineNr">57 </span>string to_string<span class="Delimiter">(</span><span class="Normal">const</span> segment& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L58" class="LineNr">58 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L59" class="LineNr">59 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L60" class="LineNr">60 </span> <span class="Normal">const</span> line& l = s<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L61" class="LineNr">61 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>l<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L62" class="LineNr">62 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>j > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L63" class="LineNr">63 </span> out << to_string<span class="Delimiter">(</span>l<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span> -<span id="L64" class="LineNr">64 </span> <span class="Delimiter">}</span> -<span id="L65" class="LineNr">65 </span> out << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L66" class="LineNr">66 </span> <span class="Delimiter">}</span> -<span id="L67" class="LineNr">67 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L68" class="LineNr">68 </span><span class="Delimiter">}</span> -<span id="L69" class="LineNr">69 </span> -<span id="L70" class="LineNr">70 </span><a href='011run.cc.html#L122'>line</a> call<span class="Delimiter">(</span>string s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L71" class="LineNr">71 </span> <a href='011run.cc.html#L122'>line</a> result<span class="Delimiter">;</span> -<span id="L72" class="LineNr">72 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>call<span class="Delimiter">());</span> -<span id="L73" class="LineNr">73 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='040---tests.cc.html#L84'>disp32</a><span class="Delimiter">(</span>s<span class="Delimiter">));</span> -<span id="L74" class="LineNr">74 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L75" class="LineNr">75 </span><span class="Delimiter">}</span> -<span id="L76" class="LineNr">76 </span> -<span id="L77" class="LineNr">77 </span><a href='011run.cc.html#L128'>word</a> call<span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L78" class="LineNr">78 </span> <a href='011run.cc.html#L128'>word</a> result<span class="Delimiter">;</span> -<span id="L79" class="LineNr">79 </span> result<span class="Delimiter">.</span>data = <span class="Constant">"e8"</span><span class="Delimiter">;</span> -<span id="L80" class="LineNr">80 </span> result<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"call"</span><span class="Delimiter">);</span> -<span id="L81" class="LineNr">81 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L82" class="LineNr">82 </span><span class="Delimiter">}</span> -<span id="L83" class="LineNr">83 </span> -<span id="L84" class="LineNr">84 </span><a href='011run.cc.html#L128'>word</a> <a href='040---tests.cc.html#L84'>disp32</a><span class="Delimiter">(</span>string s<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L85" class="LineNr">85 </span> <a href='011run.cc.html#L128'>word</a> result<span class="Delimiter">;</span> -<span id="L86" class="LineNr">86 </span> result<span class="Delimiter">.</span>data = s<span class="Delimiter">;</span> -<span id="L87" class="LineNr">87 </span> result<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"disp32"</span><span class="Delimiter">);</span> -<span id="L88" class="LineNr">88 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L89" class="LineNr">89 </span><span class="Delimiter">}</span> -<span id="L90" class="LineNr">90 </span> -<span id="L91" class="LineNr">91 </span><a href='011run.cc.html#L122'>line</a> <a href='040---tests.cc.html#L91'>ret</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L92" class="LineNr">92 </span> <a href='011run.cc.html#L122'>line</a> result<span class="Delimiter">;</span> -<span id="L93" class="LineNr">93 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L128'>word</a><span class="Delimiter">());</span> -<span id="L94" class="LineNr">94 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>data = <span class="Constant">"c3"</span><span class="Delimiter">;</span> -<span id="L95" class="LineNr">95 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"return"</span><span class="Delimiter">);</span> -<span id="L96" class="LineNr">96 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> -<span id="L97" class="LineNr">97 </span><span class="Delimiter">}</span> +<span id="L13" class="LineNr">13 </span><span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='040---tests.cc.html#L34'>create_test_function</a><span class="Delimiter">);</span> +<span id="L14" class="LineNr">14 </span> +<span id="L15" class="LineNr">15 </span><span class="Delimiter">:(code)</span> +<span id="L16" class="LineNr">16 </span><span class="Normal">void</span> <a href='040---tests.cc.html#L16'>test_run_test</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L17" class="LineNr">17 </span> <span class="Special"><a href='010---vm.cc.html#L154'>Mem</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>vma<span class="Delimiter">(</span><span class="Constant">0xbd000000</span><span class="Delimiter">));</span> <span class="Comment">// manually allocate memory</span> +<span id="L18" class="LineNr">18 </span> <span class="Special"><a href='010---vm.cc.html#L25'>Reg</a></span>[ESP]<span class="Delimiter">.</span>u = <span class="Constant">0xbd000100</span><span class="Delimiter">;</span> +<span id="L19" class="LineNr">19 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> +<span id="L20" class="LineNr">20 </span> <span class="Constant">"== code 0x1\n"</span> <span class="Comment">// code segment</span> +<span id="L21" class="LineNr">21 </span> <span class="Constant">"main:\n"</span> +<span id="L22" class="LineNr">22 </span> <span class="Constant">" e8/call run-tests/disp32\n"</span> <span class="Comment">// 5 bytes</span> +<span id="L23" class="LineNr">23 </span> <span class="Constant">" f4/halt\n"</span> <span class="Comment">// 1 byte</span> +<span id="L24" class="LineNr">24 </span> <span class="Constant">"test-foo:\n"</span> <span class="Comment">// offset 7</span> +<span id="L25" class="LineNr">25 </span> <span class="Constant">" 01 d8\n"</span> <span class="Comment">// just some unique instruction: add EBX to EAX</span> +<span id="L26" class="LineNr">26 </span> <span class="Constant">" c3/return\n"</span> +<span id="L27" class="LineNr">27 </span> <span class="Delimiter">);</span> +<span id="L28" class="LineNr">28 </span> <span class="Comment">// check that code in test-foo ran (implicitly called by run-tests)</span> +<span id="L29" class="LineNr">29 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L30" class="LineNr">30 </span> <span class="Constant">"run: 0x00000007 opcode: 01\n"</span> +<span id="L31" class="LineNr">31 </span> <span class="Delimiter">);</span> +<span id="L32" class="LineNr">32 </span><span class="Delimiter">}</span> +<span id="L33" class="LineNr">33 </span> +<span id="L34" class="LineNr">34 </span><span class="Normal">void</span> <a href='040---tests.cc.html#L34'>create_test_function</a><span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L35" class="LineNr">35 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L36" class="LineNr">36 </span> segment& code = *find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">);</span> +<span id="L37" class="LineNr">37 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- create 'run-tests'"</span> << end<span class="Delimiter">();</span> +<span id="L38" class="LineNr">38 </span> vector<line> new_insts<span class="Delimiter">;</span> +<span id="L39" class="LineNr">39 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L40" class="LineNr">40 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L41" class="LineNr">41 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L42" class="LineNr">42 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L43" class="LineNr">43 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*curr<span class="Delimiter">.</span>data<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> != <span class="Constant">':'</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// not a label</span> +<span id="L44" class="LineNr">44 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!starts_with<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">,</span> <span class="Constant">"test-"</span><span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> +<span id="L45" class="LineNr">45 </span> string fn = <a href='036labels.cc.html#L263'>drop_last</a><span class="Delimiter">(</span>curr<span class="Delimiter">.</span>data<span class="Delimiter">);</span> +<span id="L46" class="LineNr">46 </span> new_insts<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>call<span class="Delimiter">(</span>fn<span class="Delimiter">));</span> +<span id="L47" class="LineNr">47 </span> <span class="Delimiter">}</span> +<span id="L48" class="LineNr">48 </span> <span class="Delimiter">}</span> +<span id="L49" class="LineNr">49 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>new_insts<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// no tests found</span> +<span id="L50" class="LineNr">50 </span> code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>label<span class="Delimiter">(</span><span class="Constant">"run-tests"</span><span class="Delimiter">));</span> +<span id="L51" class="LineNr">51 </span> code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>insert<span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>end<span class="Delimiter">(),</span> new_insts<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> new_insts<span class="Delimiter">.</span>end<span class="Delimiter">());</span> +<span id="L52" class="LineNr">52 </span> code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='040---tests.cc.html#L89'>ret</a><span class="Delimiter">());</span> +<span id="L53" class="LineNr">53 </span><span class="Delimiter">}</span> +<span id="L54" class="LineNr">54 </span> +<span id="L55" class="LineNr">55 </span>string to_string<span class="Delimiter">(</span><span class="Normal">const</span> segment& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L56" class="LineNr">56 </span> ostringstream out<span class="Delimiter">;</span> +<span id="L57" class="LineNr">57 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L58" class="LineNr">58 </span> <span class="Normal">const</span> line& l = s<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L59" class="LineNr">59 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>l<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L60" class="LineNr">60 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>j > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> +<span id="L61" class="LineNr">61 </span> out << to_string<span class="Delimiter">(</span>l<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">));</span> +<span id="L62" class="LineNr">62 </span> <span class="Delimiter">}</span> +<span id="L63" class="LineNr">63 </span> out << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L64" class="LineNr">64 </span> <span class="Delimiter">}</span> +<span id="L65" class="LineNr">65 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L66" class="LineNr">66 </span><span class="Delimiter">}</span> +<span id="L67" class="LineNr">67 </span> +<span id="L68" class="LineNr">68 </span><a href='011run.cc.html#L121'>line</a> call<span class="Delimiter">(</span>string s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L69" class="LineNr">69 </span> <a href='011run.cc.html#L121'>line</a> result<span class="Delimiter">;</span> +<span id="L70" class="LineNr">70 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>call<span class="Delimiter">());</span> +<span id="L71" class="LineNr">71 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='040---tests.cc.html#L82'>disp32</a><span class="Delimiter">(</span>s<span class="Delimiter">));</span> +<span id="L72" class="LineNr">72 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L73" class="LineNr">73 </span><span class="Delimiter">}</span> +<span id="L74" class="LineNr">74 </span> +<span id="L75" class="LineNr">75 </span><a href='011run.cc.html#L127'>word</a> call<span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L76" class="LineNr">76 </span> <a href='011run.cc.html#L127'>word</a> result<span class="Delimiter">;</span> +<span id="L77" class="LineNr">77 </span> result<span class="Delimiter">.</span>data = <span class="Constant">"e8"</span><span class="Delimiter">;</span> +<span id="L78" class="LineNr">78 </span> result<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"call"</span><span class="Delimiter">);</span> +<span id="L79" class="LineNr">79 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L80" class="LineNr">80 </span><span class="Delimiter">}</span> +<span id="L81" class="LineNr">81 </span> +<span id="L82" class="LineNr">82 </span><a href='011run.cc.html#L127'>word</a> <a href='040---tests.cc.html#L82'>disp32</a><span class="Delimiter">(</span>string s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L83" class="LineNr">83 </span> <a href='011run.cc.html#L127'>word</a> result<span class="Delimiter">;</span> +<span id="L84" class="LineNr">84 </span> result<span class="Delimiter">.</span>data = s<span class="Delimiter">;</span> +<span id="L85" class="LineNr">85 </span> result<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"disp32"</span><span class="Delimiter">);</span> +<span id="L86" class="LineNr">86 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L87" class="LineNr">87 </span><span class="Delimiter">}</span> +<span id="L88" class="LineNr">88 </span> +<span id="L89" class="LineNr">89 </span><a href='011run.cc.html#L121'>line</a> <a href='040---tests.cc.html#L89'>ret</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L90" class="LineNr">90 </span> <a href='011run.cc.html#L121'>line</a> result<span class="Delimiter">;</span> +<span id="L91" class="LineNr">91 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='011run.cc.html#L127'>word</a><span class="Delimiter">());</span> +<span id="L92" class="LineNr">92 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>data = <span class="Constant">"c3"</span><span class="Delimiter">;</span> +<span id="L93" class="LineNr">93 </span> result<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>back<span class="Delimiter">().</span>metadata<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"return"</span><span class="Delimiter">);</span> +<span id="L94" class="LineNr">94 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L95" class="LineNr">95 </span><span class="Delimiter">}</span> </pre> </body> </html> |