about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--html/subx/056write.subx.html98
-rw-r--r--subx/056write.subx8
-rwxr-xr-xsubx/apps/crenshaw2-1bin6480 -> 6482 bytes
-rwxr-xr-xsubx/apps/crenshaw2-1bbin7041 -> 7043 bytes
-rwxr-xr-xsubx/apps/factorialbin5371 -> 5373 bytes
5 files changed, 53 insertions, 53 deletions
diff --git a/html/subx/056write.subx.html b/html/subx/056write.subx.html
index 7ada1e78..727bda6b 100644
--- a/html/subx/056write.subx.html
+++ b/html/subx/056write.subx.html
@@ -92,55 +92,55 @@ if ('onhashchange' in window) {
 <span id="L27" class="LineNr"> 27 </span>    b8/copy-to-EAX  1/imm32
 <span id="L28" class="LineNr"> 28 </span>    cd/syscall  0x80/imm8
 <span id="L29" class="LineNr"> 29 </span>
-<span id="L30" class="LineNr"> 30 </span><span class="subxFunction">write</span>:  <span class="subxComment"># f : fd or (address stream), s : (address array byte) -&gt; bytes_written/EAX</span>
-<span id="L31" class="LineNr"> 31 </span>    <span class="subxComment"># (If we ever leave the Linux kernel behind, it may be better to return</span>
-<span id="L32" class="LineNr"> 32 </span>    <span class="subxComment"># the number of bytes *not* written. Success would then be signaled by</span>
-<span id="L33" class="LineNr"> 33 </span>    <span class="subxComment"># returning 0.)</span>
-<span id="L34" class="LineNr"> 34 </span>    <span class="subxS1Comment"># . prolog</span>
-<span id="L35" class="LineNr"> 35 </span>    55/push-EBP
-<span id="L36" class="LineNr"> 36 </span>    89/copy                         3/mod/direct    5/rm32/EBP   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>          4/r32/ESP  <span class="CommentedCode"> . </span>             <span class="CommentedCode"> . </span>                <span class="subxComment"># copy ESP to EBP</span>
-<span id="L37" class="LineNr"> 37 </span>    <span class="subxComment"># if (f &lt; 0x08000000) _write(f, s), return  # f can't be a user-mode address, so treat it as a kernel file descriptor</span>
-<span id="L38" class="LineNr"> 38 </span>    81          7/subop/compare     1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>          8/disp8         0x08000000/imm32  <span class="subxComment"># compare *(EBP+8)</span>
-<span id="L39" class="LineNr"> 39 </span>    7d/jump-if-greater-or-equal  $write:fake/disp8
-<span id="L40" class="LineNr"> 40 </span>    <span class="subxS2Comment"># . . push args</span>
-<span id="L41" class="LineNr"> 41 </span>    ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>          0xc/disp8      <span class="CommentedCode"> . </span>                <span class="subxComment"># push *(EBP+12)</span>
-<span id="L42" class="LineNr"> 42 </span>    ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>          8/disp8        <span class="CommentedCode"> . </span>                <span class="subxComment"># push *(EBP+8)</span>
-<span id="L43" class="LineNr"> 43 </span>    <span class="subxS2Comment"># . . call</span>
-<span id="L44" class="LineNr"> 44 </span>    e8/call  _write/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="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>              8/imm32           <span class="subxComment"># add to ESP</span>
-<span id="L47" class="LineNr"> 47 </span>    eb/jump  $write:end/disp8
-<span id="L48" class="LineNr"> 48 </span><span class="Constant">$write:fake</span>:
-<span id="L49" class="LineNr"> 49 </span>    <span class="subxComment"># otherwise, treat 'f' as a stream to append to</span>
-<span id="L50" class="LineNr"> 50 </span>    <span class="subxS1Comment"># . save registers</span>
-<span id="L51" class="LineNr"> 51 </span>    51/push-ECX
-<span id="L52" class="LineNr"> 52 </span>    52/push-EDX
-<span id="L53" class="LineNr"> 53 </span>    53/push-EBX
-<span id="L54" class="LineNr"> 54 </span>    <span class="subxComment"># ECX = f</span>
-<span id="L55" class="LineNr"> 55 </span>    8b/copy                         1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none              1/r32/ECX   8/disp8        <span class="CommentedCode"> . </span>                <span class="subxComment"># copy *(EBP+8) to ECX</span>
-<span id="L56" class="LineNr"> 56 </span>    <span class="subxComment"># EDX = f-&gt;write</span>
-<span id="L57" class="LineNr"> 57 </span>    8b/copy                         0/mod/indirect  1/rm32/ECX   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>          2/r32/EDX  <span class="CommentedCode"> . </span>             <span class="CommentedCode"> . </span>                <span class="subxComment"># copy *ECX to EDX</span>
-<span id="L58" class="LineNr"> 58 </span>    <span class="subxComment"># EBX = f-&gt;length</span>
-<span id="L59" class="LineNr"> 59 </span>    8b/copy                         1/mod/*+disp8   1/rm32/ECX   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>          3/r32/EBX   8/disp8        <span class="CommentedCode"> . </span>                <span class="subxComment"># copy *(ECX+8) to EBX</span>
-<span id="L60" class="LineNr"> 60 </span>    <span class="subxComment"># EAX = _append-3(&amp;f-&gt;data[f-&gt;write], &amp;f-&gt;data[f-&gt;length], s)</span>
-<span id="L61" class="LineNr"> 61 </span>    <span class="subxS2Comment"># . . push s</span>
-<span id="L62" class="LineNr"> 62 </span>    ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>          0xc/disp8      <span class="CommentedCode"> . </span>                <span class="subxComment"># push *(EBP+12)</span>
-<span id="L63" class="LineNr"> 63 </span>    <span class="subxS2Comment"># . . push &amp;f-&gt;data[f-&gt;length]</span>
-<span id="L64" class="LineNr"> 64 </span>    8d/copy-address                 1/mod/*+disp8   4/rm32/sib    1/base/ECX  3/index/EBX  <span class="CommentedCode"> . </span>          3/r32/EBX   0xc/disp8      <span class="CommentedCode"> . </span>                <span class="subxComment"># copy ECX+EBX+12 to EBX</span>
-<span id="L65" class="LineNr"> 65 </span>    53/push-EBX
-<span id="L66" class="LineNr"> 66 </span>    <span class="subxS2Comment"># . . push &amp;f-&gt;data[f-&gt;write]</span>
-<span id="L67" class="LineNr"> 67 </span>    8d/copy-address                 1/mod/*+disp8   4/rm32/sib    1/base/ECX  2/index/EDX  <span class="CommentedCode"> . </span>          3/r32/EBX   0xc/disp8      <span class="CommentedCode"> . </span>                <span class="subxComment"># copy ECX+EDX+12 to EBX</span>
-<span id="L68" class="LineNr"> 68 </span>    53/push-EBX
-<span id="L69" class="LineNr"> 69 </span>    <span class="subxS2Comment"># . . call</span>
-<span id="L70" class="LineNr"> 70 </span>    e8/call  _append-3/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="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>              0xc/imm32         <span class="subxComment"># add to ESP</span>
-<span id="L73" class="LineNr"> 73 </span>    <span class="subxComment"># f-&gt;write += EAX</span>
-<span id="L74" class="LineNr"> 74 </span>    01/add                          0/mod/indirect  1/rm32/ECX   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>          0/r32/EAX  <span class="CommentedCode"> . </span>             <span class="CommentedCode"> . </span>                <span class="subxComment"># add EAX to *ECX</span>
-<span id="L75" class="LineNr"> 75 </span>    <span class="subxS1Comment"># . restore registers</span>
-<span id="L76" class="LineNr"> 76 </span>    5b/pop-to-EBX
-<span id="L77" class="LineNr"> 77 </span>    5a/pop-to-EDX
-<span id="L78" class="LineNr"> 78 </span>    59/pop-to-ECX
+<span id="L30" class="LineNr"> 30 </span><span class="subxComment"># TODO: come up with a way to signal when a write to disk fails</span>
+<span id="L31" class="LineNr"> 31 </span><span class="subxFunction">write</span>:  <span class="subxComment"># f : fd or (address stream), s : (address array byte) -&gt; &lt;void&gt;</span>
+<span id="L32" class="LineNr"> 32 </span>    <span class="subxS1Comment"># . prolog</span>
+<span id="L33" class="LineNr"> 33 </span>    55/push-EBP
+<span id="L34" class="LineNr"> 34 </span>    89/copy                         3/mod/direct    5/rm32/EBP   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>          4/r32/ESP  <span class="CommentedCode"> . </span>             <span class="CommentedCode"> . </span>                <span class="subxComment"># copy ESP to EBP</span>
+<span id="L35" class="LineNr"> 35 </span>    <span class="subxComment"># if (f &lt; 0x08000000) _write(f, s), return  # f can't be a user-mode address, so treat it as a kernel file descriptor</span>
+<span id="L36" class="LineNr"> 36 </span>    81          7/subop/compare     1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>          8/disp8         0x08000000/imm32  <span class="subxComment"># compare *(EBP+8)</span>
+<span id="L37" class="LineNr"> 37 </span>    7d/jump-if-greater-or-equal  $write:fake/disp8
+<span id="L38" class="LineNr"> 38 </span>    <span class="subxS2Comment"># . . push args</span>
+<span id="L39" class="LineNr"> 39 </span>    ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>          0xc/disp8      <span class="CommentedCode"> . </span>                <span class="subxComment"># push *(EBP+12)</span>
+<span id="L40" class="LineNr"> 40 </span>    ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>          8/disp8        <span class="CommentedCode"> . </span>                <span class="subxComment"># push *(EBP+8)</span>
+<span id="L41" class="LineNr"> 41 </span>    <span class="subxS2Comment"># . . call</span>
+<span id="L42" class="LineNr"> 42 </span>    e8/call  _write/disp32
+<span id="L43" class="LineNr"> 43 </span>    <span class="subxS2Comment"># . . discard args</span>
+<span id="L44" class="LineNr"> 44 </span>    81          0/subop/add         3/mod/direct    4/rm32/ESP   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>              8/imm32           <span class="subxComment"># add to ESP</span>
+<span id="L45" class="LineNr"> 45 </span>    eb/jump  $write:end/disp8
+<span id="L46" class="LineNr"> 46 </span><span class="Constant">$write:fake</span>:
+<span id="L47" class="LineNr"> 47 </span>    <span class="subxComment"># otherwise, treat 'f' as a stream to append to</span>
+<span id="L48" class="LineNr"> 48 </span>    <span class="subxS1Comment"># . save registers</span>
+<span id="L49" class="LineNr"> 49 </span>    50/push-EAX
+<span id="L50" class="LineNr"> 50 </span>    51/push-ECX
+<span id="L51" class="LineNr"> 51 </span>    52/push-EDX
+<span id="L52" class="LineNr"> 52 </span>    53/push-EBX
+<span id="L53" class="LineNr"> 53 </span>    <span class="subxComment"># ECX = f</span>
+<span id="L54" class="LineNr"> 54 </span>    8b/copy                         1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none              1/r32/ECX   8/disp8        <span class="CommentedCode"> . </span>                <span class="subxComment"># copy *(EBP+8) to ECX</span>
+<span id="L55" class="LineNr"> 55 </span>    <span class="subxComment"># EDX = f-&gt;write</span>
+<span id="L56" class="LineNr"> 56 </span>    8b/copy                         0/mod/indirect  1/rm32/ECX   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>          2/r32/EDX  <span class="CommentedCode"> . </span>             <span class="CommentedCode"> . </span>                <span class="subxComment"># copy *ECX to EDX</span>
+<span id="L57" class="LineNr"> 57 </span>    <span class="subxComment"># EBX = f-&gt;length</span>
+<span id="L58" class="LineNr"> 58 </span>    8b/copy                         1/mod/*+disp8   1/rm32/ECX   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>          3/r32/EBX   8/disp8        <span class="CommentedCode"> . </span>                <span class="subxComment"># copy *(ECX+8) to EBX</span>
+<span id="L59" class="LineNr"> 59 </span>    <span class="subxComment"># EAX = _append-3(&amp;f-&gt;data[f-&gt;write], &amp;f-&gt;data[f-&gt;length], s)</span>
+<span id="L60" class="LineNr"> 60 </span>    <span class="subxS2Comment"># . . push s</span>
+<span id="L61" class="LineNr"> 61 </span>    ff          6/subop/push        1/mod/*+disp8   4/rm32/sib    5/base/EBP  4/index/none <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>          0xc/disp8      <span class="CommentedCode"> . </span>                <span class="subxComment"># push *(EBP+12)</span>
+<span id="L62" class="LineNr"> 62 </span>    <span class="subxS2Comment"># . . push &amp;f-&gt;data[f-&gt;length]</span>
+<span id="L63" class="LineNr"> 63 </span>    8d/copy-address                 1/mod/*+disp8   4/rm32/sib    1/base/ECX  3/index/EBX  <span class="CommentedCode"> . </span>          3/r32/EBX   0xc/disp8      <span class="CommentedCode"> . </span>                <span class="subxComment"># copy ECX+EBX+12 to EBX</span>
+<span id="L64" class="LineNr"> 64 </span>    53/push-EBX
+<span id="L65" class="LineNr"> 65 </span>    <span class="subxS2Comment"># . . push &amp;f-&gt;data[f-&gt;write]</span>
+<span id="L66" class="LineNr"> 66 </span>    8d/copy-address                 1/mod/*+disp8   4/rm32/sib    1/base/ECX  2/index/EDX  <span class="CommentedCode"> . </span>          3/r32/EBX   0xc/disp8      <span class="CommentedCode"> . </span>                <span class="subxComment"># copy ECX+EDX+12 to EBX</span>
+<span id="L67" class="LineNr"> 67 </span>    53/push-EBX
+<span id="L68" class="LineNr"> 68 </span>    <span class="subxS2Comment"># . . call</span>
+<span id="L69" class="LineNr"> 69 </span>    e8/call  _append-3/disp32
+<span id="L70" class="LineNr"> 70 </span>    <span class="subxS2Comment"># . . discard args</span>
+<span id="L71" class="LineNr"> 71 </span>    81          0/subop/add         3/mod/direct    4/rm32/ESP   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>              0xc/imm32         <span class="subxComment"># add to ESP</span>
+<span id="L72" class="LineNr"> 72 </span>    <span class="subxComment"># f-&gt;write += EAX</span>
+<span id="L73" class="LineNr"> 73 </span>    01/add                          0/mod/indirect  1/rm32/ECX   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>          0/r32/EAX  <span class="CommentedCode"> . </span>             <span class="CommentedCode"> . </span>                <span class="subxComment"># add EAX to *ECX</span>
+<span id="L74" class="LineNr"> 74 </span>    <span class="subxS1Comment"># . restore registers</span>
+<span id="L75" class="LineNr"> 75 </span>    5b/pop-to-EBX
+<span id="L76" class="LineNr"> 76 </span>    5a/pop-to-EDX
+<span id="L77" class="LineNr"> 77 </span>    59/pop-to-ECX
+<span id="L78" class="LineNr"> 78 </span>    58/pop-to-EAX
 <span id="L79" class="LineNr"> 79 </span><span class="Constant">$write:end</span>:
 <span id="L80" class="LineNr"> 80 </span>    <span class="subxS1Comment"># . epilog</span>
 <span id="L81" class="LineNr"> 81 </span>    89/copy                         3/mod/direct    4/rm32/ESP   <span class="CommentedCode"> . </span>         <span class="CommentedCode"> . </span>           <span class="CommentedCode"> . </span>          5/r32/EBP  <span class="CommentedCode"> . </span>             <span class="CommentedCode"> . </span>                <span class="subxComment"># copy EBP to ESP</span>
diff --git a/subx/056write.subx b/subx/056write.subx
index 3496d980..c76d0737 100644
--- a/subx/056write.subx
+++ b/subx/056write.subx
@@ -27,10 +27,8 @@
     b8/copy-to-EAX  1/imm32
     cd/syscall  0x80/imm8
 
-write:  # f : fd or (address stream), s : (address array byte) -> bytes_written/EAX
-    # (If we ever leave the Linux kernel behind, it may be better to return
-    # the number of bytes *not* written. Success would then be signaled by
-    # returning 0.)
+# TODO: come up with a way to signal when a write to disk fails
+write:  # f : fd or (address stream), s : (address array byte) -> <void>
     # . prolog
     55/push-EBP
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
@@ -48,6 +46,7 @@ write:  # f : fd or (address stream), s : (address array byte) -> bytes_written/
 $write:fake:
     # otherwise, treat 'f' as a stream to append to
     # . save registers
+    50/push-EAX
     51/push-ECX
     52/push-EDX
     53/push-EBX
@@ -76,6 +75,7 @@ $write:fake:
     5b/pop-to-EBX
     5a/pop-to-EDX
     59/pop-to-ECX
+    58/pop-to-EAX
 $write:end:
     # . epilog
     89/copy                         3/mod/direct    4/rm32/ESP    .           .             .           5/r32/EBP   .               .                 # copy EBP to ESP
diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index 47762af7..10003ae7 100755
--- a/subx/apps/crenshaw2-1
+++ b/subx/apps/crenshaw2-1
Binary files differdiff --git a/subx/apps/crenshaw2-1b b/subx/apps/crenshaw2-1b
index 620c1bad..20eaafe0 100755
--- a/subx/apps/crenshaw2-1b
+++ b/subx/apps/crenshaw2-1b
Binary files differdiff --git a/subx/apps/factorial b/subx/apps/factorial
index d3a50805..7d867940 100755
--- a/subx/apps/factorial
+++ b/subx/apps/factorial
Binary files differ