diff options
Diffstat (limited to 'html/011run.cc.html')
-rw-r--r-- | html/011run.cc.html | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/html/011run.cc.html b/html/011run.cc.html index b8a0963e..26bad7d7 100644 --- a/html/011run.cc.html +++ b/html/011run.cc.html @@ -64,7 +64,7 @@ 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#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">"syntax"</span><span class="Delimiter">,</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="L10" class="LineNr"> 10 </span> <span class="Constant">"instruction, macro or directive.\n"</span> @@ -128,7 +128,7 @@ if ('onhashchange' in window) { <span id="L68" class="LineNr"> 68 </span> <span class="Comment">// and are otherwise ignored.</span> <span id="L69" class="LineNr"> 69 </span> <span class="Delimiter">);</span> <span id="L70" class="LineNr"> 70 </span> <span class="Comment">// This program, when run, causes the following events in the trace:</span> -<span id="L71" class="LineNr"> 71 </span> <a href='003trace.cc.html#L290'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> +<span id="L71" class="LineNr"> 71 </span> <a href='003trace.cc.html#L292'>CHECK_TRACE_CONTENTS</a><span class="Delimiter">(</span> <span id="L72" class="LineNr"> 72 </span> <span class="Constant">"load: 0x00000001 -> b8\n"</span> <span id="L73" class="LineNr"> 73 </span> <span class="Constant">"load: 0x00000002 -> 0a\n"</span> <span id="L74" class="LineNr"> 74 </span> <span class="Constant">"load: 0x00000003 -> 0b\n"</span> @@ -144,11 +144,11 @@ if ('onhashchange' in window) { <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="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#L262'>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="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#L262'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><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#L262'>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="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> @@ -197,7 +197,7 @@ if ('onhashchange' in window) { <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#L272'>has_data</a><span class="Delimiter">(</span>fin<span class="Delimiter">))</span> <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> @@ -205,7 +205,7 @@ if ('onhashchange' in window) { <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#L272'>has_data</a><span class="Delimiter">(</span>lin<span class="Delimiter">))</span> <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> @@ -228,7 +228,7 @@ if ('onhashchange' in window) { <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#L262'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">continue</span><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> @@ -249,7 +249,7 @@ if ('onhashchange' in window) { <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#L164'>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="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> @@ -259,7 +259,7 @@ if ('onhashchange' in window) { <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#L226'>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> <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> @@ -278,9 +278,9 @@ if ('onhashchange' in window) { <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#L164'>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="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#L226'>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> <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> @@ -299,7 +299,7 @@ if ('onhashchange' in window) { <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#L290'>CHECK_TRACE_CONTENTS</a><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> @@ -313,7 +313,7 @@ if ('onhashchange' in window) { <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#L164'>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="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> @@ -321,23 +321,23 @@ if ('onhashchange' in window) { <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#L226'>raise</a> << <span class="Constant">"no code to run\n"</span> << end<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#L164'>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="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#L164'>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="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#L164'>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="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#L262'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><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> @@ -352,7 +352,7 @@ if ('onhashchange' in window) { <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#L164'>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="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> @@ -361,18 +361,18 @@ if ('onhashchange' in window) { <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#L226'>raise</a> << <span class="Constant">"uppercase hex not allowed: "</span> << s << <span class="cSpecial">'\n'</span> << end<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#L226'>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="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#L226'>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="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> @@ -384,7 +384,7 @@ if ('onhashchange' in window) { <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="L326" class="LineNr">326 </span> <span class="Delimiter">);</span> -<span id="L327" class="LineNr">327 </span> <a href='003trace.cc.html#L290'>CHECK_TRACE_CONTENTS</a><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> @@ -395,7 +395,7 @@ if ('onhashchange' in window) { <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#L290'>CHECK_TRACE_CONTENTS</a><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> @@ -405,7 +405,7 @@ if ('onhashchange' in window) { <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#L294'>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="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> @@ -414,7 +414,7 @@ if ('onhashchange' in window) { <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#L290'>CHECK_TRACE_CONTENTS</a><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> @@ -424,7 +424,7 @@ if ('onhashchange' in window) { <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#L294'>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="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> @@ -434,7 +434,7 @@ if ('onhashchange' in window) { <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#L290'>CHECK_TRACE_CONTENTS</a><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> @@ -451,7 +451,7 @@ if ('onhashchange' in window) { <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="L393" class="LineNr">393 </span> <span class="Delimiter">);</span> -<span id="L394" class="LineNr">394 </span> <a href='003trace.cc.html#L290'>CHECK_TRACE_CONTENTS</a><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> @@ -462,7 +462,7 @@ if ('onhashchange' in window) { <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#L290'>CHECK_TRACE_CONTENTS</a><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> @@ -472,14 +472,14 @@ if ('onhashchange' in window) { <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#L262'>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="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#L260'>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="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> @@ -498,7 +498,7 @@ if ('onhashchange' in window) { <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#L290'>CHECK_TRACE_CONTENTS</a><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> @@ -515,13 +515,13 @@ if ('onhashchange' in window) { <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#L164'>SIZE</a><span class="Delimiter">(</span>w<span class="Delimiter">.</span>metadata<span class="Delimiter">);</span> ++i<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#L164'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">);</span> ++i<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> |