diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-05-20 01:44:06 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-05-20 01:44:06 -0700 |
commit | 52daf0722f7f4ad9d3f29e3cbbbaddde066f49f3 (patch) | |
tree | dac2a82e0b7148f2f215dee77c013b7a6fb329a2 /html/subx/071read-line.subx.html | |
parent | cfea67e9a00419c4493699c0ac8691d9bbb0ceca (diff) | |
download | mu-52daf0722f7f4ad9d3f29e3cbbbaddde066f49f3.tar.gz |
5211
Update syntax-highlighted renderings after a _long_ time.
Diffstat (limited to 'html/subx/071read-line.subx.html')
-rw-r--r-- | html/subx/071read-line.subx.html | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/html/subx/071read-line.subx.html b/html/subx/071read-line.subx.html index 37050313..f2dd35b4 100644 --- a/html/subx/071read-line.subx.html +++ b/html/subx/071read-line.subx.html @@ -65,7 +65,7 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="subxS1Comment"># . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes</span> <span id="L5" class="LineNr"> 5 </span> <span id="L6" class="LineNr"> 6 </span><span class="CommentedCode">#? Entry: # run a single test, while debugging</span> -<span id="L7" class="LineNr"> 7 </span><span class="CommentedCode">#? e8/call test-read-line/disp32</span> +<span id="L7" class="LineNr"> 7 </span><span class="CommentedCode">#? e8/call test-read-line-buffered/disp32</span> <span id="L8" class="LineNr"> 8 </span><span class="CommentedCode">#? # syscall(exit, Num-test-failures)</span> <span id="L9" class="LineNr"> 9 </span><span class="CommentedCode">#? 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32 # copy *Num-test-failures to EBX</span> <span id="L10" class="LineNr"> 10 </span><span class="CommentedCode">#? b8/copy-to-EAX 1/imm32/exit</span> @@ -74,7 +74,7 @@ if ('onhashchange' in window) { <span id="L13" class="LineNr"> 13 </span><span class="subxComment"># read bytes from 'f' until (and including) a newline and store them into 's'</span> <span id="L14" class="LineNr"> 14 </span><span class="subxComment"># 's' fails to grow if and only if no data found</span> <span id="L15" class="LineNr"> 15 </span><span class="subxComment"># just abort if 's' is too small</span> -<span id="L16" class="LineNr"> 16 </span><span class="subxFunction">read-line</span>: <span class="subxComment"># f : (address buffered-file), s : (address stream byte) -> <void></span> +<span id="L16" class="LineNr"> 16 </span><span class="subxFunction">read-line-buffered</span>: <span class="subxComment"># f : (address buffered-file), s : (address stream byte) -> <void></span> <span id="L17" class="LineNr"> 17 </span> <span class="subxComment"># pseudocode:</span> <span id="L18" class="LineNr"> 18 </span> <span class="subxComment"># while true</span> <span id="L19" class="LineNr"> 19 </span> <span class="subxComment"># if (s->write >= s->length) abort</span> @@ -102,13 +102,13 @@ if ('onhashchange' in window) { <span id="L41" class="LineNr"> 41 </span> 8b/copy 1/mod/*+disp8 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 7/r32/EDI 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(EBP+12) to EDI</span> <span id="L42" class="LineNr"> 42 </span> <span class="subxComment"># EDX = s->write</span> <span id="L43" class="LineNr"> 43 </span> 8b/copy 0/mod/indirect 7/rm32/EDI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/EDX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *EDI to EDX</span> -<span id="L44" class="LineNr"> 44 </span><span class="Constant">$read-line:loop</span>: +<span id="L44" class="LineNr"> 44 </span><span class="Constant">$read-line-buffered:loop</span>: <span id="L45" class="LineNr"> 45 </span> <span class="subxComment"># if (s->write >= s->length) abort</span> <span id="L46" class="LineNr"> 46 </span> 3b/compare 1/mod/*+disp8 7/rm32/EDI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/EDX 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># compare EDX with *(EDI+8)</span> -<span id="L47" class="LineNr"> 47 </span> 7d/jump-if-greater-or-equal $read-line:abort/disp8 +<span id="L47" class="LineNr"> 47 </span> 7d/jump-if-greater-or-equal $read-line-buffered:abort/disp8 <span id="L48" class="LineNr"> 48 </span> <span class="subxComment"># if (f->read >= f->write) populate stream from file</span> <span id="L49" class="LineNr"> 49 </span> 3b/compare 1/mod/*+disp8 6/rm32/ESI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ECX 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># compare ECX with *(ESI+4)</span> -<span id="L50" class="LineNr"> 50 </span> 7c/jump-if-lesser $read-line:from-stream/disp8 +<span id="L50" class="LineNr"> 50 </span> 7c/jump-if-lesser $read-line-buffered:from-stream/disp8 <span id="L51" class="LineNr"> 51 </span> <span class="subxS1Comment"># . clear-stream(stream = f+4)</span> <span id="L52" class="LineNr"> 52 </span> <span class="subxS2Comment"># . . push args</span> <span id="L53" class="LineNr"> 53 </span> 8d/copy-address 1/mod/*+disp8 6/rm32/ESI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/EAX 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy ESI+4 to EAX</span> @@ -131,8 +131,8 @@ if ('onhashchange' in window) { <span id="L70" class="LineNr"> 70 </span> <span class="subxComment"># since f->read was initially 0, EAX is the same as f->write</span> <span id="L71" class="LineNr"> 71 </span> <span class="subxS1Comment"># . if (EAX == 0) return true</span> <span id="L72" class="LineNr"> 72 </span> 3d/compare-EAX-and 0/imm32 -<span id="L73" class="LineNr"> 73 </span> 74/jump-if-equal $read-line:end/disp8 -<span id="L74" class="LineNr"> 74 </span><span class="Constant">$read-line:from-stream</span>: +<span id="L73" class="LineNr"> 73 </span> 74/jump-if-equal $read-line-buffered:end/disp8 +<span id="L74" class="LineNr"> 74 </span><span class="Constant">$read-line-buffered:from-stream</span>: <span id="L75" class="LineNr"> 75 </span> <span class="subxComment"># AL = f->data[f->read]</span> <span id="L76" class="LineNr"> 76 </span> 31/xor 3/mod/direct 0/rm32/EAX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/EAX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear EAX</span> <span id="L77" class="LineNr"> 77 </span> 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX <span class="Normal"> . </span> 0/r32/AL 0x10/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy byte at *(ESI+ECX+16) to AL</span> @@ -144,8 +144,8 @@ if ('onhashchange' in window) { <span id="L83" class="LineNr"> 83 </span> 42/increment-EDX <span id="L84" class="LineNr"> 84 </span> <span class="subxComment"># if (AL == '\n') return</span> <span id="L85" class="LineNr"> 85 </span> 3d/compare-EAX-and 0xa/imm32 -<span id="L86" class="LineNr"> 86 </span> 75/jump-if-not-equal $read-line:loop/disp8 -<span id="L87" class="LineNr"> 87 </span><span class="Constant">$read-line:end</span>: +<span id="L86" class="LineNr"> 86 </span> 75/jump-if-not-equal $read-line-buffered:loop/disp8 +<span id="L87" class="LineNr"> 87 </span><span class="Constant">$read-line-buffered:end</span>: <span id="L88" class="LineNr"> 88 </span> <span class="subxComment"># save f->read</span> <span id="L89" class="LineNr"> 89 </span> 89/copy 1/mod/*+disp8 6/rm32/ESI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ECX 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy ECX to *(ESI+8)</span> <span id="L90" class="LineNr"> 90 </span> <span class="subxComment"># save s->write</span> @@ -161,10 +161,10 @@ if ('onhashchange' in window) { <span id="L100" class="LineNr">100 </span> 5d/pop-to-EBP <span id="L101" class="LineNr">101 </span> c3/return <span id="L102" class="LineNr">102 </span> -<span id="L103" class="LineNr">103 </span><span class="Constant">$read-line:abort</span>: +<span id="L103" class="LineNr">103 </span><span class="Constant">$read-line-buffered:abort</span>: <span id="L104" class="LineNr">104 </span> <span class="subxS1Comment"># . _write(2/stderr, error)</span> <span id="L105" class="LineNr">105 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L106" class="LineNr">106 </span> 68/push <span class="Constant">"read-line: line too long\n"</span>/imm32 +<span id="L106" class="LineNr">106 </span> 68/push <span class="Constant">"read-line-buffered: line too long\n"</span>/imm32 <span id="L107" class="LineNr">107 </span> 68/push 2/imm32/stderr <span id="L108" class="LineNr">108 </span> <span class="subxS2Comment"># . . call</span> <span id="L109" class="LineNr">109 </span> e8/call <a href='050_write.subx.html#L14'>_write</a>/disp32 @@ -176,8 +176,8 @@ if ('onhashchange' in window) { <span id="L115" class="LineNr">115 </span> cd/syscall 0x80/imm8 <span id="L116" class="LineNr">116 </span> <span class="subxComment"># never gets here</span> <span id="L117" class="LineNr">117 </span> -<span id="L118" class="LineNr">118 </span><span class="subxTest">test-read-line</span>: -<span id="L119" class="LineNr">119 </span> <span class="subxH1Comment"># - check that read-line stops at a newline</span> +<span id="L118" class="LineNr">118 </span><span class="subxTest">test-read-line-buffered</span>: +<span id="L119" class="LineNr">119 </span> <span class="subxH1Comment"># - check that read-line-buffered stops at a newline</span> <span id="L120" class="LineNr">120 </span> <span class="subxComment"># setup</span> <span id="L121" class="LineNr">121 </span> <span class="subxS1Comment"># . clear-stream(_test-stream)</span> <span id="L122" class="LineNr">122 </span> <span class="subxS2Comment"># . . push args</span> @@ -211,27 +211,27 @@ if ('onhashchange' in window) { <span id="L150" class="LineNr">150 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L151" class="LineNr">151 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to ESP</span> <span id="L152" class="LineNr">152 </span> <span class="subxComment"># read a line from _test-stream (buffered by _test-buffered-file) into _test-tmp-stream</span> -<span id="L153" class="LineNr">153 </span> <span class="subxS1Comment"># . EAX = read-line(_test-buffered-file, _test-tmp-stream)</span> +<span id="L153" class="LineNr">153 </span> <span class="subxS1Comment"># . EAX = read-line-buffered(_test-buffered-file, _test-tmp-stream)</span> <span id="L154" class="LineNr">154 </span> <span class="subxS2Comment"># . . push args</span> <span id="L155" class="LineNr">155 </span> 68/push <a href='060read.subx.html#L430'>_test-tmp-stream</a>/imm32 <span id="L156" class="LineNr">156 </span> 68/push <a href='061read-byte.subx.html#L289'>_test-buffered-file</a>/imm32 <span id="L157" class="LineNr">157 </span> <span class="subxS2Comment"># . . call</span> -<span id="L158" class="LineNr">158 </span> e8/call <a href='071read-line.subx.html#L16'>read-line</a>/disp32 +<span id="L158" class="LineNr">158 </span> e8/call <a href='071read-line.subx.html#L16'>read-line-buffered</a>/disp32 <span id="L159" class="LineNr">159 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L160" class="LineNr">160 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to ESP</span> <span id="L161" class="LineNr">161 </span> <span class="subxComment"># check-next-stream-line-equal(_test-tmp-stream, "ab", msg)</span> <span id="L162" class="LineNr">162 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L163" class="LineNr">163 </span> 68/push <span class="Constant">"F - test-read-line"</span>/imm32 +<span id="L163" class="LineNr">163 </span> 68/push <span class="Constant">"F - test-read-line-buffered"</span>/imm32 <span id="L164" class="LineNr">164 </span> 68/push <span class="Constant">"ab"</span>/imm32 <span id="L165" class="LineNr">165 </span> 68/push <a href='060read.subx.html#L430'>_test-tmp-stream</a>/imm32 <span id="L166" class="LineNr">166 </span> <span class="subxS2Comment"># . . call</span> -<span id="L167" class="LineNr">167 </span> e8/call <a href='058stream-equal.subx.html#L569'>check-next-stream-line-equal</a>/disp32 +<span id="L167" class="LineNr">167 </span> e8/call <a href='058stream-equal.subx.html#L570'>check-next-stream-line-equal</a>/disp32 <span id="L168" class="LineNr">168 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L169" class="LineNr">169 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L170" class="LineNr">170 </span> <span class="subxComment"># end</span> <span id="L171" class="LineNr">171 </span> c3/return <span id="L172" class="LineNr">172 </span> -<span id="L173" class="LineNr">173 </span><span class="subxTest">test-read-line-reads-final-line-until-Eof</span>: +<span id="L173" class="LineNr">173 </span><span class="subxTest">test-read-line-buffered-reads-final-line-until-Eof</span>: <span id="L174" class="LineNr">174 </span> <span class="subxComment"># setup</span> <span id="L175" class="LineNr">175 </span> <span class="subxS1Comment"># . clear-stream(_test-stream)</span> <span id="L176" class="LineNr">176 </span> <span class="subxS2Comment"># . . push args</span> @@ -265,21 +265,21 @@ if ('onhashchange' in window) { <span id="L204" class="LineNr">204 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L205" class="LineNr">205 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to ESP</span> <span id="L206" class="LineNr">206 </span> <span class="subxComment"># read a line from _test-stream (buffered by _test-buffered-file) into _test-tmp-stream</span> -<span id="L207" class="LineNr">207 </span> <span class="subxS1Comment"># . EAX = read-line(_test-buffered-file, _test-tmp-stream)</span> +<span id="L207" class="LineNr">207 </span> <span class="subxS1Comment"># . EAX = read-line-buffered(_test-buffered-file, _test-tmp-stream)</span> <span id="L208" class="LineNr">208 </span> <span class="subxS2Comment"># . . push args</span> <span id="L209" class="LineNr">209 </span> 68/push <a href='060read.subx.html#L430'>_test-tmp-stream</a>/imm32 <span id="L210" class="LineNr">210 </span> 68/push <a href='061read-byte.subx.html#L289'>_test-buffered-file</a>/imm32 <span id="L211" class="LineNr">211 </span> <span class="subxS2Comment"># . . call</span> -<span id="L212" class="LineNr">212 </span> e8/call <a href='071read-line.subx.html#L16'>read-line</a>/disp32 +<span id="L212" class="LineNr">212 </span> e8/call <a href='071read-line.subx.html#L16'>read-line-buffered</a>/disp32 <span id="L213" class="LineNr">213 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L214" class="LineNr">214 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to ESP</span> <span id="L215" class="LineNr">215 </span> <span class="subxComment"># check-stream-equal(_test-tmp-stream, "cd", msg)</span> <span id="L216" class="LineNr">216 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L217" class="LineNr">217 </span> 68/push <span class="Constant">"F - test-read-line-reads-final-line-until-Eof"</span>/imm32 +<span id="L217" class="LineNr">217 </span> 68/push <span class="Constant">"F - test-read-line-buffered-reads-final-line-until-Eof"</span>/imm32 <span id="L218" class="LineNr">218 </span> 68/push <span class="Constant">"cd"</span>/imm32 <span id="L219" class="LineNr">219 </span> 68/push <a href='060read.subx.html#L430'>_test-tmp-stream</a>/imm32 <span id="L220" class="LineNr">220 </span> <span class="subxS2Comment"># . . call</span> -<span id="L221" class="LineNr">221 </span> e8/call <a href='058stream-equal.subx.html#L199'>check-stream-equal</a>/disp32 +<span id="L221" class="LineNr">221 </span> e8/call <a href='058stream-equal.subx.html#L200'>check-stream-equal</a>/disp32 <span id="L222" class="LineNr">222 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L223" class="LineNr">223 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L224" class="LineNr">224 </span> <span class="subxComment"># end</span> |