https://github.com/akkartik/mu/blob/main/309stream.subx
  1 # Some unsafe methods not intended to be used directly in SubX, only through
  2 # Mu after proper type-checking.
  3 
  4 == code
  5 
  6 stream-empty?:  # s: (addr stream _) -> result/eax: boolean
  7     # . prologue
  8     55/push-ebp
  9     89/<- %ebp 4/r32/esp
 10     # . save registers
 11     51/push-ecx
 12     56/push-esi
 13     # result = false
 14     b8/copy-to-eax 0/imm32/false
 15     # esi = s
 16     8b/-> *(ebp+8) 6/r32/esi
 17     # return s->read >= s->write
 18     8b/-> *esi 1/r32/ecx
 19     39/compare-with *(esi+4) 1/r32/ecx
 20     0f 9d/set-if->= %al
 21 $stream-empty?:end:
 22     # . restore registers
 23     5e/pop-to-esi
 24     59/pop-to-ecx
 25     # . epilogue
 26     89/<- %esp 5/r32/ebp
 27     5d/pop-to-ebp
 28     c3/return
 29 
 30 stream-full?:  # s: (addr stream _) -> result/eax: boolean
 31     # . prologue
 32     55/push-ebp
 33     89/<- %ebp 4/r32/esp
 34     # . save registers
 35     51/push-ecx
 36     56/push-esi
 37     # result = false
 38     b8/copy-to-eax 0/imm32/false
 39     # esi = s
 40     8b/-> *(ebp+8) 6/r32/esi
 41     # return s->write >= s->size
 42     8b/-> *(esi+8) 1/r32/ecx
 43     39/compare-with *esi 1/r32/ecx
 44     0f 9d/set-if->= %al
 45 $stream-full?:end:
 46     # . restore registers
 47     5e/pop-to-esi
 48     59/pop-to-ecx
 49     # . epilogue
 50     89/<- %esp 5/r32/ebp
 51     5d/pop-to-ebp
 52     c3/return
 53 
 54 write-to-stream:  # s: (addr stream _), in: (addr byte), n: int
 55     # . prologue
 56     55/push-ebp
 57     89/<- %ebp 4/r32/esp
 58     # . save registers
 59     50/push-eax
 60     51/push-ecx
 61     52/push-edx
 62     53/push-ebx
 63     57/push-edi
 64     # edi = s
 65     8b/-> *(ebp+8) 7/r32/edi
 66     # var swrite/edx: int = s->write
 67     8b/-> *edi 2/r32/edx
 68     # if (swrite + n > s->size) abort
 69     8b/-> *(ebp+0x10) 1/r32/ecx
 70     01/add-to %ecx 2/r32/edx
 71     3b/compare 1/r32/ecx *(edi+8)
 72     0f 8f/jump-if-> $write-to-stream:abort/disp32
 73     # var out/edx: (addr byte) = s->data + s->write
 74     8d/copy-address *(edi+edx+0xc) 2/r32/edx
 75     # var outend/ebx: (addr byte) = out + n
 76     8b/-> *(ebp+0x10) 3/r32/ebx
 77     8d/copy-address *(edx+ebx) 3/r32/ebx
 78     # eax = in
 79     8b/-> *(ebp+0xc) 0/r32/eax
 80     # var inend/ecx: (addr byte) = in + n
 81     8b/-> *(ebp+0x10) 1/r32/ecx
 82     8d/copy-address *(eax+ecx) 1/r32/ecx
 83     #
 84     (_append-4  %edx %ebx  %eax %ecx)  # => eax
 85     # s->write += n
 86     8b/-> *(ebp+0x10) 1/r32/ecx
 87     01/add-to *edi 1/r32/ecx
 88 $write-to-stream:end:
 89     # . restore registers
 90     5f/pop-to-edi
 91     5b/pop-to-ebx
 92     5a/pop-to-edx
 93     59/pop-to-ecx
 94     58/pop-to-eax
 95     # . epilogue
 96     89/<- %esp 5/r32/ebp
 97     5d/pop-to-ebp
 98     c3/return
 99 
100 $write-to-stream:abort:
101     (draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "write-to-stream: stream full" 3 0)  # 3=cyan
102     {
103       eb/jump loop/disp8
104     }
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* 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 */
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module test.tc_directory</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="test.html"><font color="#ffffff">test</font></a>.tc_directory</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/ranger/test/tc_directory.py">/home/hut/ranger/test/tc_directory.py</