about summary refs log tree commit diff stats
path: root/html/subx/examples/ex6.subx.html
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-12-30 20:24:37 -0800
committerKartik Agaram <vc@akkartik.com>2018-12-30 20:24:37 -0800
commit901ae474300d70bcc00e7e0b420ca87c8cbf6f55 (patch)
treeaf60b1c8c92bfc10a6bb6bd1082a765fcc718004 /html/subx/examples/ex6.subx.html
parent0474ec865af12cff08dd255954fbccf6d38085e6 (diff)
downloadmu-901ae474300d70bcc00e7e0b420ca87c8cbf6f55.tar.gz
4899
Bug in my linkify tool introduced in commit 4891.
Diffstat (limited to 'html/subx/examples/ex6.subx.html')
-rw-r--r--html/subx/examples/ex6.subx.html4
1 files changed, 2 insertions, 2 deletions
diff --git a/html/subx/examples/ex6.subx.html b/html/subx/examples/ex6.subx.html
index e06a0885..d2d01bed 100644
--- a/html/subx/examples/ex6.subx.html
+++ b/html/subx/examples/ex6.subx.html
@@ -84,9 +84,9 @@ if ('onhashchange' in window) {
 <span id="L27" class="LineNr">27 </span>
 <span id="L28" class="LineNr">28 </span>== data
 <span id="L29" class="LineNr">29 </span>
-<span id="L30" class="LineNr">30 </span><span class="SpecialChar"><a href='ex6.subx.html#L30'>Size</a></span>:  <span class="subxComment"># size of string</span>
+<span id="L30" class="LineNr">30 </span><span class="SpecialChar">Size</span>:  <span class="subxComment"># size of string</span>
 <span id="L31" class="LineNr">31 </span>    0e 00 00 00  <span class="subxComment"># 14</span>
-<span id="L32" class="LineNr">32 </span><span class="SpecialChar"><a href='ex6.subx.html#L32'>X</a></span>:  <span class="subxComment"># string to print</span>
+<span id="L32" class="LineNr">32 </span><span class="SpecialChar">X</span>:  <span class="subxComment"># string to print</span>
 <span id="L33" class="LineNr">33 </span>    48 65 6c 6c 6f 2c 20 77 6f 72 6c 64 21 0a       00
 <span id="L34" class="LineNr">34 </span><span class="subxComment">#   H  e  l  l  o  ,  ␣  w  o  r  l  d  !  newline  null</span>
 <span id="L35" class="LineNr">35 </span>
ld } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Methods for constructing buffered-file objects.
#
# TODO: There are hard-coded parameters here for buffer sizes. When they
# overflow, tracking down what's going on can get hairy.
#
# HACK: buffered-file stores naked addrs. This is safe because buffered-file
# objects are opaque. But still sub-optimal; they'll be harder to reclaim when
# we get around to that.

== code

open:  # filename: (addr array byte), write?: boolean, out: (addr handle buffered-file)
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # . save registers
    50/push-eax
    51/push-ecx
    # var new-fd/ecx: fd
    (open-fd *(ebp+8) *(ebp+0xc))  # => eax
    89/<- %ecx 0/r32/eax
    # if fd < 0 return
    3d/compare-eax-with 0/imm32
    7c/jump-if-< $open:end/disp8
    # allocate a buffered-file
    (allocate Heap 0x1010 *(ebp+0x10))  # file-buffer-size + 16 for other fields
    # var out-addr/eax: (addr buffered-file)
    8b/-> *(ebp+0x10) 0/r32/eax
    (lookup *eax *(eax+4))  # => eax
    # out-addr->size = 4KB
    c7 0/subop/copy *(eax+0xc) 0x1000/imm32/file-buffer-size  # Stream-size + 4 for fd
    # out-addr->fd = fd
    89/<- *eax 1/r32/ecx
$open:end:
    # . restore registers
    59/pop-to-ecx
    58/pop-to-eax
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

open-fd:  # filename: (addr array byte), write?: boolean -> result/eax: fd
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # . save registers
    51/push-ecx
    52/push-edx
    53/push-ebx
    56/push-esi
    # ecx = filename
    8b/-> *(ebp+8) 1/r32/ecx
    # var size/edx: int = filename->length + 1 for the trailing null character
    8b/-> *ecx 2/r32/edx
    42/increment-edx
    # var s/esi: (stream size)
    29/subtract-from %esp 2/r32/edx
    52/push-edx  # size
    68/push 0/imm32/read
    68/push 0/imm32/write
    89/<- %esi 4/r32/esp
    # copy filename and a final null character
    (clear-stream %esi)
    (write %esi %ecx)
    # spill edx
    52/push-edx
    # var fd/eax: fd = open(filename)
    8d/copy-address *(esi+0xc) 3/r32/ebx
    8b/-> *(ebp+0xc) 1/r32/ecx/flags
    ba/copy-to-edx 0x180/imm32/permissions
    e8/call syscall_open/disp32
    # restore edx
    5a/pop-to-edx
$open-fd:end:
    # . reclaim locals
    01/add-to %esp 2/r32/edx
    81 0/subop/add %esp 0xc/imm32
    # . restore registers
    5e/pop-to-esi
    5b/pop-to-ebx
    5a/pop-to-edx
    59/pop-to-ecx
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

populate-buffered-file-containing:  # contents: (addr array byte), out: (addr handle buffered-file)
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # . save registers
    50/push-eax
    51/push-ecx
    56/push-esi
    57/push-edi
    # esi = contents
    8b/-> *(ebp+8) 6/r32/esi
    # var n/ecx: int = len(contents)
    8b/-> *esi 1/r32/ecx
    # var stream/edi: (handle stream byte)
    68/push 0/imm32
    68/push 0/imm32
    89/<- %edi 4/r32/esp
    # allocate stream
    (new-stream Heap %ecx 1 %edi)
    # var stream-addr/edi: (addr stream byte) = lookup(stream)
    (lookup *edi *(edi+4))  # => eax
    89/<- %edi 0/r32/eax
    # write contents to stream
    (write %edi %esi)
    # allocate buffered-file
    (allocate Heap 0x110 *(ebp+0xc))
    # var out-addr/eax: (addr buffered-file)
    8b/-> *(ebp+0xc) 0/r32/eax
    (lookup *eax *(eax+4))  # => eax
    # out-addr->size = 256 bytes
    c7 0/subop/copy *(eax+0xc) 0x100/imm32/file-buffer-size
    # out-addr->fd = stream
    89/<- *eax 7/r32/edi
$populate-buffered-file-containing:end:
    # . reclaim locals
    81 0/subop/add %esp 8/imm32
    # . restore registers
    5f/pop-to-edi
    5e/pop-to-esi
    59/pop-to-ecx
    58/pop-to-eax
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

new-buffered-file:  # out: (addr handle buffered-file)
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    # . save registers
    50/push-eax
    51/push-ecx
    # var stream/ecx: (handle stream byte)
    68/push 0/imm32
    68/push 0/imm32
    89/<- %ecx 4/r32/esp
    # allocate stream
    (new-stream Heap 0x100 1 %ecx)
    # var stream-addr/ecx: (addr stream byte) = lookup(stream)
    (lookup *ecx *(ecx+4))  # => eax
    89/<- %ecx 0/r32/eax
    # allocate buffered-file
    (allocate Heap 0x110 *(ebp+8))
    # var out-addr/eax: (addr buffered-file)
    8b/-> *(ebp+8) 0/r32/eax
    (lookup *eax *(eax+4))  # => eax
    # out-addr->size = 256 bytes
    c7 0/subop/copy *(eax+0xc) 0x100/imm32/file-buffer-size
    # out-addr->fd = stream
    89/<- *eax 1/r32/ecx
$new-buffered-file:end:
    # . reclaim locals
    81 0/subop/add %esp 8/imm32
    # . restore registers
    59/pop-to-ecx
    58/pop-to-eax
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return