diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-07-27 18:26:18 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-07-27 18:26:18 -0700 |
commit | c8a3ccbeb89221d726542a89b42ddb26827af1f4 (patch) | |
tree | 56cbeba889d66d680069dad7696e835fe611ed64 /html/016index_addressing.cc.html | |
parent | a56d969ec99ef66ab21709b3aa61d49d9a3dfd10 (diff) | |
download | mu-c8a3ccbeb89221d726542a89b42ddb26827af1f4.tar.gz |
5490
Diffstat (limited to 'html/016index_addressing.cc.html')
-rw-r--r-- | html/016index_addressing.cc.html | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/html/016index_addressing.cc.html b/html/016index_addressing.cc.html index bd2304e9..0126e913 100644 --- a/html/016index_addressing.cc.html +++ b/html/016index_addressing.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - subx/016index_addressing.cc</title> +<title>Mu - 016index_addressing.cc</title> <meta name="Generator" content="Vim/8.1"> <meta name="plugin-version" content="vim8.1_v1"> <meta name="syntax" content="cpp"> @@ -54,7 +54,7 @@ if ('onhashchange' in window) { </script> </head> <body onload='JumpToLine();'> -<a href='https://github.com/akkartik/mu/blob/master/subx/016index_addressing.cc'>https://github.com/akkartik/mu/blob/master/subx/016index_addressing.cc</a> +<a href='https://github.com/akkartik/mu/blob/master/016index_addressing.cc'>https://github.com/akkartik/mu/blob/master/016index_addressing.cc</a> <pre id='vimCodeElement'> <span id="L1" class="LineNr"> 1 </span><span class="Comment">//: operating on memory at the address provided by some register plus optional scale and offset</span> <span id="L2" class="LineNr"> 2 </span> @@ -62,7 +62,7 @@ if ('onhashchange' in window) { <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#L28'>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#L28'>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#L85'>run</a><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="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> @@ -85,27 +85,27 @@ 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#L339'>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#L328'>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#L18'>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#L28'>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#L409'>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="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#L398'>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#L432'>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#L409'>HEXWORD</a> << addr << <span class="Constant">" (disp32)"</span> << end<span class="Delimiter">();</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#L398'>HEXWORD</a> << addr << <span class="Constant">" (disp32)"</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#L17'>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#L409'>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#L398'>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#L28'>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#L409'>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#L411'>NUM</a><span class="Delimiter">(</span>scale<span class="Delimiter">)</span> << <span class="Constant">")"</span> << end<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="Special">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#L398'>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#L400'>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> @@ -115,7 +115,7 @@ if ('onhashchange' in window) { <span id="L57" class="LineNr"> 57 </span> <span class="Special"><a href='010---vm.cc.html#L28'>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#L28'>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#L28'>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#L85'>run</a><span class="Delimiter">(</span> +<span id="L60" class="LineNr"> 60 </span> <a href='011run.cc.html#L83'>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> @@ -135,7 +135,7 @@ if ('onhashchange' in window) { <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#L28'>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#L85'>run</a><span class="Delimiter">(</span> +<span id="L80" class="LineNr"> 80 </span> <a href='011run.cc.html#L83'>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> @@ -159,7 +159,7 @@ if ('onhashchange' in window) { <span id="L101" class="LineNr">101 </span> <span class="Special"><a href='010---vm.cc.html#L28'>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#L28'>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#L28'>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#L85'>run</a><span class="Delimiter">(</span> +<span id="L104" class="LineNr">104 </span> <a href='011run.cc.html#L83'>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> @@ -189,7 +189,7 @@ if ('onhashchange' in window) { <span id="L131" class="LineNr">131 </span> <span class="Special"><a href='010---vm.cc.html#L28'>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#L28'>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#L28'>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#L85'>run</a><span class="Delimiter">(</span> +<span id="L134" class="LineNr">134 </span> <a href='011run.cc.html#L83'>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> |