diff options
Diffstat (limited to 'html/010---vm.cc.html')
-rw-r--r-- | html/010---vm.cc.html | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/html/010---vm.cc.html b/html/010---vm.cc.html index f7f8be08..6d55cc8a 100644 --- a/html/010---vm.cc.html +++ b/html/010---vm.cc.html @@ -98,7 +98,7 @@ if ('onhashchange' in window) { <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#L260'>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="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> @@ -124,11 +124,11 @@ if ('onhashchange' in window) { <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#L148'>reset</a> if not.\n"</span> -<span id="L67" class="LineNr"> 67 </span> <span class="Constant">"- the zero flag (ZF): usually set if a result is zero, or <a href='000organization.cc.html#L148'>reset</a> if not.\n"</span> -<span id="L68" class="LineNr"> 68 </span> <span class="Constant">"- the carry flag (CF): usually set if an arithmetic result overflows by just one bit.\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 (OF): usually set if an arithmetic result overflows by more\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> @@ -201,7 +201,7 @@ if ('onhashchange' in window) { <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#L164'>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="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> @@ -246,16 +246,16 @@ if ('onhashchange' in window) { <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#L164'>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="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#L226'>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="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#L446'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Special"><a href='003trace.cc.html#L446'>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#L226'>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="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> @@ -265,17 +265,17 @@ if ('onhashchange' in window) { <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#L164'>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="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#L226'>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="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="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#L446'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Special"><a href='003trace.cc.html#L446'>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#L226'>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#L226'>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="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> @@ -314,10 +314,10 @@ if ('onhashchange' in window) { <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#L164'>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="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#L226'>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="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> @@ -331,7 +331,7 @@ if ('onhashchange' in window) { <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#L446'>Trace_file</a></span><span class="Delimiter">)</span> <span class="Delimiter">{</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> @@ -414,7 +414,7 @@ if ('onhashchange' in window) { <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#L250'>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="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> |