https://github.com/akkartik/mu/blob/main/linux/calls.subx
   1 # Function calls in a single line.
   2 #
   3 # To run (on Linux):
   4 #   $ ./translate_subx init.linux [012]*.subx subx-params.subx calls.subx
   5 #   $ mv a.elf calls
   6 #
   7 # Example 1:
   8 #   $ echo '(foo %eax)'                         |  calls
   9 #   # . (foo %eax)                                      # output has comments
  10 #   ff 6/subop/push %eax                                # push
  11 #   e8/call foo/disp32                                  # call
  12 #   81 0/subop/add %esp 4/imm32                         # undo push
  13 #
  14 # Example 2:
  15 #   $ echo '(foo Var1 *(eax + 4) "blah")'       |  calls
  16 #   # . (foo Var1 *(eax + 4) "blah")
  17 #   68/push "blah"/imm32
  18 #   ff 6/subop/push *(eax + 4)                          # push args in..
  19 #   68/push Var1/imm32                                  # ..reverse order
  20 #   e8/call foo/disp32
  21 #   81 0/subop/add %esp 0xc/imm32                       # undo pushes
  22 #
  23 # Calls always begin with '(' as the first non-whitespace on a line.
  24 
  25 == code
  26 
  27 Entry:  # run tests if necessary, convert stdin if not
  28     # . prologue
  29     89/<- %ebp 4/r32/esp
  30 
  31     # initialize heap
  32     # . Heap = new-segment(Heap-size)
  33     # . . push args
  34     68/push Heap/imm32
  35     ff 6/subop/push *Heap-size
  36     # . . call
  37     e8/call new-segment/disp32
  38     # . . discard args
  39     81 0/subop/add %esp 8/imm32
  40 
  41     # - if argc > 1 and argv[1] == "test", then return run_tests()
  42     # if (argc <= 1) goto run-main
  43     81 7/subop/compare *ebp 1/imm32
  44     7e/jump-if-<= $subx-calls-main:interactive/disp8
  45     # if (!kernel-string-equal?(argv[1], "test")) goto run-main
  46     # . eax = kernel-string-equal?(argv[1], "test")
  47     # . . push args
  48     68/push "test"/imm32
  49     ff 6/subop/push *(ebp+8)
  50     # . . call
  51     e8/call kernel-string-equal?/disp32
  52     # . . discard args
  53     81 0/subop/add %esp 8/imm32
  54     # . if (eax == false) goto run-main
  55     3d/compare-eax-and 0/imm32/false
  56     74/jump-if-= $subx-calls-main:interactive/disp8
  57     # run-tests()
  58     e8/call run-tests/disp32
  59     # syscall(exit, *Num-test-failures)
  60     8b/-> *Num-test-failures 3/r32/ebx
  61     eb/jump $subx-calls-main:end/disp8
  62 $subx-calls-main:interactive:
  63     # - otherwise convert stdin
  64     # subx-calls(Stdin, Stdout)
  65     # . . push args
  66     68/push Stdout/imm32
  67     68/push 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 ranger.container.history</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</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="ranger.html"><font color="#ffffff">ranger</font></a>.<a href="ranger.container.html"><font color="#ffffff">container</font></a>.history</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/work/ranger/ranger/container/history.py">/home/hut/work/ranger/ranger/container/history.py</a></font></td></tr></table>
    <p></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#Exception">builtins.Exception</a>(<a href="builtins.html#BaseException">builtins.BaseException</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.container.history.html#HistoryEmptyException">HistoryEmptyException</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.container.history.html#History">History</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="History">class <strong>History</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="History-__init__"><strong>__init__</strong></a>(self, maxlen<font color="#909090">=None</font>)</dt></dl>

<dl><dt><a name="History-__iter__"><strong>__iter__</strong></a>(self)</dt></dl>

<dl><dt><a name="History-__len__"><strong>__len__</strong></a>(self)</dt></dl>

<dl><dt><a name="History-add"><strong>add</strong></a>(self, item)</dt></dl>

<dl><dt><a name="History-back"><strong>back</strong></a>(self)</dt></dl>

<dl><dt><a name="History-bottom"><strong>bottom</strong></a>(self)</dt></dl>

<dl><dt><a name="History-current"><strong>current</strong></a>(self)</dt></dl>

<dl><dt><a name="History-fast_forward"><strong>fast_forward</strong></a>(self)</dt></dl>

<dl><dt><a name="History-forward"><strong>forward</strong></a>(self)</dt></dl>

<dl><dt><a name="History-modify"><strong>modify</strong></a>(self, item)</dt></dl>

<dl><dt><a name="History-move"><strong>move</strong></a>(self, n)</dt></dl>

<dl><dt><a name="History-next"><strong>next</strong></a>(self)</dt></dl>

<dl><dt><a name="History-top"><strong>top</strong></a>(self)</dt></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="HistoryEmptyException">class <strong>HistoryEmptyException</strong></a>(<a href="builtins.html#Exception">builtins.Exception</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.container.history.html#HistoryEmptyException">HistoryEmptyException</a></dd>
<dd><a href="builtins.html#Exception">builtins.Exception</a></dd>
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="builtins.html#Exception">builtins.Exception</a>:<br>
<dl><dt><a name="HistoryEmptyException-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#HistoryEmptyException-__init__">__init__</a>(...)&nbsp;initializes&nbsp;x;&nbsp;see&nbsp;x.__class__.__doc__&nbsp;for&nbsp;signature</tt></dd></dl>

<hr>
Data and other attributes inherited from <a href="builtins.html#Exception">builtins.Exception</a>:<br>
<dl><dt><strong>__new__</strong> = &lt;built-in method __new__ of type object at 0x7f327d94a120&gt;<dd><tt>T.<a href="#HistoryEmptyException-__new__">__new__</a>(S,&nbsp;...)&nbsp;-&gt;&nbsp;a&nbsp;new&nbsp;<a href="builtins.html#object">object</a>&nbsp;with&nbsp;type&nbsp;S,&nbsp;a&nbsp;subtype&nbsp;of&nbsp;T</tt></dl>

<hr>
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
<dl><dt><a name="HistoryEmptyException-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#HistoryEmptyException-__delattr__">__delattr__</a>('name')&nbsp;&lt;==&gt;&nbsp;del&nbsp;x.name</tt></dd></dl>

<dl><dt><a name="HistoryEmptyException-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#HistoryEmptyException-__getattribute__">__getattribute__</a>('name')&nbsp;&lt;==&gt;&nbsp;x.name</tt></dd></dl>

<dl><dt><a name="HistoryEmptyException-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl>

<dl><dt><a name="HistoryEmptyException-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#HistoryEmptyException-__repr__">__repr__</a>()&nbsp;&lt;==&gt;&nbsp;repr(x)</tt></dd></dl>

<dl><dt><a name="HistoryEmptyException-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#HistoryEmptyException-__setattr__">__setattr__</a>('name',&nbsp;value)&nbsp;&lt;==&gt;&nbsp;x.name&nbsp;=&nbsp;value</tt></dd></dl>

<dl><dt><a name="HistoryEmptyException-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>

<dl><dt><a name="HistoryEmptyException-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#HistoryEmptyException-__str__">__str__</a>()&nbsp;&lt;==&gt;&nbsp;str(x)</tt></dd></dl>

<dl><dt><a name="HistoryEmptyException-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt><a href="builtins.html#Exception">Exception</a>.<a href="#HistoryEmptyException-with_traceback">with_traceback</a>(tb)&nbsp;--<br>
set&nbsp;self.<strong>__traceback__</strong>&nbsp;to&nbsp;tb&nbsp;and&nbsp;return&nbsp;self.</tt></dd></dl>

<hr>
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
<dl><dt><strong>__cause__</strong></dt>
<dd><tt>exception&nbsp;cause</tt></dd>
</dl>
<dl><dt><strong>__context__</strong></dt>
<dd><tt>exception&nbsp;context</tt></dd>
</dl>
<dl><dt><strong>__dict__</strong></dt>
</dl>
<dl><dt><strong>__traceback__</strong></dt>
</dl>
<dl><dt><strong>args</strong></dt>
</dl>
</td></tr></table></td></tr></table>
</body></html>
an> # . clear-stream(_test-output-stream) 689 # . . push args 690 68/push _test-output-stream/imm32 691 # . . call 692 e8/call clear-stream/disp32 693 # . . discard args 694 81 0/subop/add %esp 4/imm32 695 # . clear-stream($_test-output-buffered-file->buffer) 696 # . . push args 697 68/push $_test-output-buffered-file->buffer/imm32 698 # . . call 699 e8/call clear-stream/disp32 700 # . . discard args 701 81 0/subop/add %esp 4/imm32 702 # . write(_test-input-stream, "(foo %eax)\n") 703 # . . push args 704 68/push "(foo %eax)\n"/imm32 705 68/push _test-input-stream/imm32 706 # . . call 707 e8/call write/disp32 708 # . . discard args 709 81 0/subop/add %esp 8/imm32 710 # subx-calls(_test-input-buffered-file, _test-output-buffered-file) 711 # . . push args 712 68/push _test-output-buffered-file/imm32 713 68/push _test-input-buffered-file/imm32 714 # . . call 715 e8/call subx-calls/disp32 716 # . . discard args 717 81 0/subop/add %esp 8/imm32 718 # check that the line just passed through 719 # . flush(_test-output-buffered-file) 720 # . . push args 721 68/push _test-output-buffered-file/imm32 722 # . . call 723 e8/call flush/disp32 724 # . . discard args 725 81 0/subop/add %esp 4/imm32 726 +-- 33 lines: #? # dump _test-output-stream ---------------------------------------------------------------------------------------------------------------------------- 759 # . check-next-stream-line-equal(_test-output-stream, "# . (foo %eax)", msg) 760 # . . push args 761 68/push "F - test-subx-calls-processes-calls: comment"/imm32 762 68/push "# . (foo %eax)"/imm32 763 68/push _test-output-stream/imm32 764 # . . call 765 e8/call check-next-stream-line-equal/disp32 766 # . . discard args 767 81 0/subop/add %esp 0xc/imm32 768 # . check-next-stream-line-equal(_test-output-stream, "ff 6/subop/push %eax", msg) 769 # . . push args 770 68/push "F - test-subx-calls-processes-calls: arg 0"/imm32 771 68/push "ff 6/subop/push %eax"/imm32 772 68/push _test-output-stream/imm32 773 # . . call 774 e8/call check-next-stream-line-equal/disp32 775 # . . discard args 776 81 0/subop/add %esp 0xc/imm32 777 # . check-next-stream-line-equal(_test-output-stream, "e8/call foo/disp32", msg) 778 # . . push args 779 68/push "F - test-subx-calls-processes-calls: call"/imm32 780 68/push "e8/call foo/disp32"/imm32 781 68/push _test-output-stream/imm32 782 # . . call 783 e8/call check-next-stream-line-equal/disp32 784 # . . discard args 785 81 0/subop/add %esp 0xc/imm32 786 # . check-next-stream-line-equal(_test-output-stream, "81 0/subop/add %esp 4/imm32", msg) 787 # . . push args 788 68/push "F - test-subx-calls-processes-calls: pops"/imm32 789 68/push "81 0/subop/add %esp 0x00000004/imm32"/imm32 790 68/push _test-output-stream/imm32 791 # . . call 792 e8/call check-next-stream-line-equal/disp32 793 # . . discard args 794 81 0/subop/add %esp 0xc/imm32 795 # . epilogue 796 89/<- %esp 5/r32/ebp 797 5d/pop-to-ebp 798 c3/return 799 800 next-word-string-or-expression-without-metadata: # line: (addr stream byte), out: (addr slice) 801 # pseudocode: 802 # skip-chars-matching(line, ' ') 803 # if line->read >= line->write # end of line 804 # out = {0, 0} 805 # return 806 # out->start = &line->data[line->read] 807 # if line->data[line->read] == '#' # comment 808 # out->end = &line->data[line->write] # skip to end of line 809 # return 810 # if line->data[line->read] == '"' # string literal 811 # skip-string(line) 812 # out->end = &line->data[line->read] # no metadata 813 # return 814 # if line->data[line->read] == '*' # expression 815 # if line->data[line->read + 1] == ' ' 816 # abort 817 # if line->data[line->read + 1] == '(' 818 # skip-until-close-paren(line) 819 # if (line->data[line->read] != ')' 820 # abort 821 # ++line->read to skip ')' 822 # out->end = &line->data[line->read] 823 # return 824 # if line->data[line->read] == '(' 825 # abort 826 # if line->data[line->read] == ')' 827 # ++line->read to skip ')' 828 # # make sure there's nothing else of importance 829 # if line->read >= line->write 830 # out = {0, 0} 831 # return 832 # if line->data[line->read] != ' ' 833 # abort 834 # skip-chars-matching-whitespace(line) 835 # if line->read >= line->write 836 # out = {0, 0} 837 # return 838 # if line->data[line->read] == '#' # only thing permitted after ')' is a comment 839 # out = {0, 0} 840 # return 841 # abort 842 # # default case: read a word -- but no metadata 843 # while true 844 # if line->read >= line->write 845 # break 846 # if line->data[line->read] == ' ' 847 # break 848 # if line->data[line->read] == ')' 849 # break 850 # if line->data[line->read] == '/' 851 # abort 852 # ++line->read 853 # out->end = &line->data[line->read] 854 # 855 # registers: 856 # ecx: often line->read 857 # eax: often line->data[line->read] 858 # 859 # . prologue 860 55/push-ebp 861 89/<- %ebp 4/r32/esp 862 # . save registers 863 50/push-eax 864 51/push-ecx 865 56/push-esi 866 57/push-edi 867 # esi = line 868 8b/-> *(ebp+8) 6/r32/esi 869 # edi = out 870 8b/-> *(ebp+0xc) 7/r32/edi 871 # skip-chars-matching(line, ' ') 872 # . . push args 873 68/push 0x20/imm32/space 874 ff 6/subop/push *(ebp+8) 875 # . . call 876 e8/call skip-chars-matching/disp32 877 # . . discard args 878 81 0/subop/add %esp 8/imm32 879 $next-word-string-or-expression-without-metadata:check0: 880 # if (line->read >= line->write) abort because we didn't encounter a final ')' 881 # . ecx = line->read 882 8b/-> *(esi+4) 1/r32/ecx 883 # . if (ecx >= line->write) abort 884 3b/compare<- *esi 1/r32/ecx 885 0f 8d/jump-if->= $next-word-string-or-expression-without-metadata:error0/disp32 886 $next-word-string-or-expression-without-metadata:check-for-comment: 887 # out->start = &line->data[line->read] 888 8d/copy-address *(esi+ecx+0xc) 0/r32/eax 889 89/<- *edi 0/r32/eax 890 # if (line->data[line->read] != '#') goto next check 891 # . var eax: byte = line->data[line->read] 892 31/xor-with %eax 0/r32/eax 893 8a/copy-byte *(esi+ecx+0xc) 0/r32/AL 894 # . if (eax != '#') goto next check 895 3d/compare-eax-and 0x23/imm32/pound 896 75/jump-if-!= $next-word-string-or-expression-without-metadata:check-for-string-literal/disp8 897 $next-word-string-or-expression-without-metadata:comment: 898 # out->end = &line->data[line->write] 899 8b/-> *esi 0/r32/eax 900 8d/copy-address *(esi+eax+0xc) 0/r32/eax 901 89/<- *(edi+4) 0/r32/eax 902 # line->read = line->write # skip rest of line 903 8b/-> *esi 0/r32/eax 904 89/<- *(esi+4) 0/r32/eax 905 # return 906 e9/jump $next-word-string-or-expression-without-metadata:end/disp32 907 $next-word-string-or-expression-without-metadata:check-for-string-literal: 908 # if (line->data[line->read] != '"') goto next check 909 3d/compare-eax-and 0x22/imm32/dquote 910 75/jump-if-!= $next-word-string-or-expression-without-metadata:check-for-expression/disp8 911 $next-word-string-or-expression-without-metadata:string-literal: 912 # skip-string(line) 913 # . . push args 914 56/push-esi 915 # . . call 916 e8/call skip-string/disp32 917 # . . discard args 918 81 0/subop/add %esp 4/imm32 919 # out->end = &line->data[line->read] 920 8b/-> *(esi+4) 1/r32/ecx 921 8d/copy-address *(esi+ecx+0xc) 0/r32/eax 922 89/<- *(edi+4) 0/r32/eax 923 # return 924 e9/jump $next-word-string-or-expression-without-metadata:end/disp32 925 $next-word-string-or-expression-without-metadata:check-for-expression: 926 # if (line->data[line->read] != '*') goto next check 927 3d/compare-eax-and 0x2a/imm32/asterisk 928 75/jump-if-!= $next-word-string-or-expression-without-metadata:check-for-open-paren/disp8 929 # if (line->data[line->read + 1] == ' ') goto error1 930 8a/copy-byte *(esi+ecx+0xd) 0/r32/AL 931 3d/compare-eax-and 0x20/imm32/space 932 0f 84/jump-if-= $next-word-string-or-expression-without-metadata:error1/disp32 933 # if (line->data[line->read + 1] != '(') goto regular-word 934 3d/compare-eax-and 0x28/imm32/open-paren 935 0f 85/jump-if-!= $next-word-string-or-expression-without-metadata:regular-word-without-metadata/disp32 936 $next-word-string-or-expression-without-metadata:paren: 937 # skip-until-close-paren(line) 938 # . . push args 939 56/push-esi 940 # . . call 941 e8/call skip-until-close-paren/disp32 942 # . . discard args 943 81 0/subop/add %esp 4/imm32 944 # if (line->data[line->read] != ')') goto error2 945 # . eax = line->data[line->read] 946 8b/-> *(esi+4) 1/r32/ecx 947 8a/copy-byte *(esi+ecx+0xc) 0/r32/AL 948 # . if (eax != ')') goto error2 949 3d/compare-eax-and 0x29/imm32/close-paren 950 0f 85/jump-if-!= $next-word-string-or-expression-without-metadata:error2/disp32 951 # ++line->read to skip ')' 952 ff 0/subop/increment *(esi+4) 953 # out->end = &line->data[line->read] 954 8b/-> *(esi+4) 1/r32/ecx 955 8d/copy-address *(esi+ecx+0xc) 0/r32/eax 956 89/<- *(edi+4) 0/r32/eax 957 # return 958 e9/jump $next-word-string-or-expression-without-metadata:end/disp32 959 $next-word-string-or-expression-without-metadata:check-for-open-paren: 960 # if (line->data[line->read] == '(') abort 961 3d/compare-eax-and 0x28/imm32/open-paren 962 0f 84/jump-if-= $next-word-string-or-expression-without-metadata:error4a/disp32 963 $next-word-string-or-expression-without-metadata:check-for-end-of-call: 964 # if (line->data[line->read] != ')') goto next check 965 3d/compare-eax-and 0x29/imm32/close-paren 966 75/jump-if-!= $next-word-string-or-expression-without-metadata:regular-word-without-metadata/disp8 967 # ++line->read to skip ')' 968 ff 0/subop/increment *(esi+4) 969 # - error checking: make sure there's nothing else of importance on the line 970 # if (line->read >= line->write) return out = {0, 0} 971 # . ecx = line->read 972 8b/-> *(esi+4) 1/r32/ecx 973 # . if (ecx >= line->write) return {0, 0} 974 3b/compare<- *esi 1/r32/ecx 975 0f 8d/jump-if->= $next-word-string-or-expression-without-metadata:return-eol/disp32 976 # if (line->data[line->read] == '/') goto error3 977 # . eax = line->data[line->read] 978 8a/copy-byte *(esi+ecx+0xc) 0/r32/AL 979 # . if (eax == '/') goto error3 980 3d/compare-eax-and 0x2f/imm32/slash 981 0f 84/jump-if-= $next-word-string-or-expression-without-metadata:error3/disp32 982 # skip-chars-matching-whitespace(line) 983 # . . push args 984 56/push-esi 985 # . . call 986 e8/call skip-chars-matching-whitespace/disp32 987 # . . discard args 988 81 0/subop/add %esp 4/imm32 989 # if (line->read >= line->write) return out = {0, 0} 990 # . ecx = line->read 991 8b/-> *(esi+4) 1/r32/ecx 992 # . if (ecx >= line->write) return {0, 0} 993 3b/compare<- *esi 1/r32/ecx 994 0f 8d/jump-if->= $next-word-string-or-expression-without-metadata:return-eol/disp32 995 # if (line->data[line->read] == '#') return out = {0, 0} 996 # . eax = line->data[line->read] 997 8b/-> *(esi+4) 1/r32/ecx 998 8a/copy-byte *(esi+ecx+0xc) 0/r32/AL 999 # . if (eax == '#') return out = {0, 0} 1000 3d/compare-eax-and 0x23/imm32/pound 1001 74/jump-if-= $next-word-string-or-expression-without-metadata:return-eol/disp8 1002 # otherwise goto error4 1003 e9/jump $next-word-string-or-expression-without-metadata:error4/disp32 1004 $next-word-string-or-expression-without-metadata:regular-word-without-metadata: 1005 # if (line->read >= line->write) break 1006 # . ecx = line->read 1007 8b/-> *(esi+4) 1/r32/ecx 1008 # . if (ecx >= line->write) break 1009 3b/compare<- *esi 1/r32/ecx 1010 7d/jump-if->= $next-word-string-or-expression-without-metadata:regular-word-break/disp8 1011 # if (line->data[line->read] == ' ') break 1012 # . eax = line->data[line->read] 1013 8b/-> *(esi+4) 1/r32/ecx 1014 8a/copy-byte *(esi+ecx+0xc) 0/r32/AL 1015 # . if (eax == ' ') break 1016 3d/compare-eax-and 0x20/imm32/space 1017 74/jump-if-= $next-word-string-or-expression-without-metadata:regular-word-break/disp8 1018 # if (line->data[line->read] == ')') break 1019 3d/compare-eax-and 0x29/imm32/close-paren 1020 0f 84/jump-if-= $next-word-string-or-expression-without-metadata:regular-word-break/disp32 1021 # if (line->data[line->read] == '/') goto error5 1022 3d/compare-eax-and 0x2f/imm32/slash 1023 0f 84/jump-if-= $next-word-string-or-expression-without-metadata:error5/disp32 1024 # ++line->read 1025 ff 0/subop/increment *(esi+4) 1026 # loop 1027 e9/jump $next-word-string-or-expression-without-metadata:regular-word-without-metadata/disp32 1028 $next-word-string-or-expression-without-metadata:regular-word-break: 1029 # out->end = &line->data[line->read] 1030 8b/-> *(esi+4) 1/r32/ecx 1031 8d/copy-address *(esi+ecx+0xc) 0/r32/eax 1032 89/<- *(edi+4) 0/r32/eax 1033 eb/jump $next-word-string-or-expression-without-metadata:end/disp8 1034 $next-word-string-or-expression-without-metadata:return-eol: 1035 # return out = {0, 0} 1036 c7 0/subop/copy *edi 0/imm32 1037 c7 0/subop/copy *(edi+4) 0/imm32 1038 $next-word-string-or-expression-without-metadata:end: 1039 # . restore registers 1040 5f/pop-to-edi 1041 5e/pop-to-esi 1042 59/pop-to-ecx 1043 58/pop-to-eax 1044 # . epilogue 1045 89/<- %esp 5/r32/ebp 1046 5d/pop-to-ebp 1047 c3/return 1048 1049 $next-word-string-or-expression-without-metadata:error0: 1050 # print(stderr, "error: missing final ')' in '" line "'") 1051 # . write-buffered(Stderr, "error: missing final ')' in '") 1052 # . . push args 1053 68/push "error: missing final ')' in '"/imm32 1054 68/push Stderr/imm32 1055 # . . call 1056 e8/call write-buffered/disp32 1057 # . . discard args 1058 81 0/subop/add %esp 8/imm32 1059 # . write-stream-data(Stderr, line) 1060 # . . push args 1061 56/push-esi 1062 68/push Stderr/imm32 1063 # . . call 1064 e8/call write-stream-data/disp32 1065 # . . discard args 1066 81 0/subop/add %esp 8/imm32 1067 # . write-buffered(Stderr, "'") 1068 # . . push args 1069 68/push "'"/imm32 1070 68/push Stderr/imm32 1071 # . . call 1072 e8/call write-buffered/disp32 1073 # . . discard args 1074 81 0/subop/add %esp 8/imm32 1075 # . flush(Stderr) 1076 # . . push args 1077 68/push Stderr/imm32 1078 # . . call 1079 e8/call flush/disp32 1080 # . . discard args 1081 81 0/subop/add %esp 4/imm32 1082 # . syscall(exit, 1) 1083 bb/copy-to-ebx 1/imm32 1084 e8/call syscall_exit/disp32 1085 # never gets here 1086 1087 $next-word-string-or-expression-without-metadata:error1: 1088 # print(stderr, "error: no space allowed after '*' in '" line "'") 1089 # . write-buffered(Stderr, "error: no space allowed after '*' in '") 1090 # . . push args 1091 68/push "error: no space allowed after '*' in '"/imm32 1092 68/push Stderr/imm32 1093 # . . call 1094 e8/call write-buffered/disp32 1095 # . . discard args 1096 81 0/subop/add %esp 8/imm32 1097 # . write-stream-data(Stderr, line) 1098 # . . push args 1099 56/push-esi 1100 68/push Stderr/imm32 1101 # . . call 1102 e8/call write-stream-data/disp32 1103 # . . discard args 1104 81 0/subop/add %esp 8/imm32 1105 # . write-buffered(Stderr, "'") 1106 # . . push args 1107 68/push "'"/imm32 1108 68/push Stderr/imm32 1109 # . . call 1110 e8/call write-buffered/disp32 1111 # . . discard args 1112 81 0/subop/add %esp 8/imm32 1113 # . flush(Stderr) 1114 # . . push args 1115 68/push Stderr/imm32 1116 # . . call 1117 e8/call flush/disp32 1118 # . . discard args 1119 81 0/subop/add %esp 4/imm32 1120 # . syscall(exit, 1) 1121 bb/copy-to-ebx 1/imm32 1122 e8/call syscall_exit/disp32 1123 # never gets here 1124 1125 $next-word-string-or-expression-without-metadata:error2: 1126 # print(stderr, "error: *(...) expression must be all on a single line in '" line "'") 1127 # . write-buffered(Stderr, "error: *(...) expression must be all on a single line in '") 1128 # . . push args 1129 68/push "error: *(...) expression must be all on a single line in '"/imm32 1130 68/push Stderr/imm32 1131 # . . call 1132 e8/call write-buffered/disp32 1133 # . . discard args 1134 81 0/subop/add %esp 8/imm32 1135 # . write-stream-data(Stderr, line) 1136 # . . push args 1137 56/push-esi 1138 68/push Stderr/imm32 1139 # . . call 1140 e8/call write-stream-data/disp32 1141 # . . discard args 1142 81 0/subop/add %esp 8/imm32 1143 # . write-buffered(Stderr, "'") 1144 # . . push args 1145 68/push "'"/imm32 1146 68/push Stderr/imm32 1147 # . . call 1148 e8/call write-buffered/disp32 1149 # . . discard args 1150 81 0/subop/add %esp 8/imm32 1151 # . flush(Stderr) 1152 # . . push args 1153 68/push Stderr/imm32 1154 # . . call 1155 e8/call flush/disp32 1156 # . . discard args 1157 81 0/subop/add %esp 4/imm32 1158 # . syscall(exit, 1) 1159 bb/copy-to-ebx 1/imm32 1160 e8/call syscall_exit/disp32 1161 # never gets here 1162 1163 $next-word-string-or-expression-without-metadata:error3: 1164 # print(stderr, "error: no metadata after calls; just use a comment (in '" line "')") 1165 # . write-buffered(Stderr, "error: no metadata after calls; just use a comment (in '") 1166 # . . push args 1167 68/push "error: no metadata after calls; just use a comment (in '"/imm32 1168 68/push Stderr/imm32 1169 # . . call 1170 e8/call write-buffered/disp32 1171 # . . discard args 1172 81 0/subop/add %esp 8/imm32 1173 # . write-stream-data(Stderr, line) 1174 # . . push args 1175 56/push-esi 1176 68/push Stderr/imm32 1177 # . . call 1178 e8/call write-stream-data/disp32 1179 # . . discard args 1180 81 0/subop/add %esp 8/imm32 1181 # . write-buffered(Stderr, "')") 1182 # . . push args 1183 68/push "')"/imm32 1184 68/push Stderr/imm32 1185 # . . call 1186 e8/call write-buffered/disp32 1187 # . . discard args 1188 81 0/subop/add %esp 8/imm32 1189 # . flush(Stderr) 1190 # . . push args 1191 68/push Stderr/imm32 1192 # . . call 1193 e8/call flush/disp32 1194 # . . discard args 1195 81 0/subop/add %esp 4/imm32 1196 # . syscall(exit, 1) 1197 bb/copy-to-ebx 1/imm32 1198 e8/call syscall_exit/disp32 1199 # never gets here 1200 1201 $next-word-string-or-expression-without-metadata:error4a: 1202 # print(stderr, "error: unexpected '(' within call in '" line "'") 1203 # . write-buffered(Stderr, "error: unexpected '(' within call in '") 1204 # . . push args 1205 68/push "error: unexpected '(' within call in '"/imm32 1206 68/push Stderr/imm32 1207 # . . call 1208 e8/call write-buffered/disp32 1209 # . . discard args 1210 81 0/subop/add %esp 8/imm32 1211 # . write-stream-data(Stderr, line) 1212 # . . push args 1213 56/push-esi 1214 68/push Stderr/imm32 1215 # . . call 1216 e8/call write-stream-data/disp32 1217 # . . discard args 1218 81 0/subop/add %esp 8/imm32 1219 # . write-buffered(Stderr, "'\n") 1220 # . . push args 1221 68/push "'\n"/imm32 1222 68/push Stderr/imm32 1223 # . . call 1224 e8/call write-buffered/disp32 1225 # . . discard args 1226 81 0/subop/add %esp 8/imm32 1227 # . flush(Stderr) 1228 # . . push args 1229 68/push Stderr/imm32 1230 # . . call 1231 e8/call flush/disp32 1232 # . . discard args 1233 81 0/subop/add %esp 4/imm32 1234 # . syscall(exit, 1) 1235 bb/copy-to-ebx 1/imm32 1236 e8/call syscall_exit/disp32 1237 # never gets here 1238 1239 $next-word-string-or-expression-without-metadata:error4: 1240 # print(stderr, "error: unexpected text after end of call in '" line "'") 1241 # . write-buffered(Stderr, "error: unexpected text after end of call in '") 1242 # . . push args 1243 68/push "error: unexpected text after end of call in '"/imm32 1244 68/push Stderr/imm32 1245 # . . call 1246 e8/call write-buffered/disp32 1247 # . . discard args 1248 81 0/subop/add %esp 8/imm32 1249 # . write-stream-data(Stderr, line) 1250 # . . push args 1251 56/push-esi 1252 68/push Stderr/imm32 1253 # . . call 1254 e8/call write-stream-data/disp32 1255 # . . discard args 1256 81 0/subop/add %esp 8/imm32 1257 # . write-buffered(Stderr, "'") 1258 # . . push args 1259 68/push "'"/imm32 1260 68/push Stderr/imm32 1261 # . . call 1262 e8/call write-buffered/disp32 1263 # . . discard args 1264 81 0/subop/add %esp 8/imm32 1265 # . flush(Stderr) 1266 # . . push args 1267 68/push Stderr/imm32 1268 # . . call 1269 e8/call flush/disp32 1270 # . . discard args 1271 81 0/subop/add %esp 4/imm32 1272 # . syscall(exit, 1) 1273 bb/copy-to-ebx 1/imm32 1274 e8/call syscall_exit/disp32 1275 # never gets here 1276 1277 $next-word-string-or-expression-without-metadata:error5: 1278 # print(stderr, "error: no metadata anywhere in calls (in '" line "')") 1279 # . write-buffered(Stderr, "error: no metadata anywhere in calls (in '") 1280 # . . push args 1281 68/push "error: no metadata anywhere in calls (in '"/imm32 1282 68/push Stderr/imm32 1283 # . . call 1284 e8/call write-buffered/disp32 1285 # . . discard args 1286 81 0/subop/add %esp 8/imm32 1287 # . write-stream-data(Stderr, line) 1288 # . . push args 1289 56/push-esi 1290 68/push Stderr/imm32 1291 # . . call 1292 e8/call write-stream-data/disp32 1293 # . . discard args 1294 81 0/subop/add %esp 8/imm32 1295 # . write-buffered(Stderr, "')") 1296 # . . push args 1297 68/push "')"/imm32 1298 68/push Stderr/imm32 1299 # . . call 1300 e8/call write-buffered/disp32 1301 # . . discard args 1302 81 0/subop/add %esp 8/imm32 1303 # . flush(Stderr) 1304 # . . push args 1305 68/push Stderr/imm32 1306 # . . call 1307 e8/call flush/disp32 1308 # . . discard args 1309 81 0/subop/add %esp 4/imm32 1310 # . syscall(exit, 1) 1311 bb/copy-to-ebx 1/imm32 1312 e8/call syscall_exit/disp32 1313 # never gets here 1314 1315 test-next-word-string-or-expression-without-metadata: 1316 # . prologue 1317 55/push-ebp 1318 89/<- %ebp 4/r32/esp 1319 # setup 1320 # . clear-stream(_test-input-stream) 1321 # . . push args 1322 68/push _test-input-stream/imm32 1323 # . . call 1324 e8/call clear-stream/disp32 1325 # . . discard args 1326 81 0/subop/add %esp 4/imm32 1327 # var slice/ecx: slice 1328 68/push 0/imm32/end 1329 68/push 0/imm32/start 1330 89/<- %ecx 4/r32/esp 1331 # write(_test-input-stream, " ab") 1332 # . . push args 1333 68/push " ab"/imm32 1334 68/push _test-input-stream/imm32 1335 # . . call 1336 e8/call write/disp32 1337 # . . discard args 1338 81 0/subop/add %esp 8/imm32 1339 # next-word-string-or-expression-without-metadata(_test-input-stream, slice) 1340 # . . push args 1341 51/push-ecx 1342 68/push _test-input-stream/imm32 1343 # . . call 1344 e8/call next-word-string-or-expression-without-metadata/disp32 1345 # . . discard args 1346 81 0/subop/add %esp 8/imm32 1347 # check-ints-equal(_test-input-stream->read, 4, msg) 1348 # . . push args 1349 68/push "F - test-next-word-string-or-expression-without-metadata/updates-stream-read-correctly"/imm32 1350 68/push 4/imm32 1351 b8/copy-to-eax _test-input-stream/imm32 1352 ff 6/subop/push *(eax+4) 1353 # . . call 1354 e8/call check-ints-equal/disp32 1355 # . . discard args 1356 81 0/subop/add %esp 0xc/imm32 1357 # check-ints-equal(slice->start - _test-input-stream->data, 2, msg) 1358 # . check-ints-equal(slice->start - _test-input-stream, 14, msg) 1359 # . . push args 1360 68/push "F - test-next-word-string-or-expression-without-metadata: start"/imm32 1361 68/push 0xe/imm32 1362 # . . push slice->start - _test-input-stream 1363 8b/-> *ecx 0/r32/eax 1364 2d/subtract-from-eax _test-input-stream/imm32 1365 50/push-eax 1366 # . . call 1367 e8/call check-ints-equal/disp32 1368 # . . discard args 1369 81 0/subop/add %esp 0xc/imm32 1370 # check-ints-equal(slice->end - _test-input-stream->data, 4, msg) 1371 # . check-ints-equal(slice->end - _test-input-stream, 16, msg) 1372 # . . push args 1373 68/push "F - test-next-word-string-or-expression-without-metadata: end"/imm32 1374 68/push 0x10/imm32 1375 # . . push slice->end - _test-input-stream 1376 8b/-> *(ecx+4) 0/r32/eax 1377 2d/subtract-from-eax _test-input-stream/imm32 1378 50/push-eax 1379 # . . call 1380 e8/call check-ints-equal/disp32 1381 # . . discard args 1382 81 0/subop/add %esp 0xc/imm32 1383 # . epilogue 1384 89/<- %esp 5/r32/ebp 1385 5d/pop-to-ebp 1386 c3/return 1387 1388 test-next-word-string-or-expression-without-metadata-returns-whole-comment: 1389 # . prologue 1390 55/push-ebp 1391 89/<- %ebp 4/r32/esp 1392 # setup 1393 # . clear-stream(_test-input-stream) 1394 # . . push args 1395 68/push _test-input-stream/imm32 1396 # . . call 1397 e8/call clear-stream/disp32 1398 # . . discard args 1399 81 0/subop/add %esp 4/imm32 1400 # var slice/ecx: slice 1401 68/push 0/imm32/end 1402 68/push 0/imm32/start 1403 89/<- %ecx 4/r32/esp 1404 # write(_test-input-stream, " # a") 1405 # . . push args 1406 68/push " # a"/imm32 1407 68/push _test-input-stream/imm32 1408 # . . call 1409 e8/call write/disp32 1410 # . . discard args 1411 81 0/subop/add %esp 8/imm32 1412 # next-word-string-or-expression-without-metadata(_test-input-stream, slice) 1413 # . . push args 1414 51/push-ecx 1415 68/push _test-input-stream/imm32 1416 # . . call 1417 e8/call next-word-string-or-expression-without-metadata/disp32 1418 # . . discard args 1419 81 0/subop/add %esp 8/imm32 1420 # check-ints-equal(_test-input-stream->read, 5, msg) 1421 # . . push args 1422 68/push "F - test-next-word-string-or-expression-without-metadata-returns-whole-comment/updates-stream-read-correctly"/imm32 1423 68/push 5/imm32 1424 b8/copy-to-eax _test-input-stream/imm32 1425 ff 6/subop/push *(eax+4) 1426 # . . call 1427 e8/call check-ints-equal/disp32 1428 # . . discard args 1429 81 0/subop/add %esp 0xc/imm32 1430 # check-ints-equal(slice->start - _test-input-stream->data, 2, msg) 1431 # . check-ints-equal(slice->start - _test-input-stream, 14, msg) 1432 # . . push args 1433 68/push "F - test-next-word-string-or-expression-without-metadata-returns-whole-comment: start"/imm32 1434 68/push 0xe/imm32 1435 # . . push slice->start - _test-input-stream 1436 8b/-> *ecx 0/r32/eax 1437 2d/subtract-from-eax _test-input-stream/imm32 1438 50/push-eax 1439 # . . call 1440 e8/call check-ints-equal/disp32 1441 # . . discard args 1442 81 0/subop/add %esp 0xc/imm32 1443 # check-ints-equal(slice->end - _test-input-stream->data, 5, msg) 1444 # . check-ints-equal(slice->end - _test-input-stream, 17, msg) 1445 # . . push args 1446 68/push "F - test-next-word-string-or-expression-without-metadata-returns-whole-comment: end"/imm32 1447 68/push 0x11/imm32 1448 # . . push slice->end - _test-input-stream 1449 8b/-> *(ecx+4) 0/r32/eax 1450 2d/subtract-from-eax _test-input-stream/imm32 1451 50/push-eax 1452 # . . call 1453 e8/call check-ints-equal/disp32 1454 # . . discard args 1455 81 0/subop/add %esp 0xc/imm32 1456 # . epilogue 1457 89/<- %esp 5/r32/ebp 1458 5d/pop-to-ebp 1459 c3/return 1460 1461 test-next-word-string-or-expression-without-metadata-returns-string-literal: 1462 # . prologue 1463 55/push-ebp 1464 89/<- %ebp 4/r32/esp 1465 # setup 1466 # . clear-stream(_test-input-stream) 1467 # . . push args 1468 68/push _test-input-stream/imm32 1469 # . . call 1470 e8/call clear-stream/disp32 1471 # . . discard args 1472 81 0/subop/add %esp 4/imm32 1473 # var slice/ecx: slice 1474 68/push 0/imm32/end 1475 68/push 0/imm32/start 1476 89/<- %ecx 4/r32/esp 1477 # write(_test-input-stream, " \"a b\" ") 1478 # . . push args 1479 68/push " \"a b\" "/imm32 1480 68/push _test-input-stream/imm32 1481 # . . call 1482 e8/call write/disp32 1483 # . . discard args 1484 81 0/subop/add %esp 8/imm32 1485 # next-word-string-or-expression-without-metadata(_test-input-stream, slice) 1486 # . . push args 1487 51/push-ecx 1488 68/push _test-input-stream/imm32 1489 # . . call 1490 e8/call next-word-string-or-expression-without-metadata/disp32 1491 # . . discard args 1492 81 0/subop/add %esp 8/imm32 1493 # check-ints-equal(slice->start - _test-input-stream->data, 1, msg) 1494 # . check-ints-equal(slice->start - _test-input-stream, 13, msg) 1495 # . . push args 1496 68/push "F - test-next-word-string-or-expression-without-metadata-returns-string-literal: start"/imm32 1497 68/push 0xd/imm32 1498 # . . push slice->start - _test-input-stream 1499 8b/-> *ecx 0/r32/eax 1500 2d/subtract-from-eax _test-input-stream/imm32 1501 50/push-eax 1502 # . . call 1503 e8/call check-ints-equal/disp32 1504 # . . discard args 1505 81 0/subop/add %esp 0xc/imm32 1506 # check-ints-equal(slice->end - _test-input-stream->data, 6, msg) 1507 # . check-ints-equal(slice->end - _test-input-stream, 18, msg) 1508 # . . push args 1509 68/push "F - test-next-word-string-or-expression-without-metadata-returns-string-literal: end"/imm32 1510 68/push 0x12/imm32 1511 # . . push slice->end - _test-input-stream 1512 8b/-> *(ecx+4) 0/r32/eax 1513 2d/subtract-from-eax _test-input-stream/imm32 1514 50/push-eax 1515 # . . call 1516 e8/call check-ints-equal/disp32 1517 # . . discard args 1518 81 0/subop/add %esp 0xc/imm32 1519 # . epilogue 1520 89/<- %esp 5/r32/ebp 1521 5d/pop-to-ebp 1522 c3/return 1523 1524 test-next-word-string-or-expression-without-metadata-returns-string-with-escapes: 1525 # . prologue 1526 55/push-ebp 1527 89/<- %ebp 4/r32/esp 1528 # setup 1529 # . clear-stream(_test-input-stream) 1530 # . . push args 1531 68/push _test-input-stream/imm32 1532 # . . call 1533 e8/call clear-stream/disp32 1534 # . . discard args 1535 81 0/subop/add %esp 4/imm32 1536 # var slice/ecx: slice 1537 68/push 0/imm32/end 1538 68/push 0/imm32/start 1539 89/<- %ecx 4/r32/esp 1540 # write(_test-input-stream, " \"a\\\"b\"") 1541 # . . push args 1542 68/push " \"a\\\"b\""/imm32 1543 68/push _test-input-stream/imm32 1544 # . . call 1545 e8/call write/disp32 1546 # . . discard args 1547 81 0/subop/add %esp 8/imm32 1548 # next-word-string-or-expression-without-metadata(_test-input-stream, slice) 1549 # . . push args 1550 51/push-ecx 1551 68/push _test-input-stream/imm32 1552 # . . call 1553 e8/call next-word-string-or-expression-without-metadata/disp32 1554 # . . discard args 1555 81 0/subop/add %esp 8/imm32 1556 # check-ints-equal(slice->start - _test-input-stream->data, 1, msg) 1557 # . check-ints-equal(slice->start - _test-input-stream, 13, msg) 1558 # . . push args 1559 68/push "F - test-next-word-string-or-expression-without-metadata-returns-string-with-escapes: start"/imm32 1560 68/push 0xd/imm32 1561 # . . push slice->start - _test-input-stream 1562 8b/-> *ecx 0/r32/eax 1563 2d/subtract-from-eax _test-input-stream/imm32 1564 50/push-eax 1565 # . . call 1566 e8/call check-ints-equal/disp32 1567 # . . discard args 1568 81 0/subop/add %esp 0xc/imm32 1569 # check-ints-equal(slice->end - _test-input-stream->data, 7, msg) 1570 # . check-ints-equal(slice->end - _test-input-stream, 19, msg) 1571 # . . push args 1572 68/push "F - test-next-word-string-or-expression-without-metadata-returns-string-with-escapes: end"/imm32 1573 68/push 0x13/imm32 1574 # . . push slice->end - _test-input-stream 1575 8b/-> *(ecx+4) 0/r32/eax 1576 2d/subtract-from-eax _test-input-stream/imm32 1577 50/push-eax 1578 # . . call 1579 e8/call check-ints-equal/disp32 1580 # . . discard args 1581 81 0/subop/add %esp 0xc/imm32 1582 # . epilogue 1583 89/<- %esp 5/r32/ebp 1584 5d/pop-to-ebp 1585 c3/return 1586 1587 test-next-word-string-or-expression-without-metadata-returns-whole-expression: 1588 # . prologue 1589 55/push-ebp 1590 89/<- %ebp 4/r32/esp 1591 # setup 1592 # . clear-stream(_test-input-stream) 1593 # . . push args 1594 68/push _test-input-stream/imm32 1595 # . . call 1596 e8/call clear-stream/disp32 1597 # . . discard args 1598 81 0/subop/add %esp 4/imm32 1599 # var slice/ecx: slice 1600 68/push 0/imm32/end 1601 68/push 0/imm32/start 1602 89/<- %ecx 4/r32/esp 1603 # write(_test-input-stream, " *(a b) ") 1604 # . . push args 1605 68/push " *(a b) "/imm32 1606 68/push _test-input-stream/imm32 1607 # . . call 1608 e8/call write/disp32 1609 # . . discard args 1610 81 0/subop/add %esp 8/imm32 1611 # next-word-string-or-expression-without-metadata(_test-input-stream, slice) 1612 # . . push args 1613 51/push-ecx 1614 68/push _test-input-stream/imm32 1615 # . . call 1616 e8/call next-word-string-or-expression-without-metadata/disp32 1617 # . . discard args 1618 81 0/subop/add %esp 8/imm32 1619 # check-ints-equal(slice->start - _test-input-stream->data, 1, msg) 1620 # . check-ints-equal(slice->start - _test-input-stream, 13, msg) 1621 # . . push args 1622 68/push "F - test-next-word-string-or-expression-without-metadata-returns-whole-expression: start"/imm32 1623 68/push 0xd/imm32 1624 # . . push slice->start - _test-input-stream 1625 8b/-> *ecx 0/r32/eax 1626 2d/subtract-from-eax _test-input-stream/imm32 1627 50/push-eax 1628 # . . call 1629 e8/call check-ints-equal/disp32 1630 # . . discard args 1631 81 0/subop/add %esp 0xc/imm32 1632 # check-ints-equal(slice->end - _test-input-stream->data, 7, msg) 1633 # . check-ints-equal(slice->end - _test-input-stream, 19, msg) 1634 # . . push args 1635 68/push "F - test-next-word-string-or-expression-without-metadata-returns-whole-expression: end"/imm32 1636 68/push 0x13/imm32 1637 # . . push slice->end - _test-input-stream 1638 8b/-> *(ecx+4) 0/r32/eax 1639 2d/subtract-from-eax _test-input-stream/imm32 1640 50/push-eax 1641 # . . call 1642 e8/call check-ints-equal/disp32 1643 # . . discard args 1644 81 0/subop/add %esp 0xc/imm32 1645 # . epilogue 1646 89/<- %esp 5/r32/ebp 1647 5d/pop-to-ebp 1648 c3/return 1649 1650 test-next-word-string-or-expression-without-metadata-returns-eol-on-trailing-close-paren: 1651 # . prologue 1652 55/push-ebp 1653 89/<- %ebp 4/r32/esp 1654 # setup 1655 # . clear-stream(_test-input-stream) 1656 # . . push args 1657 68/push _test-input-stream/imm32 1658 # . . call 1659 e8/call clear-stream/disp32 1660 # . . discard args 1661 81 0/subop/add %esp 4/imm32 1662 # var slice/ecx: slice 1663 68/push 0/imm32/end 1664 68/push 0/imm32/start 1665 89/<- %ecx 4/r32/esp 1666 # write(_test-input-stream, " ) ") 1667 # . . push args 1668 68/push " ) "/imm32 1669 68/push _test-input-stream/imm32 1670 # . . call 1671 e8/call write/disp32 1672 # . . discard args 1673 81 0/subop/add %esp 8/imm32 1674 # next-word-string-or-expression-without-metadata(_test-input-stream, slice) 1675 # . . push args 1676 51/push-ecx 1677 68/push _test-input-stream/imm32 1678 # . . call 1679 e8/call next-word-string-or-expression-without-metadata/disp32 1680 # . . discard args 1681 81 0/subop/add %esp 8/imm32 1682 # check-ints-equal(slice->start, 0, msg) 1683 # . . push args 1684 68/push "F - test-next-word-string-or-expression-without-metadata-returns-eol-on-trailing-close-paren: start"/imm32 1685 68/push 0/imm32 1686 ff 6/subop/push *ecx 1687 # . . call 1688 e8/call check-ints-equal/disp32 1689 # . . discard args 1690 81 0/subop/add %esp 0xc/imm32 1691 # check-ints-equal(slice->end, 0, msg) 1692 # . . push args 1693 68/push "F - test-next-word-string-or-expression-without-metadata-returns-eol-on-trailing-close-paren: end"/imm32 1694 68/push 0/imm32 1695 ff 6/subop/push *(ecx+4) 1696 # . . call 1697 e8/call check-ints-equal/disp32 1698 # . . discard args 1699 81 0/subop/add %esp 0xc/imm32 1700 # . epilogue 1701 89/<- %esp 5/r32/ebp 1702 5d/pop-to-ebp 1703 c3/return 1704 1705 test-next-word-string-or-expression-without-metadata-handles-comment-after-trailing-close-paren: 1706 # . prologue 1707 55/push-ebp 1708 89/<- %ebp 4/r32/esp 1709 # setup 1710 # . clear-stream(_test-input-stream) 1711 # . . push args 1712 68/push _test-input-stream/imm32 1713 # . . call 1714 e8/call clear-stream/disp32 1715 # . . discard args 1716 81 0/subop/add %esp 4/imm32 1717 # var slice/ecx: slice 1718 68/push 0/imm32/end 1719 68/push 0/imm32/start 1720 89/<- %ecx 4/r32/esp 1721 # write(_test-input-stream, " ) # abc ") 1722 # . . push args 1723 68/push " ) # abc "/imm32 1724 68/push _test-input-stream/imm32 1725 # . . call 1726 e8/call write/disp32 1727 # . . discard args 1728 81 0/subop/add %esp 8/imm32 1729 # next-word-string-or-expression-without-metadata(_test-input-stream, slice) 1730 # . . push args 1731 51/push-ecx 1732 68/push _test-input-stream/imm32 1733 # . . call 1734 e8/call next-word-string-or-expression-without-metadata/disp32 1735 # . . discard args 1736 81 0/subop/add %esp 8/imm32 1737 # check-ints-equal(slice->start, 0, msg) 1738 # . . push args 1739 68/push "F - test-next-word-string-or-expression-without-metadata-handles-comment-after-trailing-close-paren: start"/imm32 1740 68/push 0/imm32 1741 ff 6/subop/push *ecx 1742 # . . call 1743 e8/call check-ints-equal/disp32 1744 # . . discard args 1745 81 0/subop/add %esp 0xc/imm32 1746 # check-ints-equal(slice->end, 0, msg) 1747 # . . push args 1748 68/push "F - test-next-word-string-or-expression-without-metadata-handles-comment-after-trailing-close-paren: end"/imm32 1749 68/push 0/imm32 1750 ff 6/subop/push *(ecx+4) 1751 # . . call 1752 e8/call check-ints-equal/disp32 1753 # . . discard args 1754 81 0/subop/add %esp 0xc/imm32 1755 # . epilogue 1756 89/<- %esp 5/r32/ebp 1757 5d/pop-to-ebp 1758 c3/return 1759 1760 test-next-word-string-or-expression-without-metadata-handles-newline-after-trailing-close-paren: 1761 # . prologue 1762 55/push-ebp 1763 89/<- %ebp 4/r32/esp 1764 # setup 1765 # . clear-stream(_test-input-stream) 1766 # . . push args 1767 68/push _test-input-stream/imm32 1768 # . . call 1769 e8/call clear-stream/disp32 1770 # . . discard args 1771 81 0/subop/add %esp 4/imm32 1772 # var slice/ecx: slice 1773 68/push 0/imm32/end 1774 68/push 0/imm32/start 1775 89/<- %ecx 4/r32/esp 1776 # write(_test-input-stream, " )\n") 1777 # . . push args 1778 68/push " )\n"/imm32 1779 68/push _test-input-stream/imm32 1780 # . . call 1781 e8/call write/disp32 1782 # . . discard args 1783 81 0/subop/add %esp 8/imm32 1784 # next-word-string-or-expression-without-metadata(_test-input-stream, slice) 1785 # . . push args 1786 51/push-ecx 1787 68/push _test-input-stream/imm32 1788 # . . call 1789 e8/call next-word-string-or-expression-without-metadata/disp32 1790 # . . discard args 1791 81 0/subop/add %esp 8/imm32 1792 # check-ints-equal(slice->start, 0, msg) 1793 # . . push args 1794 68/push "F - test-next-word-string-or-expression-without-metadata-handles-newline-after-trailing-close-paren: start"/imm32 1795 68/push 0/imm32 1796 ff 6/subop/push *ecx 1797 # . . call 1798 e8/call check-ints-equal/disp32 1799 # . . discard args 1800 81 0/subop/add %esp 0xc/imm32 1801 # check-ints-equal(slice->end, 0, msg) 1802 # . . push args 1803 68/push "F - test-next-word-string-or-expression-without-metadata-handles-newline-after-trailing-close-paren: end"/imm32 1804 68/push 0/imm32 1805 ff 6/subop/push *(ecx+4) 1806 # . . call 1807 e8/call check-ints-equal/disp32 1808 # . . discard args 1809 81 0/subop/add %esp 0xc/imm32 1810 # . epilogue 1811 89/<- %esp 5/r32/ebp 1812 5d/pop-to-ebp 1813 c3/return 1814 1815 test-next-word-string-or-expression-without-metadata-stops-at-close-paren: 1816 # . prologue 1817 55/push-ebp 1818 89/<- %ebp 4/r32/esp 1819 # setup 1820 # . clear-stream(_test-input-stream) 1821 # . . push args 1822 68/push _test-input-stream/imm32 1823 # . . call 1824 e8/call clear-stream/disp32 1825 # . . discard args 1826 81 0/subop/add %esp 4/imm32 1827 # var slice/ecx: slice 1828 68/push 0/imm32/end 1829 68/push 0/imm32/start 1830 89/<- %ecx 4/r32/esp 1831 # write(_test-input-stream, " abc) # def") 1832 # . . push args 1833 68/push " abc) # def"/imm32 1834 68/push _test-input-stream/imm32 1835 # . . call 1836 e8/call write/disp32 1837 # . . discard args 1838 81 0/subop/add %esp 8/imm32 1839 # next-word-string-or-expression-without-metadata(_test-input-stream, slice) 1840 # . . push args 1841 51/push-ecx 1842 68/push _test-input-stream/imm32 1843 # . . call 1844 e8/call next-word-string-or-expression-without-metadata/disp32 1845 # . . discard args 1846 81 0/subop/add %esp 8/imm32 1847 # check-ints-equal(slice->start - _test-input-stream->data, 1, msg) 1848 # . check-ints-equal(slice->start - _test-input-stream, 13, msg) 1849 # . . push args 1850 68/push "F - test-next-word-string-or-expression-without-metadata-stops-at-close-paren: start"/imm32 1851 68/push 0xd/imm32 1852 # . . push slice->start - _test-input-stream 1853 8b/-> *ecx 0/r32/eax 1854 2d/subtract-from-eax _test-input-stream/imm32 1855 50/push-eax 1856 # . . call 1857 e8/call check-ints-equal/disp32 1858 # . . discard args 1859 81 0/subop/add %esp 0xc/imm32 1860 # check-ints-equal(slice->end - _test-input-stream->data, 4, msg) 1861 # . check-ints-equal(slice->end - _test-input-stream, 16, msg) 1862 # . . push args 1863 68/push "F - test-next-word-string-or-expression-without-metadata-stops-at-close-paren: end"/imm32 1864 68/push 0x10/imm32 1865 # . . push slice->end - _test-input-stream 1866 8b/-> *(ecx+4) 0/r32/eax 1867 2d/subtract-from-eax _test-input-stream/imm32 1868 50/push-eax 1869 # . . call 1870 e8/call check-ints-equal/disp32 1871 # . . discard args 1872 81 0/subop/add %esp 0xc/imm32 1873 # . epilogue 1874 89/<- %esp 5/r32/ebp 1875 5d/pop-to-ebp 1876 c3/return