https://github.com/akkartik/mu/blob/main/310copy-bytes.subx
  1 # Some helpers for copying non-overlapping regions of memory.
  2 # Really only intended to be called from code generated by mu.subx.
  3 
  4 == code
  5 
  6 copy-bytes:  # src: (addr byte), dest: (addr byte), size: int
  7     # pseudocode:
  8     #   curr-src/esi = src
  9     #   curr-dest/edi = dest
 10     #   i/ecx = 0
 11     #   while true
 12     #     if (i >= size) break
 13     #     *curr-dest = *curr-src
 14     #     ++curr-src
 15     #     ++curr-dest
 16     #     ++i
 17     #
 18     # . prologue
 19     55/push-ebp
 20     89/<- %ebp 4/r32/esp
 21     # . save registers
 22     50/push-eax
 23     51/push-ecx
 24     52/push-edx
 25     56/push-esi
 26     57/push-edi
 27     # curr-src/esi = src
 28     8b/-> *(ebp+8) 6/r32/esi
 29     # curr-dest/edi = dest
 30     8b/-> *(ebp+0xc) 7/r32/edi
 31     # var i/ecx: int = 0
 32     b9/copy-to-ecx 0/imm32
 33     # edx = size
 34     8b/-> *(ebp+0x10) 2/r32/edx
 35     {
 36       # if (i >= size) break
 37       39/compare %ecx 2/r32/edx
 38       7d/jump-if->=  break/disp8
 39       # *curr-dest = *curr-src
 40       8a/byte-> *esi 0/r32/AL
 41       88/byte<- *edi 0/r32/AL
 42       # update
 43       46/increment-esi
 44       47/increment-edi
 45       41/increment-ecx
 46       eb/jump loop/disp8
 47     }
 48 $copy-bytes:end:
 49     # . restore registers
 50     5f/pop-to-edi
 51     5e/pop-to-esi
 52     5a/pop-to-edx
 53 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 */
# Compatible with ranger 1.6.0 through 1.7.*
#
# Replace your rifle.conf with this file to use xdg-open as your file opener.
# This is, of course, adaptable for use with any other file opener.
else = xdg-open "$1"

# You need an "editor" and "pager" in order to use certain functions in ranger:
label editor = $EDITOR -- "$@"
label pager  = $PAGER -- "$@"
>/read-pointer-not-perturbed") 117 # . epilogue 118 89/<- %esp 5/r32/ebp 119 5d/pop-to-ebp 120 c3/return 121 122 # like stream-to-array but ignore surrounding quotes 123 # we might do other stuff here later 124 unquote-stream-to-array: # in: (addr stream _), out: (addr handle array _) 125 # . prologue 126 55/push-ebp 127 89/<- %ebp 4/r32/esp 128 # . save registers 129 50/push-eax 130 51/push-ecx 131 52/push-edx 132 56/push-esi 133 # esi = s 134 8b/-> *(ebp+8) 6/r32/esi 135 # var len/ecx: int = s->write - s->read - 2 136 8b/-> *esi 1/r32/ecx 137 2b/subtract *(esi+4) 1/r32/ecx 138 81 7/subop/compare %ecx 2/imm32 139 7c/jump-if-< $unquote-stream-to-array:end/disp8 140 81 5/subop/subtract %ecx 2/imm32 141 # allocate 142 (allocate-array Heap %ecx *(ebp+0xc)) 143 # var in/edx: (addr byte) = s->data + s->read + 1 144 8b/-> *(esi+4) 2/r32/edx 145 8d/copy-address *(esi+edx+0xd) 2/r32/edx # Stream-data + 1 146 # var dest/eax: (addr byte) = data for out 147 8b/-> *(ebp+0xc) 0/r32/eax 148 (lookup *eax *(eax+4)) # => eax 149 8d/copy-address *(eax+4) 0/r32/eax 150 # 151 (copy-bytes %edx %eax %ecx) 152 $unquote-stream-to-array:end: 153 # . restore registers 154 5e/pop-to-esi 155 5a/pop-to-edx 156 59/pop-to-ecx 157 58/pop-to-eax 158 # . epilogue 159 89/<- %esp 5/r32/ebp 160 5d/pop-to-ebp 161 c3/return