diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-11-26 01:19:47 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-11-26 01:19:47 -0800 |
commit | d1c9392a5461e0d33e226375a8f7986a97d2d66b (patch) | |
tree | 494c19edbe1d1522344b56ced6aa7c040ad37406 /html/subx/028translate.cc.html | |
parent | 7e00968c99f97e13be8f5269feaf7fd1d33ecd33 (diff) | |
download | mu-d1c9392a5461e0d33e226375a8f7986a97d2d66b.tar.gz |
4782
Diffstat (limited to 'html/subx/028translate.cc.html')
-rw-r--r-- | html/subx/028translate.cc.html | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/html/subx/028translate.cc.html b/html/subx/028translate.cc.html index 2745d059..ccd31900 100644 --- a/html/subx/028translate.cc.html +++ b/html/subx/028translate.cc.html @@ -17,6 +17,7 @@ a:hover { text-decoration: underline; } * { font-size: 12pt; font-size: 1em; } .LineNr { color: #444444; } .Constant { color: #00a0a0; } +.Special { color: #c00000; } .Delimiter { color: #800080; } .SalientComment { color: #00ffff; } .Identifier { color: #c0a020; } @@ -88,7 +89,7 @@ if ('onhashchange' in window) { <span id="L28" class="LineNr"> 28 </span> ++i<span class="Delimiter">;</span> <span id="L29" class="LineNr"> 29 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i >= argc<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L30" class="LineNr"> 30 </span> <a href='028translate.cc.html#L68'>print_translate_usage</a><span class="Delimiter">();</span> -<span id="L31" class="LineNr"> 31 </span> cerr << <span class="Constant">"'-o' must be followed by a filename to write results to</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L31" class="LineNr"> 31 </span> cerr << <span class="Constant">"'-o' must be followed by a filename to write results to\n"</span><span class="Delimiter">;</span> <span id="L32" class="LineNr"> 32 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L33" class="LineNr"> 33 </span> <span class="Delimiter">}</span> <span id="L34" class="LineNr"> 34 </span> output_filename = argv[i]<span class="Delimiter">;</span> @@ -105,12 +106,12 @@ if ('onhashchange' in window) { <span id="L45" class="LineNr"> 45 </span> <span class="Delimiter">}</span> <span id="L46" class="LineNr"> 46 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L100'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> <span id="L47" class="LineNr"> 47 </span> <a href='028translate.cc.html#L68'>print_translate_usage</a><span class="Delimiter">();</span> -<span id="L48" class="LineNr"> 48 </span> cerr << <span class="Constant">"nothing to do; must provide at least one file to read</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L48" class="LineNr"> 48 </span> cerr << <span class="Constant">"nothing to do; must provide at least one file to read\n"</span><span class="Delimiter">;</span> <span id="L49" class="LineNr"> 49 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L50" class="LineNr"> 50 </span> <span class="Delimiter">}</span> <span id="L51" class="LineNr"> 51 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>output_filename<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> <span id="L52" class="LineNr"> 52 </span> <a href='028translate.cc.html#L68'>print_translate_usage</a><span class="Delimiter">();</span> -<span id="L53" class="LineNr"> 53 </span> cerr << <span class="Constant">"must provide a filename to write to using '-o'</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L53" class="LineNr"> 53 </span> cerr << <span class="Constant">"must provide a filename to write to using '-o'\n"</span><span class="Delimiter">;</span> <span id="L54" class="LineNr"> 54 </span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> <span id="L55" class="LineNr"> 55 </span> <span class="Delimiter">}</span> <span id="L56" class="LineNr"> 56 </span> <a href='011run.cc.html#L231'>transform</a><span class="Delimiter">(</span>p<span class="Delimiter">);</span> @@ -126,7 +127,7 @@ if ('onhashchange' in window) { <span id="L66" class="LineNr"> 66 </span> <span id="L67" class="LineNr"> 67 </span><span class="Delimiter">:(code)</span> <span id="L68" class="LineNr"> 68 </span><span class="Normal">void</span> <a href='028translate.cc.html#L68'>print_translate_usage</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L69" class="LineNr"> 69 </span> cerr << <span class="Constant">"Usage: subx translate file1 file2 ... -o output</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L69" class="LineNr"> 69 </span> cerr << <span class="Constant">"Usage: subx translate file1 file2 ... -o output\n"</span><span class="Delimiter">;</span> <span id="L70" class="LineNr"> 70 </span><span class="Delimiter">}</span> <span id="L71" class="LineNr"> 71 </span> <span id="L72" class="LineNr"> 72 </span><span class="Comment">// write out a program to a bare-bones ELF file</span> @@ -145,17 +146,17 @@ if ('onhashchange' in window) { <span id="L85" class="LineNr"> 85 </span><span class="Comment">#define emit(X) out.write(reinterpret_cast<const char*>(&X), sizeof(X))</span> <span id="L86" class="LineNr"> 86 </span> <span class="SalientComment">//// ehdr</span> <span id="L87" class="LineNr"> 87 </span> <span class="Comment">// e_ident</span> -<span id="L88" class="LineNr"> 88 </span> O<span class="Delimiter">(</span><span class="Constant">0x7f</span><span class="Delimiter">);</span> O<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">E</span><span class="Comment">*/</span><span class="Constant">0x45</span><span class="Delimiter">);</span> O<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">L</span><span class="Comment">*/</span><span class="Constant">0x4c</span><span class="Delimiter">);</span> O<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">F</span><span class="Comment">*/</span><span class="Constant">0x46</span><span class="Delimiter">);</span> -<span id="L89" class="LineNr"> 89 </span> O<span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Comment">// 32-bit format</span> -<span id="L90" class="LineNr"> 90 </span> O<span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Comment">// little-endian</span> -<span id="L91" class="LineNr"> 91 </span> O<span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> O<span class="Delimiter">(</span><span class="Constant">0x0</span><span class="Delimiter">);</span> -<span id="L92" class="LineNr"> 92 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <span class="Constant">8</span><span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> O<span class="Delimiter">(</span><span class="Constant">0x0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> +<span id="L88" class="LineNr"> 88 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x7f</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">E</span><span class="Comment">*/</span><span class="Constant">0x45</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">L</span><span class="Comment">*/</span><span class="Constant">0x4c</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">F</span><span class="Comment">*/</span><span class="Constant">0x46</span><span class="Delimiter">);</span> +<span id="L89" class="LineNr"> 89 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Comment">// 32-bit format</span> +<span id="L90" class="LineNr"> 90 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Comment">// little-endian</span> +<span id="L91" class="LineNr"> 91 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x1</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x0</span><span class="Delimiter">);</span> +<span id="L92" class="LineNr"> 92 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">size_t</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <span class="Constant">8</span><span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x0</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span id="L93" class="LineNr"> 93 </span> <span class="Comment">// e_type</span> -<span id="L94" class="LineNr"> 94 </span> O<span class="Delimiter">(</span><span class="Constant">0x02</span><span class="Delimiter">);</span> O<span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L94" class="LineNr"> 94 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x02</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> <span id="L95" class="LineNr"> 95 </span> <span class="Comment">// e_machine</span> -<span id="L96" class="LineNr"> 96 </span> O<span class="Delimiter">(</span><span class="Constant">0x03</span><span class="Delimiter">);</span> O<span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L96" class="LineNr"> 96 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x03</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> <span id="L97" class="LineNr"> 97 </span> <span class="Comment">// e_version</span> -<span id="L98" class="LineNr"> 98 </span> O<span class="Delimiter">(</span><span class="Constant">0x01</span><span class="Delimiter">);</span> O<span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> O<span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> O<span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> +<span id="L98" class="LineNr"> 98 </span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x01</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> <span class="Special">O</span><span class="Delimiter">(</span><span class="Constant">0x00</span><span class="Delimiter">);</span> <span id="L99" class="LineNr"> 99 </span> <span class="Comment">// e_entry</span> <span id="L100" class="LineNr">100 </span> <span class="Normal">int</span> e_entry = p<span class="Delimiter">.</span><a href='011run.cc.html#L100'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>start<span class="Delimiter">;</span> <span class="Comment">// convention</span> <span id="L101" class="LineNr">101 </span> emit<span class="Delimiter">(</span>e_entry<span class="Delimiter">);</span> @@ -199,7 +200,7 @@ if ('onhashchange' in window) { <span id="L139" class="LineNr">139 </span> emit<span class="Delimiter">(</span>p_start<span class="Delimiter">);</span> <span id="L140" class="LineNr">140 </span> <span class="Comment">// p_filesz</span> <span id="L141" class="LineNr">141 </span> <span class="Normal">uint32_t</span> size = <a href='028translate.cc.html#L185'>num_words</a><span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L100'>segments</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> -<span id="L142" class="LineNr">142 </span> assert<span class="Delimiter">(</span>p_offset + size < <a href='010---vm.cc.html#L115'>INITIAL_SEGMENT_SIZE</a><span class="Delimiter">);</span> +<span id="L142" class="LineNr">142 </span> assert<span class="Delimiter">(</span>p_offset + size < <a href='010---vm.cc.html#L115'>SEGMENT_ALIGNMENT</a><span class="Delimiter">);</span> <span id="L143" class="LineNr">143 </span> emit<span class="Delimiter">(</span>size<span class="Delimiter">);</span> <span id="L144" class="LineNr">144 </span> <span class="Comment">// p_memsz</span> <span id="L145" class="LineNr">145 </span> emit<span class="Delimiter">(</span>size<span class="Delimiter">);</span> @@ -221,7 +222,7 @@ if ('onhashchange' in window) { <span id="L161" class="LineNr">161 </span> <span class="Normal">uint32_t</span> p_align = <span class="Constant">0x1000</span><span class="Delimiter">;</span> <span class="Comment">// default page size on linux</span> <span id="L162" class="LineNr">162 </span> emit<span class="Delimiter">(</span>p_align<span class="Delimiter">);</span> <span id="L163" class="LineNr">163 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p_offset % p_align != p_start % p_align<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L164" class="LineNr">164 </span> <a href='003trace.cc.html#L210'>raise</a> << <span class="Constant">"segment starting at 0x"</span> << <a href='010---vm.cc.html#L404'>HEXWORD</a> << p_start << <span class="Constant">" is improperly aligned; alignment for p_offset "</span> << p_offset << <span class="Constant">" should be "</span> << <span class="Delimiter">(</span>p_offset % p_align<span class="Delimiter">)</span> << <span class="Constant">" but is "</span> << <span class="Delimiter">(</span>p_start % p_align<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> +<span id="L164" class="LineNr">164 </span> <a href='003trace.cc.html#L210'>raise</a> << <span class="Constant">"segment starting at 0x"</span> << <a href='010---vm.cc.html#L413'>HEXWORD</a> << p_start << <span class="Constant">" is improperly aligned; alignment for p_offset "</span> << p_offset << <span class="Constant">" should be "</span> << <span class="Delimiter">(</span>p_offset % p_align<span class="Delimiter">)</span> << <span class="Constant">" but is "</span> << <span class="Delimiter">(</span>p_start % p_align<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span id="L165" class="LineNr">165 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L166" class="LineNr">166 </span> <span class="Delimiter">}</span> <span id="L167" class="LineNr">167 </span> |