diff options
-rw-r--r-- | html/subx/011direct_addressing.cc.html | 112 | ||||
-rw-r--r-- | html/subx/012indirect_addressing.cc.html | 75 | ||||
-rw-r--r-- | html/subx/013immediate_addressing.cc.html | 2 | ||||
-rw-r--r-- | subx/011direct_addressing.cc | 30 | ||||
-rw-r--r-- | subx/012indirect_addressing.cc | 19 |
5 files changed, 118 insertions, 120 deletions
diff --git a/html/subx/011direct_addressing.cc.html b/html/subx/011direct_addressing.cc.html index ba7a1e3b..7c348d47 100644 --- a/html/subx/011direct_addressing.cc.html +++ b/html/subx/011direct_addressing.cc.html @@ -287,59 +287,65 @@ if ('onhashchange' in window) { <span id="L222" class="LineNr">222 </span><span class="Special">% Reg[EBX].i = 0x0000000a;</span> <span id="L223" class="LineNr">223 </span><span class="Comment"># op ModRM SIB displacement immediate</span> <span id="L224" class="LineNr">224 </span> <span class="Constant">53</span> <span class="Comment"># push EBX (reg 3) to stack</span> -<span id="L225" class="LineNr">225 </span><span class="traceContains">+run: push <a href='010core.cc.html#L17'>reg</a> 3</span> -<span id="L226" class="LineNr">226 </span><span class="traceContains">+run: pushing value 0x0000000a</span> -<span id="L227" class="LineNr">227 </span><span class="traceContains">+run: <a href='010core.cc.html#L11'>ESP</a> is now 0x00000060</span> -<span id="L228" class="LineNr">228 </span><span class="traceContains">+run: <a href='003trace.cc.html#L74'>contents</a> at <a href='010core.cc.html#L11'>ESP</a>: 0x0000000a</span> -<span id="L229" class="LineNr">229 </span> -<span id="L230" class="LineNr">230 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> -<span id="L231" class="LineNr">231 </span><span class="Normal">case</span> <span class="Constant">0x50</span>: -<span id="L232" class="LineNr">232 </span><span class="Normal">case</span> <span class="Constant">0x51</span>: -<span id="L233" class="LineNr">233 </span><span class="Normal">case</span> <span class="Constant">0x52</span>: -<span id="L234" class="LineNr">234 </span><span class="Normal">case</span> <span class="Constant">0x53</span>: -<span id="L235" class="LineNr">235 </span><span class="Normal">case</span> <span class="Constant">0x54</span>: -<span id="L236" class="LineNr">236 </span><span class="Normal">case</span> <span class="Constant">0x55</span>: -<span id="L237" class="LineNr">237 </span><span class="Normal">case</span> <span class="Constant">0x56</span>: -<span id="L238" class="LineNr">238 </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="L239" class="LineNr">239 </span> <span class="Normal">uint8_t</span> <a href='010core.cc.html#L17'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> -<span id="L240" class="LineNr">240 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"push <a href='010core.cc.html#L17'>reg</a> "</span> << <a href='010core.cc.html#L232'>NUM</a><span class="Delimiter">(</span><a href='010core.cc.html#L17'>reg</a><span class="Delimiter">)</span> << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L241" class="LineNr">241 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span> val = Reg[reg]<span class="Delimiter">.</span>u<span class="Delimiter">;</span> -<span id="L242" class="LineNr">242 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pushing value 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << val << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L243" class="LineNr">243 </span> Reg[ESP]<span class="Delimiter">.</span>u -= <span class="Constant">4</span><span class="Delimiter">;</span> -<span id="L244" class="LineNr">244 </span> *<span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>&Mem<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Reg[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">))</span> = val<span class="Delimiter">;</span> -<span id="L245" class="LineNr">245 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"ESP is now 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << Reg[ESP]<span class="Delimiter">.</span>u << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L246" class="LineNr">246 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"contents at <a href='010core.cc.html#L11'>ESP</a>: 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << *<span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>&Mem<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Reg[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">))</span> << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L247" class="LineNr">247 </span> <span class="Identifier">break</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="SalientComment">//:: pop</span> -<span id="L251" class="LineNr">251 </span> -<span id="L252" class="LineNr">252 </span><span class="Delimiter">:(scenario pop_r32)</span> -<span id="L253" class="LineNr">253 </span><span class="Special">% Reg[ESP].u = 0x60;</span> -<span id="L254" class="LineNr">254 </span><span class="Special">% SET_WORD_IN_MEM(0x60, 0x0000000a);</span> -<span id="L255" class="LineNr">255 </span><span class="Comment"># op ModRM SIB displacement immediate</span> -<span id="L256" class="LineNr">256 </span> 5b <span class="Comment"># pop stack to EBX (reg 3)</span> -<span id="L257" class="LineNr">257 </span><span class="traceContains">+run: pop into <a href='010core.cc.html#L17'>reg</a> 3</span> -<span id="L258" class="LineNr">258 </span><span class="traceContains">+run: popping value 0x0000000a</span> -<span id="L259" class="LineNr">259 </span><span class="traceContains">+run: <a href='010core.cc.html#L11'>ESP</a> is now 0x00000064</span> -<span id="L260" class="LineNr">260 </span> -<span id="L261" class="LineNr">261 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> -<span id="L262" class="LineNr">262 </span><span class="Normal">case</span> <span class="Constant">0x58</span>: -<span id="L263" class="LineNr">263 </span><span class="Normal">case</span> <span class="Constant">0x59</span>: -<span id="L264" class="LineNr">264 </span><span class="Normal">case</span> <span class="Constant">0x5a</span>: -<span id="L265" class="LineNr">265 </span><span class="Normal">case</span> <span class="Constant">0x5b</span>: -<span id="L266" class="LineNr">266 </span><span class="Normal">case</span> <span class="Constant">0x5c</span>: -<span id="L267" class="LineNr">267 </span><span class="Normal">case</span> <span class="Constant">0x5d</span>: -<span id="L268" class="LineNr">268 </span><span class="Normal">case</span> <span class="Constant">0x5e</span>: -<span id="L269" class="LineNr">269 </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="L270" class="LineNr">270 </span> <span class="Normal">uint8_t</span> <a href='010core.cc.html#L17'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> -<span id="L271" class="LineNr">271 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pop into <a href='010core.cc.html#L17'>reg</a> "</span> << <a href='010core.cc.html#L232'>NUM</a><span class="Delimiter">(</span><a href='010core.cc.html#L17'>reg</a><span class="Delimiter">)</span> << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L272" class="LineNr">272 </span> Reg[reg]<span class="Delimiter">.</span>u = *<span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>&Mem<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Reg[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">));</span> -<span id="L273" class="LineNr">273 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"popping value 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << Reg[reg]<span class="Delimiter">.</span>u << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L274" class="LineNr">274 </span> Reg[ESP]<span class="Delimiter">.</span>u += <span class="Constant">4</span><span class="Delimiter">;</span> -<span id="L275" class="LineNr">275 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"ESP is now 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << Reg[ESP]<span class="Delimiter">.</span>u << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L276" class="LineNr">276 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L277" class="LineNr">277 </span><span class="Delimiter">}</span> +<span id="L225" class="LineNr">225 </span><span class="traceContains">+run: <a href='011direct_addressing.cc.html#L244'>push</a> <a href='010core.cc.html#L17'>reg</a> 3</span> +<span id="L226" class="LineNr">226 </span><span class="traceContains">+run: decrementing <a href='010core.cc.html#L11'>ESP</a> to 0x00000060</span> +<span id="L227" class="LineNr">227 </span><span class="traceContains">+run: pushing value 0x0000000a</span> +<span id="L228" class="LineNr">228 </span> +<span id="L229" class="LineNr">229 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> +<span id="L230" class="LineNr">230 </span><span class="Normal">case</span> <span class="Constant">0x50</span>: +<span id="L231" class="LineNr">231 </span><span class="Normal">case</span> <span class="Constant">0x51</span>: +<span id="L232" class="LineNr">232 </span><span class="Normal">case</span> <span class="Constant">0x52</span>: +<span id="L233" class="LineNr">233 </span><span class="Normal">case</span> <span class="Constant">0x53</span>: +<span id="L234" class="LineNr">234 </span><span class="Normal">case</span> <span class="Constant">0x54</span>: +<span id="L235" class="LineNr">235 </span><span class="Normal">case</span> <span class="Constant">0x55</span>: +<span id="L236" class="LineNr">236 </span><span class="Normal">case</span> <span class="Constant">0x56</span>: +<span id="L237" class="LineNr">237 </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="L238" class="LineNr">238 </span> <span class="Normal">uint8_t</span> <a href='010core.cc.html#L17'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> +<span id="L239" class="LineNr">239 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"push <a href='010core.cc.html#L17'>reg</a> "</span> << <a href='010core.cc.html#L232'>NUM</a><span class="Delimiter">(</span><a href='010core.cc.html#L17'>reg</a><span class="Delimiter">)</span> << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> +<span id="L240" class="LineNr">240 </span> <a href='011direct_addressing.cc.html#L244'>push</a><span class="Delimiter">(</span>Reg[reg]<span class="Delimiter">.</span>u<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 class="Delimiter">:(code)</span> +<span id="L244" class="LineNr">244 </span><span class="Normal">void</span> <a href='011direct_addressing.cc.html#L244'>push</a><span class="Delimiter">(</span><span class="Normal">uint32_t</span> val<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L245" class="LineNr">245 </span> Reg[ESP]<span class="Delimiter">.</span>u -= <span class="Constant">4</span><span class="Delimiter">;</span> +<span id="L246" class="LineNr">246 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"decrementing <a href='010core.cc.html#L11'>ESP</a> to 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << Reg[ESP]<span class="Delimiter">.</span>u << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> +<span id="L247" class="LineNr">247 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pushing value 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << val << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> +<span id="L248" class="LineNr">248 </span> *<span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>&Mem<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Reg[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">))</span> = val<span class="Delimiter">;</span> +<span id="L249" class="LineNr">249 </span><span class="Delimiter">}</span> +<span id="L250" class="LineNr">250 </span> +<span id="L251" class="LineNr">251 </span><span class="SalientComment">//:: pop</span> +<span id="L252" class="LineNr">252 </span> +<span id="L253" class="LineNr">253 </span><span class="Delimiter">:(scenario pop_r32)</span> +<span id="L254" class="LineNr">254 </span><span class="Special">% Reg[ESP].u = 0x60;</span> +<span id="L255" class="LineNr">255 </span><span class="Special">% SET_WORD_IN_MEM(0x60, 0x0000000a);</span> +<span id="L256" class="LineNr">256 </span><span class="Comment"># op ModRM SIB displacement immediate</span> +<span id="L257" class="LineNr">257 </span> 5b <span class="Comment"># pop stack to EBX (reg 3)</span> +<span id="L258" class="LineNr">258 </span><span class="traceContains">+run: <a href='011direct_addressing.cc.html#L277'>pop</a> into <a href='010core.cc.html#L17'>reg</a> 3</span> +<span id="L259" class="LineNr">259 </span><span class="traceContains">+run: popping value 0x0000000a</span> +<span id="L260" class="LineNr">260 </span><span class="traceContains">+run: incrementing <a href='010core.cc.html#L11'>ESP</a> to 0x00000064</span> +<span id="L261" class="LineNr">261 </span> +<span id="L262" class="LineNr">262 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> +<span id="L263" class="LineNr">263 </span><span class="Normal">case</span> <span class="Constant">0x58</span>: +<span id="L264" class="LineNr">264 </span><span class="Normal">case</span> <span class="Constant">0x59</span>: +<span id="L265" class="LineNr">265 </span><span class="Normal">case</span> <span class="Constant">0x5a</span>: +<span id="L266" class="LineNr">266 </span><span class="Normal">case</span> <span class="Constant">0x5b</span>: +<span id="L267" class="LineNr">267 </span><span class="Normal">case</span> <span class="Constant">0x5c</span>: +<span id="L268" class="LineNr">268 </span><span class="Normal">case</span> <span class="Constant">0x5d</span>: +<span id="L269" class="LineNr">269 </span><span class="Normal">case</span> <span class="Constant">0x5e</span>: +<span id="L270" class="LineNr">270 </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="L271" class="LineNr">271 </span> <span class="Normal">uint8_t</span> <a href='010core.cc.html#L17'>reg</a> = op & <span class="Constant">0x7</span><span class="Delimiter">;</span> +<span id="L272" class="LineNr">272 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pop into <a href='010core.cc.html#L17'>reg</a> "</span> << <a href='010core.cc.html#L232'>NUM</a><span class="Delimiter">(</span><a href='010core.cc.html#L17'>reg</a><span class="Delimiter">)</span> << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> +<span id="L273" class="LineNr">273 </span> Reg[reg]<span class="Delimiter">.</span>u = <a href='011direct_addressing.cc.html#L277'>pop</a><span class="Delimiter">();</span> +<span id="L274" class="LineNr">274 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L275" class="LineNr">275 </span><span class="Delimiter">}</span> +<span id="L276" class="LineNr">276 </span><span class="Delimiter">:(code)</span> +<span id="L277" class="LineNr">277 </span><span class="Normal">uint32_t</span> <a href='011direct_addressing.cc.html#L277'>pop</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> +<span id="L278" class="LineNr">278 </span> <span class="Normal">uint32_t</span> result = *<span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>&Mem<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Reg[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">));</span> +<span id="L279" class="LineNr">279 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"popping value 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << result << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> +<span id="L280" class="LineNr">280 </span> Reg[ESP]<span class="Delimiter">.</span>u += <span class="Constant">4</span><span class="Delimiter">;</span> +<span id="L281" class="LineNr">281 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"incrementing <a href='010core.cc.html#L11'>ESP</a> to 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << Reg[ESP]<span class="Delimiter">.</span>u << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> +<span id="L282" class="LineNr">282 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span id="L283" class="LineNr">283 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/subx/012indirect_addressing.cc.html b/html/subx/012indirect_addressing.cc.html index 35dd62ab..781b9ad2 100644 --- a/html/subx/012indirect_addressing.cc.html +++ b/html/subx/012indirect_addressing.cc.html @@ -412,53 +412,46 @@ if ('onhashchange' in window) { <span id="L347" class="LineNr">347 </span><span class="Special">% Reg[ESP].u = 0x14;</span> <span id="L348" class="LineNr">348 </span><span class="Comment"># op ModRM SIB displacement immediate</span> <span id="L349" class="LineNr">349 </span> ff <span class="Constant">30</span> <span class="Comment"># push *EAX (reg 0) to stack</span> -<span id="L350" class="LineNr">350 </span><span class="traceContains">+run: push effective address</span> +<span id="L350" class="LineNr">350 </span><span class="traceContains">+run: <a href='011direct_addressing.cc.html#L244'>push</a> effective address</span> <span id="L351" class="LineNr">351 </span><span class="traceContains">+run: effective address is mem at address 0x60 (reg 0)</span> -<span id="L352" class="LineNr">352 </span><span class="traceContains">+run: <a href='010core.cc.html#L11'>ESP</a> is now 0x00000010</span> -<span id="L353" class="LineNr">353 </span><span class="traceContains">+run: <a href='003trace.cc.html#L74'>contents</a> at <a href='010core.cc.html#L11'>ESP</a>: 0x000000af</span> +<span id="L352" class="LineNr">352 </span><span class="traceContains">+run: decrementing <a href='010core.cc.html#L11'>ESP</a> to 0x00000010</span> +<span id="L353" class="LineNr">353 </span><span class="traceContains">+run: pushing value 0x000000af</span> <span id="L354" class="LineNr">354 </span> <span id="L355" class="LineNr">355 </span><span class="Delimiter">:(before "End Op ff Subops")</span> <span id="L356" class="LineNr">356 </span><span class="Normal">case</span> <span class="Constant">6</span>: <span class="Delimiter">{</span> <span id="L357" class="LineNr">357 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"push effective address"</span> << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> <span id="L358" class="LineNr">358 </span> <span class="Normal">const</span> <span class="Normal">int32_t</span>* val = <a href='011direct_addressing.cc.html#L26'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L359" class="LineNr">359 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pushing value 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << *val << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L360" class="LineNr">360 </span> Reg[ESP]<span class="Delimiter">.</span>u -= <span class="Constant">4</span><span class="Delimiter">;</span> -<span id="L361" class="LineNr">361 </span> *<span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>&Mem<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Reg[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">))</span> = *val<span class="Delimiter">;</span> -<span id="L362" class="LineNr">362 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"ESP is now 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << Reg[ESP]<span class="Delimiter">.</span>u << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L363" class="LineNr">363 </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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"contents at <a href='010core.cc.html#L11'>ESP</a>: 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << *<span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>&Mem<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Reg[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">))</span> << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L364" class="LineNr">364 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L365" class="LineNr">365 </span><span class="Delimiter">}</span> -<span id="L366" class="LineNr">366 </span> -<span id="L367" class="LineNr">367 </span><span class="SalientComment">//:: pop</span> -<span id="L368" class="LineNr">368 </span> -<span id="L369" class="LineNr">369 </span><span class="Delimiter">:(scenario pop_mem_at_r32)</span> -<span id="L370" class="LineNr">370 </span><span class="Special">% Reg[0].i = 0x60;</span> -<span id="L371" class="LineNr">371 </span><span class="Special">% Reg[ESP].u = 0x10;</span> -<span id="L372" class="LineNr">372 </span><span class="Special">% SET_WORD_IN_MEM(0x10, 0x00000030);</span> -<span id="L373" class="LineNr">373 </span><span class="Comment"># op ModRM SIB displacement immediate</span> -<span id="L374" class="LineNr">374 </span> <span class="Constant">8f</span> <span class="PreProc">0</span><span class="Constant">0</span> <span class="Comment"># pop stack into *EAX (reg 0)</span> -<span id="L375" class="LineNr">375 </span><span class="traceContains">+run: pop into effective address</span> -<span id="L376" class="LineNr">376 </span><span class="traceContains">+run: effective address is mem at address 0x60 (reg 0)</span> -<span id="L377" class="LineNr">377 </span><span class="traceContains">+run: storing 0x00000030</span> -<span id="L378" class="LineNr">378 </span><span class="traceContains">+run: <a href='010core.cc.html#L11'>ESP</a> is now 0x00000014</span> -<span id="L379" class="LineNr">379 </span> -<span id="L380" class="LineNr">380 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> -<span id="L381" class="LineNr">381 </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="L382" class="LineNr">382 </span> <span class="Normal">uint8_t</span> modrm = <a href='010core.cc.html#L214'>next</a><span class="Delimiter">();</span> -<span id="L383" class="LineNr">383 </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="L384" class="LineNr">384 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>subop<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L385" class="LineNr">385 </span> <span class="Conceal">¦</span> <span class="Normal">case</span> <span class="Constant">0</span>: <span class="Delimiter">{</span> -<span id="L386" class="LineNr">386 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pop into effective address"</span> << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L387" class="LineNr">387 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">int32_t</span>* dest = <a href='011direct_addressing.cc.html#L26'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> -<span id="L388" class="LineNr">388 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> *dest = *<span class="Normal">reinterpret_cast</span><<span class="Normal">uint32_t</span>*><span class="Delimiter">(</span>&Mem<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Reg[ESP]<span class="Delimiter">.</span>u<span class="Delimiter">));</span> -<span id="L389" class="LineNr">389 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"storing 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << *dest << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L390" class="LineNr">390 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> Reg[ESP]<span class="Delimiter">.</span>u += <span class="Constant">4</span><span class="Delimiter">;</span> -<span id="L391" class="LineNr">391 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"ESP is now 0x"</span> << <a href='010core.cc.html#L230'>HEXWORD</a> << Reg[ESP]<span class="Delimiter">.</span>u << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> -<span id="L392" class="LineNr">392 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L393" class="LineNr">393 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> -<span id="L394" class="LineNr">394 </span> <span class="Delimiter">}</span> -<span id="L395" class="LineNr">395 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> -<span id="L396" class="LineNr">396 </span><span class="Delimiter">}</span> +<span id="L359" class="LineNr">359 </span> <a href='011direct_addressing.cc.html#L244'>push</a><span class="Delimiter">(</span>*val<span class="Delimiter">);</span> +<span id="L360" class="LineNr">360 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L361" class="LineNr">361 </span><span class="Delimiter">}</span> +<span id="L362" class="LineNr">362 </span> +<span id="L363" class="LineNr">363 </span><span class="SalientComment">//:: pop</span> +<span id="L364" class="LineNr">364 </span> +<span id="L365" class="LineNr">365 </span><span class="Delimiter">:(scenario pop_mem_at_r32)</span> +<span id="L366" class="LineNr">366 </span><span class="Special">% Reg[0].i = 0x60;</span> +<span id="L367" class="LineNr">367 </span><span class="Special">% Reg[ESP].u = 0x10;</span> +<span id="L368" class="LineNr">368 </span><span class="Special">% SET_WORD_IN_MEM(0x10, 0x00000030);</span> +<span id="L369" class="LineNr">369 </span><span class="Comment"># op ModRM SIB displacement immediate</span> +<span id="L370" class="LineNr">370 </span> <span class="Constant">8f</span> <span class="PreProc">0</span><span class="Constant">0</span> <span class="Comment"># pop stack into *EAX (reg 0)</span> +<span id="L371" class="LineNr">371 </span><span class="traceContains">+run: <a href='011direct_addressing.cc.html#L277'>pop</a> into effective address</span> +<span id="L372" class="LineNr">372 </span><span class="traceContains">+run: effective address is mem at address 0x60 (reg 0)</span> +<span id="L373" class="LineNr">373 </span><span class="traceContains">+run: popping value 0x00000030</span> +<span id="L374" class="LineNr">374 </span><span class="traceContains">+run: incrementing <a href='010core.cc.html#L11'>ESP</a> to 0x00000014</span> +<span id="L375" class="LineNr">375 </span> +<span id="L376" class="LineNr">376 </span><span class="Delimiter">:(before "End Single-Byte Opcodes")</span> +<span id="L377" class="LineNr">377 </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="L378" class="LineNr">378 </span> <span class="Normal">uint8_t</span> modrm = <a href='010core.cc.html#L214'>next</a><span class="Delimiter">();</span> +<span id="L379" class="LineNr">379 </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="L380" class="LineNr">380 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>subop<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L381" class="LineNr">381 </span> <span class="Conceal">¦</span> <span class="Normal">case</span> <span class="Constant">0</span>: <span class="Delimiter">{</span> +<span id="L382" class="LineNr">382 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</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">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"pop into effective address"</span> << <a href='003trace.cc.html#L184'>end</a><span class="Delimiter">();</span> +<span id="L383" class="LineNr">383 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">int32_t</span>* dest = <a href='011direct_addressing.cc.html#L26'>effective_address</a><span class="Delimiter">(</span>modrm<span class="Delimiter">);</span> +<span id="L384" class="LineNr">384 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> *dest = <a href='011direct_addressing.cc.html#L277'>pop</a><span class="Delimiter">();</span> +<span id="L385" class="LineNr">385 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L386" class="LineNr">386 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> +<span id="L387" class="LineNr">387 </span> <span class="Delimiter">}</span> +<span id="L388" class="LineNr">388 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> +<span id="L389" class="LineNr">389 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/subx/013immediate_addressing.cc.html b/html/subx/013immediate_addressing.cc.html index 80939a21..e8c646aa 100644 --- a/html/subx/013immediate_addressing.cc.html +++ b/html/subx/013immediate_addressing.cc.html @@ -440,7 +440,7 @@ if ('onhashchange' in window) { <span id="L376" class="LineNr">376 </span><span class="Special">% Reg[ESP].u = 0x14;</span> <span id="L377" class="LineNr">377 </span><span class="Comment"># op ModRM SIB displacement immediate</span> <span id="L378" class="LineNr">378 </span> <span class="Constant">68</span> af <span class="PreProc">0</span><span class="Constant">0</span> <span class="PreProc">0</span><span class="Constant">0</span> <span class="PreProc">0</span><span class="Constant">0</span> <span class="Comment"># push *EAX (reg 0) to stack</span> -<span id="L379" class="LineNr">379 </span><span class="traceContains">+run: push <a href='010core.cc.html#L219'>imm32</a> 0x000000af</span> +<span id="L379" class="LineNr">379 </span><span class="traceContains">+run: <a href='011direct_addressing.cc.html#L244'>push</a> <a href='010core.cc.html#L219'>imm32</a> 0x000000af</span> <span id="L380" class="LineNr">380 </span><span class="traceContains">+run: <a href='010core.cc.html#L11'>ESP</a> is now 0x00000010</span> <span id="L381" class="LineNr">381 </span><span class="traceContains">+run: <a href='003trace.cc.html#L74'>contents</a> at <a href='010core.cc.html#L11'>ESP</a>: 0x000000af</span> <span id="L382" class="LineNr">382 </span> diff --git a/subx/011direct_addressing.cc b/subx/011direct_addressing.cc index b3f234b3..9e5f6e80 100644 --- a/subx/011direct_addressing.cc +++ b/subx/011direct_addressing.cc @@ -223,9 +223,8 @@ case 0x89: { // copy r32 to r/m32 # op ModRM SIB displacement immediate 53 # push EBX (reg 3) to stack +run: push reg 3 ++run: decrementing ESP to 0x00000060 +run: pushing value 0x0000000a -+run: ESP is now 0x00000060 -+run: contents at ESP: 0x0000000a :(before "End Single-Byte Opcodes") case 0x50: @@ -238,13 +237,15 @@ case 0x56: case 0x57: { // push r32 to stack uint8_t reg = op & 0x7; trace(2, "run") << "push reg " << NUM(reg) << end(); - const int32_t val = Reg[reg].u; - trace(2, "run") << "pushing value 0x" << HEXWORD << val << end(); + push(Reg[reg].u); + break; +} +:(code) +void push(uint32_t val) { Reg[ESP].u -= 4; + trace(2, "run") << "decrementing ESP to 0x" << HEXWORD << Reg[ESP].u << end(); + trace(2, "run") << "pushing value 0x" << HEXWORD << val << end(); *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)) = val; - trace(2, "run") << "ESP is now 0x" << HEXWORD << Reg[ESP].u << end(); - trace(2, "run") << "contents at ESP: 0x" << HEXWORD << *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)) << end(); - break; } //:: pop @@ -256,7 +257,7 @@ case 0x57: { // push r32 to stack 5b # pop stack to EBX (reg 3) +run: pop into reg 3 +run: popping value 0x0000000a -+run: ESP is now 0x00000064 ++run: incrementing ESP to 0x00000064 :(before "End Single-Byte Opcodes") case 0x58: @@ -269,9 +270,14 @@ case 0x5e: case 0x5f: { // pop stack into r32 uint8_t reg = op & 0x7; trace(2, "run") << "pop into reg " << NUM(reg) << end(); - Reg[reg].u = *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)); - trace(2, "run") << "popping value 0x" << HEXWORD << Reg[reg].u << end(); - Reg[ESP].u += 4; - trace(2, "run") << "ESP is now 0x" << HEXWORD << Reg[ESP].u << end(); + Reg[reg].u = pop(); break; } +:(code) +uint32_t pop() { + uint32_t result = *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)); + trace(2, "run") << "popping value 0x" << HEXWORD << result << end(); + Reg[ESP].u += 4; + trace(2, "run") << "incrementing ESP to 0x" << HEXWORD << Reg[ESP].u << end(); + return result; +} diff --git a/subx/012indirect_addressing.cc b/subx/012indirect_addressing.cc index 37d82a3f..f4e8c665 100644 --- a/subx/012indirect_addressing.cc +++ b/subx/012indirect_addressing.cc @@ -349,18 +349,14 @@ case 0xff: { // jump to r/m32 ff 30 # push *EAX (reg 0) to stack +run: push effective address +run: effective address is mem at address 0x60 (reg 0) -+run: ESP is now 0x00000010 -+run: contents at ESP: 0x000000af ++run: decrementing ESP to 0x00000010 ++run: pushing value 0x000000af :(before "End Op ff Subops") case 6: { trace(2, "run") << "push effective address" << end(); const int32_t* val = effective_address(modrm); - trace(2, "run") << "pushing value 0x" << HEXWORD << *val << end(); - Reg[ESP].u -= 4; - *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)) = *val; - trace(2, "run") << "ESP is now 0x" << HEXWORD << Reg[ESP].u << end(); - trace(2, "run") << "contents at ESP: 0x" << HEXWORD << *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)) << end(); + push(*val); break; } @@ -374,8 +370,8 @@ case 6: { 8f 00 # pop stack into *EAX (reg 0) +run: pop into effective address +run: effective address is mem at address 0x60 (reg 0) -+run: storing 0x00000030 -+run: ESP is now 0x00000014 ++run: popping value 0x00000030 ++run: incrementing ESP to 0x00000014 :(before "End Single-Byte Opcodes") case 0x8f: { // pop stack into r/m32 @@ -385,10 +381,7 @@ case 0x8f: { // pop stack into r/m32 case 0: { trace(2, "run") << "pop into effective address" << end(); int32_t* dest = effective_address(modrm); - *dest = *reinterpret_cast<uint32_t*>(&Mem.at(Reg[ESP].u)); - trace(2, "run") << "storing 0x" << HEXWORD << *dest << end(); - Reg[ESP].u += 4; - trace(2, "run") << "ESP is now 0x" << HEXWORD << Reg[ESP].u << end(); + *dest = pop(); break; } } |