diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-09-20 11:19:30 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-09-20 11:25:59 -0700 |
commit | 4a4a392dc7c81b301ad6b760525c5549f2f6644c (patch) | |
tree | 9ce3225fd2b87c57090509d0fd42a9d4147d1b2e /html/apps/hex.subx.html | |
parent | 0ca3aa4acce4f5a1378f87754761197673cdd6db (diff) | |
download | mu-4a4a392dc7c81b301ad6b760525c5549f2f6644c.tar.gz |
5683
Diffstat (limited to 'html/apps/hex.subx.html')
-rw-r--r-- | html/apps/hex.subx.html | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/html/apps/hex.subx.html b/html/apps/hex.subx.html index e0e3ecf8..4403ad99 100644 --- a/html/apps/hex.subx.html +++ b/html/apps/hex.subx.html @@ -64,7 +64,7 @@ if ('onhashchange' in window) { <span id="L3" class="LineNr"> 3 </span><span class="subxComment"># comments between '#' and newline.</span> <span id="L4" class="LineNr"> 4 </span><span class="subxComment">#</span> <span id="L5" class="LineNr"> 5 </span><span class="subxComment"># To run:</span> -<span id="L6" class="LineNr"> 6 </span><span class="subxComment"># $ ./subx translate init.linux 0*.subx apps/subx-common.subx apps/hex.subx -o apps/hex</span> +<span id="L6" class="LineNr"> 6 </span><span class="subxComment"># $ ./subx translate init.linux 0*.subx apps/subx-params.subx apps/hex.subx -o apps/hex</span> <span id="L7" class="LineNr"> 7 </span><span class="subxComment"># $ echo '80 81 82 # comment' |./subx run apps/hex |xxd -</span> <span id="L8" class="LineNr"> 8 </span><span class="subxComment"># Expected output:</span> <span id="L9" class="LineNr"> 9 </span><span class="subxComment"># 00000000: 8081 82</span> @@ -83,20 +83,20 @@ if ('onhashchange' in window) { <span id="L22" class="LineNr"> 22 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> <span id="L23" class="LineNr"> 23 </span> <span id="L24" class="LineNr"> 24 </span> <span class="subxComment"># initialize heap</span> -<span id="L25" class="LineNr"> 25 </span> <span class="subxS1Comment"># . Heap = new-segment(64KB)</span> +<span id="L25" class="LineNr"> 25 </span> <span class="subxS1Comment"># . Heap = new-segment(Heap-size)</span> <span id="L26" class="LineNr"> 26 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L27" class="LineNr"> 27 </span> 68/push <span class="SpecialChar"><a href='../075array-equal.subx.html#L623'>Heap</a></span>/imm32 -<span id="L28" class="LineNr"> 28 </span> 68/push 0x10000/imm32/64KB +<span id="L27" class="LineNr"> 27 </span> 68/push <span class="SpecialChar"><a href='../069allocate.subx.html#L22'>Heap</a></span>/imm32 +<span id="L28" class="LineNr"> 28 </span> 68/push <span class="SpecialChar"><a href='../069allocate.subx.html#L29'>Heap-size</a></span>/imm32 <span id="L29" class="LineNr"> 29 </span> <span class="subxS2Comment"># . . call</span> <span id="L30" class="LineNr"> 30 </span> e8/call <a href='../053new-segment.subx.html#L41'>new-segment</a>/disp32 <span id="L31" class="LineNr"> 31 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L32" class="LineNr"> 32 </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="L33" class="LineNr"> 33 </span> <span id="L34" class="LineNr"> 34 </span> <span class="subxH1Comment"># - if argc > 1 and argv[1] == "test", then return run_tests()</span> -<span id="L35" class="LineNr"> 35 </span> <span class="subxComment"># if (argc <= 1) goto run-main</span> +<span id="L35" class="LineNr"> 35 </span> <span class="subxComment"># if (argc <= 1) goto interactive</span> <span id="L36" class="LineNr"> 36 </span> 81 7/subop/compare 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/disp8 1/imm32 <span class="subxComment"># compare *ebp</span> -<span id="L37" class="LineNr"> 37 </span> 7e/jump-if-lesser-or-equal $run-main/disp8 -<span id="L38" class="LineNr"> 38 </span> <span class="subxComment"># if (!kernel-string-equal?(argv[1], "test")) goto run-main</span> +<span id="L37" class="LineNr"> 37 </span> 7e/jump-if-lesser-or-equal $subx-hex-main:interactive/disp8 +<span id="L38" class="LineNr"> 38 </span> <span class="subxComment"># if (!kernel-string-equal?(argv[1], "test")) goto interactive</span> <span id="L39" class="LineNr"> 39 </span> <span class="subxS1Comment"># . eax = kernel-string-equal?(argv[1], "test")</span> <span id="L40" class="LineNr"> 40 </span> <span class="subxS2Comment"># . . push args</span> <span id="L41" class="LineNr"> 41 </span> 68/push <span class="Constant">"test"</span>/imm32 @@ -105,15 +105,15 @@ if ('onhashchange' in window) { <span id="L44" class="LineNr"> 44 </span> e8/call <a href='../052kernel-string-equal.subx.html#L31'>kernel-string-equal?</a>/disp32 <span id="L45" class="LineNr"> 45 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L46" class="LineNr"> 46 </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="L47" class="LineNr"> 47 </span> <span class="subxS1Comment"># . if (eax == 0) goto run-main</span> +<span id="L47" class="LineNr"> 47 </span> <span class="subxS1Comment"># . if (eax == 0) goto interactive</span> <span id="L48" class="LineNr"> 48 </span> 3d/compare-eax-and 0/imm32 -<span id="L49" class="LineNr"> 49 </span> 74/jump-if-equal $run-main/disp8 +<span id="L49" class="LineNr"> 49 </span> 74/jump-if-equal $subx-hex-main:interactive/disp8 <span id="L50" class="LineNr"> 50 </span> <span class="subxComment"># run-tests()</span> <span id="L51" class="LineNr"> 51 </span> e8/call run-tests/disp32 <span id="L52" class="LineNr"> 52 </span> <span class="subxComment"># syscall(exit, *Num-test-failures)</span> <span id="L53" class="LineNr"> 53 </span> 8b/copy 0/mod/indirect 5/rm32/.disp32 <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="SpecialChar"><a href='../051test.subx.html#L90'>Num-test-failures</a></span>/disp32 <span class="subxComment"># copy *Num-test-failures to ebx</span> -<span id="L54" class="LineNr"> 54 </span> eb/jump $main:end/disp8 -<span id="L55" class="LineNr"> 55 </span><span class="Constant">$run-main</span>: +<span id="L54" class="LineNr"> 54 </span> eb/jump $subx-hex-main:end/disp8 +<span id="L55" class="LineNr"> 55 </span><span class="Constant">$subx-hex-main:interactive</span>: <span id="L56" class="LineNr"> 56 </span> <span class="subxH1Comment"># - otherwise convert stdin</span> <span id="L57" class="LineNr"> 57 </span> <span class="subxComment"># var ed/eax : exit-descriptor</span> <span id="L58" class="LineNr"> 58 </span> 81 5/subop/subtract 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"># subtract from esp</span> @@ -121,24 +121,24 @@ if ('onhashchange' in window) { <span id="L60" class="LineNr"> 60 </span> <span class="subxComment"># configure ed to really exit()</span> <span id="L61" class="LineNr"> 61 </span> <span class="subxS1Comment"># . ed->target = 0</span> <span id="L62" class="LineNr"> 62 </span> c7 0/subop/copy 0/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/imm32 <span class="subxComment"># copy to *eax</span> -<span id="L63" class="LineNr"> 63 </span> <span class="subxComment"># convert(Stdin, 1/stdout, 2/stderr, ed)</span> +<span id="L63" class="LineNr"> 63 </span> <span class="subxComment"># subx-hex(Stdin, 1/stdout, 2/stderr, ed)</span> <span id="L64" class="LineNr"> 64 </span> <span class="subxS2Comment"># . . push args</span> <span id="L65" class="LineNr"> 65 </span> 50/push-eax/ed <span id="L66" class="LineNr"> 66 </span> 68/push <span class="SpecialChar"><a href='../065write-buffered.subx.html#L213'>Stderr</a></span>/imm32 <span id="L67" class="LineNr"> 67 </span> 68/push <span class="SpecialChar"><a href='../064write-byte.subx.html#L10'>Stdout</a></span>/imm32 <span id="L68" class="LineNr"> 68 </span> 68/push <span class="SpecialChar"><a href='../061read-byte.subx.html#L14'>Stdin</a></span>/imm32 <span id="L69" class="LineNr"> 69 </span> <span class="subxS2Comment"># . . call</span> -<span id="L70" class="LineNr"> 70 </span> e8/call <a href='hex.subx.html#L80'>convert</a>/disp32 +<span id="L70" class="LineNr"> 70 </span> e8/call <a href='hex.subx.html#L80'>subx-hex</a>/disp32 <span id="L71" class="LineNr"> 71 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L72" class="LineNr"> 72 </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> 0x10/imm32 <span class="subxComment"># add to esp</span> <span id="L73" class="LineNr"> 73 </span> <span class="subxComment"># syscall(exit, 0)</span> <span id="L74" class="LineNr"> 74 </span> bb/copy-to-ebx 0/imm32 -<span id="L75" class="LineNr"> 75 </span><span class="Constant">$main:end</span>: +<span id="L75" class="LineNr"> 75 </span><span class="Constant">$subx-hex-main:end</span>: <span id="L76" class="LineNr"> 76 </span> b8/copy-to-eax 1/imm32/exit <span id="L77" class="LineNr"> 77 </span> cd/syscall 0x80/imm8 <span id="L78" class="LineNr"> 78 </span> <span id="L79" class="LineNr"> 79 </span><span class="subxComment"># the main entry point</span> -<span id="L80" class="LineNr"> 80 </span><span class="subxFunction">convert</span>: <span class="subxComment"># in : (address buffered-file), out : (address buffered-file), err : (address buffered-file), ed : (address exit-descriptor) -> <void></span> +<span id="L80" class="LineNr"> 80 </span><span class="subxFunction">subx-hex</span>: <span class="subxComment"># in : (address buffered-file), out : (address buffered-file), err : (address buffered-file), ed : (address exit-descriptor) -> <void></span> <span id="L81" class="LineNr"> 81 </span> <span class="subxComment"># pseudocode:</span> <span id="L82" class="LineNr"> 82 </span> <span class="subxComment"># while true</span> <span id="L83" class="LineNr"> 83 </span> <span class="subxComment"># eax = convert-next-octet(in, err, ed)</span> @@ -151,7 +151,7 @@ if ('onhashchange' in window) { <span id="L90" class="LineNr"> 90 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> <span id="L91" class="LineNr"> 91 </span> <span class="subxS1Comment"># . save registers</span> <span id="L92" class="LineNr"> 92 </span> 50/push-eax -<span id="L93" class="LineNr"> 93 </span><span class="Constant">$convert:loop</span>: +<span id="L93" class="LineNr"> 93 </span><span class="Constant">$subx-hex:loop</span>: <span id="L94" class="LineNr"> 94 </span> <span class="subxComment"># eax = convert-next-octet(in, err, ed)</span> <span id="L95" class="LineNr"> 95 </span> <span class="subxS2Comment"># . . push args</span> <span id="L96" class="LineNr"> 96 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x14/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+20)</span> @@ -163,7 +163,7 @@ if ('onhashchange' in window) { <span id="L102" class="LineNr"> 102 </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="L103" class="LineNr"> 103 </span> <span class="subxComment"># if (eax == Eof) break</span> <span id="L104" class="LineNr"> 104 </span> 3d/compare-eax-and 0xffffffff/imm32/Eof -<span id="L105" class="LineNr"> 105 </span> 74/jump-if-equal $convert:loop-end/disp8 +<span id="L105" class="LineNr"> 105 </span> 74/jump-if-equal $subx-hex:loop-end/disp8 <span id="L106" class="LineNr"> 106 </span> <span class="subxComment"># write-byte-buffered(out, AL)</span> <span id="L107" class="LineNr"> 107 </span> <span class="subxS2Comment"># . . push args</span> <span id="L108" class="LineNr"> 108 </span> 50/push-eax @@ -173,8 +173,8 @@ if ('onhashchange' in window) { <span id="L112" class="LineNr"> 112 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L113" class="LineNr"> 113 </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="L114" class="LineNr"> 114 </span> <span class="subxComment"># loop</span> -<span id="L115" class="LineNr"> 115 </span> eb/jump $convert:loop/disp8 -<span id="L116" class="LineNr"> 116 </span><span class="Constant">$convert:loop-end</span>: +<span id="L115" class="LineNr"> 115 </span> eb/jump $subx-hex:<span class="Constant">loop</span>/disp8 +<span id="L116" class="LineNr"> 116 </span><span class="Constant">$subx-hex:loop-end</span>: <span id="L117" class="LineNr"> 117 </span> <span class="subxComment"># flush(out)</span> <span id="L118" class="LineNr"> 118 </span> <span class="subxS2Comment"># . . push args</span> <span id="L119" class="LineNr"> 119 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+12)</span> @@ -182,7 +182,7 @@ if ('onhashchange' in window) { <span id="L121" class="LineNr"> 121 </span> e8/call <a href='../064write-byte.subx.html#L79'>flush</a>/disp32 <span id="L122" class="LineNr"> 122 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L123" class="LineNr"> 123 </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> 4/imm32 <span class="subxComment"># add to esp</span> -<span id="L124" class="LineNr"> 124 </span><span class="Constant">$convert:end</span>: +<span id="L124" class="LineNr"> 124 </span><span class="Constant">$subx-hex:end</span>: <span id="L125" class="LineNr"> 125 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L126" class="LineNr"> 126 </span> 58/pop-to-eax <span id="L127" class="LineNr"> 127 </span> <span class="subxS1Comment"># . epilog</span> @@ -239,7 +239,7 @@ if ('onhashchange' in window) { <span id="L178" class="LineNr"> 178 </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="L179" class="LineNr"> 179 </span> <span class="subxComment"># if (eax == Eof) error(ed, err, "partial byte found.")</span> <span id="L180" class="LineNr"> 180 </span> 3d/compare-eax-and 0xffffffff/imm32/Eof -<span id="L181" class="LineNr"> 181 </span> 75/jump-if-not-equal $convert-next-octet:<a href='hex.subx.html#L80'>convert</a>/disp8 +<span id="L181" class="LineNr"> 181 </span> 75/jump-if-not-equal $convert-next-octet:convert/disp8 <span id="L182" class="LineNr"> 182 </span> <span class="subxS1Comment"># . error-byte(ed, err, msg, '.') # reusing error-byte to avoid creating _yet_ another helper</span> <span id="L183" class="LineNr"> 183 </span> <span class="subxS2Comment"># . . push args</span> <span id="L184" class="LineNr"> 184 </span> 68/push 0x2e/imm32/period/dummy @@ -248,7 +248,7 @@ if ('onhashchange' in window) { <span id="L187" class="LineNr"> 187 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x10/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+16)</span> <span id="L188" class="LineNr"> 188 </span> <span class="subxS2Comment"># . . call</span> <span id="L189" class="LineNr"> 189 </span> e8/call <a href='../068error-byte.subx.html#L27'>error-byte</a>/disp32 <span class="subxComment"># never returns</span> -<span id="L190" class="LineNr"> 190 </span><span class="Constant">$convert-next-octet:<a href='hex.subx.html#L80'>convert</a></span>: +<span id="L190" class="LineNr"> 190 </span><span class="Constant">$convert-next-octet:convert</span>: <span id="L191" class="LineNr"> 191 </span> <span class="subxComment"># eax = from-hex-char(eax)</span> <span id="L192" class="LineNr"> 192 </span> e8/call <a href='../067parse-hex.subx.html#L797'>from-hex-char</a>/disp32 <span id="L193" class="LineNr"> 193 </span> <span class="subxComment"># eax = (ecx << 4) | eax</span> @@ -598,13 +598,13 @@ if ('onhashchange' in window) { <span id="L537" class="LineNr"> 537 </span><span class="Constant">$scan-next-byte:check1</span>: <span id="L538" class="LineNr"> 538 </span> <span class="subxComment"># if (eax == ' ') continue</span> <span id="L539" class="LineNr"> 539 </span> 3d/compare-eax-and 0x20/imm32/space -<span id="L540" class="LineNr"> 540 </span> 74/jump-if-equal $scan-next-byte:loop/disp8 +<span id="L540" class="LineNr"> 540 </span> 74/jump-if-equal $scan-next-byte:<span class="Constant">loop</span>/disp8 <span id="L541" class="LineNr"> 541 </span> <span class="subxComment"># if (eax == '\t') continue</span> <span id="L542" class="LineNr"> 542 </span> 3d/compare-eax-and 9/imm32/tab -<span id="L543" class="LineNr"> 543 </span> 74/jump-if-equal $scan-next-byte:loop/disp8 +<span id="L543" class="LineNr"> 543 </span> 74/jump-if-equal $scan-next-byte:<span class="Constant">loop</span>/disp8 <span id="L544" class="LineNr"> 544 </span> <span class="subxComment"># if (eax == '\n') continue</span> <span id="L545" class="LineNr"> 545 </span> 3d/compare-eax-and 0xa/imm32/newline -<span id="L546" class="LineNr"> 546 </span> 74/jump-if-equal $scan-next-byte:loop/disp8 +<span id="L546" class="LineNr"> 546 </span> 74/jump-if-equal $scan-next-byte:<span class="Constant">loop</span>/disp8 <span id="L547" class="LineNr"> 547 </span><span class="Constant">$scan-next-byte:check2</span>: <span id="L548" class="LineNr"> 548 </span> <span class="subxComment"># if (eax == '#') skip-until-newline(in)</span> <span id="L549" class="LineNr"> 549 </span> 3d/compare-with-eax 0x23/imm32 @@ -616,7 +616,7 @@ if ('onhashchange' in window) { <span id="L555" class="LineNr"> 555 </span> e8/call <a href='hex.subx.html#L1395'>skip-until-newline</a>/disp32 <span id="L556" class="LineNr"> 556 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L557" class="LineNr"> 557 </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> 4/imm32 <span class="subxComment"># add to esp</span> -<span id="L558" class="LineNr"> 558 </span> eb/jump $scan-next-byte:loop/disp8 +<span id="L558" class="LineNr"> 558 </span> eb/jump $scan-next-byte:<span class="Constant">loop</span>/disp8 <span id="L559" class="LineNr"> 559 </span><span class="Constant">$scan-next-byte:check3</span>: <span id="L560" class="LineNr"> 560 </span> <span class="subxComment"># otherwise error-byte(ed, err, msg, eax)</span> <span id="L561" class="LineNr"> 561 </span> <span class="subxS2Comment"># . . push args</span> @@ -1479,7 +1479,7 @@ if ('onhashchange' in window) { <span id="L1418" class="LineNr">1418 </span> 74/jump-if-equal $skip-until-newline:end/disp8 <span id="L1419" class="LineNr">1419 </span> <span class="subxS1Comment"># . if (eax != 0xa/newline) loop</span> <span id="L1420" class="LineNr">1420 </span> 3d/compare-eax-and 0xa/imm32/newline -<span id="L1421" class="LineNr">1421 </span> 75/jump-if-not-equal $skip-until-newline:loop/disp8 +<span id="L1421" class="LineNr">1421 </span> 75/jump-if-not-equal $skip-until-newline:<span class="Constant">loop</span>/disp8 <span id="L1422" class="LineNr">1422 </span><span class="Constant">$skip-until-newline:end</span>: <span id="L1423" class="LineNr">1423 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L1424" class="LineNr">1424 </span> 58/pop-to-eax |