I spent a while spelunking into the code generated by C compilers before
realizing that ignoring the order of arguments for 'cmp' instructions
clarifies everything.
This commit is contained in:
Kartik K. Agaram 2017-10-14 23:33:27 -07:00
parent c67ca4b926
commit 311297cb00
4 changed files with 4 additions and 4 deletions

View File

@ -226,7 +226,7 @@ if ('onhashchange' in window) {
<span id="L161" class="LineNr">161 </span><span class="traceContains">+run: SF=0; ZF=0; OF=0</span>
<span id="L162" class="LineNr">162 </span>
<span id="L163" class="LineNr">163 </span><span class="Delimiter">:(before &quot;End Single-Byte Opcodes&quot;)</span>
<span id="L164" class="LineNr">164 </span><span class="Normal">case</span> <span class="Constant">0x39</span>: <span class="Delimiter">{</span> <span class="Comment">// compare r32 with r/m32</span>
<span id="L164" class="LineNr">164 </span><span class="Normal">case</span> <span class="Constant">0x39</span>: <span class="Delimiter">{</span> <span class="Comment">// set SF if r/m32 &lt; r32</span>
<span id="L165" class="LineNr">165 </span> <span class="Normal">uint8_t</span> modrm = <a href='010core.cc.html#L210'>next</a><span class="Delimiter">();</span>
<span id="L166" class="LineNr">166 </span> <span class="Normal">uint8_t</span> reg2 = <span class="Delimiter">(</span>modrm&gt;&gt;<span class="Constant">3</span><span class="Delimiter">)</span>&amp;<span class="Constant">0x7</span><span class="Delimiter">;</span>
<span id="L167" class="LineNr">167 </span> <a href='003trace.cc.html#L160'>trace</a><span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;compare <a href='010core.cc.html#L15'>reg</a> &quot;</span> &lt;&lt; <a href='010core.cc.html#L228'>NUM</a><span class="Delimiter">(</span>reg2<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot; with effective address&quot;</span> &lt;&lt; <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span>

View File

@ -302,7 +302,7 @@ if ('onhashchange' in window) {
<span id="L238" class="LineNr">238 </span><span class="traceContains">+run: SF=0; ZF=0; OF=0</span>
<span id="L239" class="LineNr">239 </span>
<span id="L240" class="LineNr">240 </span><span class="Delimiter">:(before &quot;End Single-Byte Opcodes&quot;)</span>
<span id="L241" class="LineNr">241 </span><span class="Normal">case</span> <span class="Constant">0x3b</span>: <span class="Delimiter">{</span> <span class="Comment">// compare r/m32 with r32</span>
<span id="L241" class="LineNr">241 </span><span class="Normal">case</span> <span class="Constant">0x3b</span>: <span class="Delimiter">{</span> <span class="Comment">// set SF if r32 &lt; r/m32</span>
<span id="L242" class="LineNr">242 </span> <span class="Normal">uint8_t</span> modrm = <a href='010core.cc.html#L210'>next</a><span class="Delimiter">();</span>
<span id="L243" class="LineNr">243 </span> <span class="Normal">uint8_t</span> reg1 = <span class="Delimiter">(</span>modrm&gt;&gt;<span class="Constant">3</span><span class="Delimiter">)</span>&amp;<span class="Constant">0x7</span><span class="Delimiter">;</span>
<span id="L244" class="LineNr">244 </span> <a href='003trace.cc.html#L160'>trace</a><span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;compare effective address with <a href='010core.cc.html#L15'>reg</a> &quot;</span> &lt;&lt; <a href='010core.cc.html#L228'>NUM</a><span class="Delimiter">(</span>reg1<span class="Delimiter">)</span> &lt;&lt; <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span>

View File

@ -161,7 +161,7 @@ case 0xf7: { // xor r32 with r/m32
+run: SF=0; ZF=0; OF=0
:(before "End Single-Byte Opcodes")
case 0x39: { // compare r32 with r/m32
case 0x39: { // set SF if r/m32 < r32
uint8_t modrm = next();
uint8_t reg2 = (modrm>>3)&0x7;
trace(2, "run") << "compare reg " << NUM(reg2) << " with effective address" << end();

View File

@ -238,7 +238,7 @@ case 0x33: { // xor r/m32 with r32
+run: SF=0; ZF=0; OF=0
:(before "End Single-Byte Opcodes")
case 0x3b: { // compare r/m32 with r32
case 0x3b: { // set SF if r32 < r/m32
uint8_t modrm = next();
uint8_t reg1 = (modrm>>3)&0x7;
trace(2, "run") << "compare effective address with reg " << NUM(reg1) << end();