about summary refs log tree commit diff stats
path: root/init.linux
blob: 6e482b9658fbba93be24050e60bdd84838eb2f46 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Some OS-specific preliminaries for Linux.

# Memory layout
#
#          0 - 0x08047ffff - reserved for the kernel
# 0x08048000 - 0xbffffffff - available for user programs
# 0xc0000000 - 0xfffffffff - reserved for the kernel
== code 0x09000000
== data 0x0a000000

# Syscalls
#
# We don't have libc, so we need to know Linux's precise syscall layout.
# These are not real functions. Pass arguments in specific registers.
== code

# http://man7.org/linux/man-pages/man2/exit.2.html
syscall_exit:  # status/ebx: int
    b8/copy-to-eax 1/imm32
    cd/syscall 0x80/imm8

# http://man7.org/linux/man-pages/man2/read.2.html
syscall_read:  # fd/ebx: int, buf/ecx: addr, size/edx: int -> nbytes-or-error/eax: int
    b8/copy-to-eax 3/imm32
    cd/syscall 0x80/imm8
    c3/return

# http://man7.org/linux/man-pages/man2/write.2.html
syscall_write:  # fd/ebx: int, buf/ecx: addr, size/edx: int -> nbytes-or-error/eax: int
    b8/copy-to-eax 4/imm32
    cd/syscall 0x80/imm8
    c3/return

# http://man7.org/linux/man-pages/man2/open.2.html
syscall_open:  # filename/ebx: (addr kernel-string), flags/ecx: int, dummy=0x180/edx -> fd-or-error/eax: int
    b8/copy-to-eax 5/imm32
    cd/syscall 0x80/imm8
    c3/return

# http://man7.org/linux/man-pages/man2/close.2.html
syscall_close:  # fd/ebx: int -> status/eax
    b8/copy-to-eax 6/imm32
    cd/syscall 0x80/imm8
    c3/return

# http://man7.org/linux/man-pages/man2/creat.2.html
syscall_creat:  # filename/ebx: (addr kernel-string) -> fd-or-error/eax: int
    b8/copy-to-eax 8/imm32
    cd/syscall 0x80/imm8
    c3/return

# http://man7.org/linux/man-pages/man2/unlink.2.html
syscall_unlink:  # filename/ebx: (addr kernel-string) -> status/eax: int
    b8/copy-to-eax 0xa/imm32
    cd/syscall 0x80/imm8
    c3/return

# http://man7.org/linux/man-pages/man2/rename.2.html
syscall_rename:  # source/ebx: (addr kernel-string), dest/ecx: (addr kernel-string) -> status/eax: int
    b8/copy-to-eax 0x26/imm32
    cd/syscall 0x80/imm8
    c3/return

# https://github.com/torvalds/linux/blob/fa121bb3fed6313b1f0af23952301e06cf6d32ed/mm/nommu.c#L1352
syscall_mmap:  # arg/ebx: (addr mmap_arg_struct) -> status/eax: int
    # the important thing: ebx+4 contains the 32-bit size to be allocated
    b8/copy-to-eax 0x5a/imm32
    cd/syscall 0x80/imm8
    c3/return

syscall_ioctl:  # fd/ebx: int, cmd/ecx: int, arg/edx: (addr _)
    b8/copy-to-eax 0x36/imm32
    cd/syscall 0x80/imm8
    c3/return

syscall_nanosleep:  # req/ebx: (addr timespec)
    b8/copy-to-eax 0xa2/imm32  # 162
    cd/syscall 0x80/imm8
    c3/return

syscall_clock_gettime:  # clock/ebx: int, out/ecx: (addr timespec)
    b8/copy-to-eax 0x109/imm32  # 265
    cd/syscall 0x80/imm8
    c3/return
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.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - 024jump.cc</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 12pt; font-size: 1em; }
.Constant { color: #00a0a0; }
.traceAbsent { color: #c00000; }
.cSpecial { color: #008000; }
.muRecipe { color: #ff8700; }
.Comment { color: #9090ff; }
.Delimiter { color: #800080; }
.Special { color: #c00000; }
.traceContains { color: #008000; }
.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; }
.Identifier { color: #c0a020; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">//: Jump primitives</span>

<span class="Delimiter">:(scenario jump_can_skip_instructions)</span>
<span class="muRecipe">def</span> main [
  jump <span class="Constant">1:offset</span>
  <span class="Constant">1</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
]
<span class="traceContains">+run: jump {1: &quot;offset&quot;}</span>
<span class="traceAbsent">-run: {1: &quot;number&quot;} &lt;- copy {1: &quot;literal&quot;}</span>
<span class="traceAbsent">-mem: storing 1 in location 1</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
JUMP<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;jump&quot;</span><span class="Delimiter">,</span> JUMP<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> JUMP: <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump' requires exactly one ingredient, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;first ingredient of 'jump' should be a label or offset, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> JUMP: <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>initialized<span class="Delimiter">);</span>
  current_step_index<span class="Delimiter">()</span> += ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>+<span class="Constant">1</span><span class="Delimiter">;</span>
  trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;jumping to instruction &quot;</span> &lt;&lt; current_step_index<span class="Delimiter">()</span> &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Identifier">continue</span><span class="Delimiter">;</span>  <span class="Comment">// skip rest of this instruction</span>
<span class="Delimiter">}</span>

<span class="Comment">//: special type to designate jump targets</span>
<span class="Delimiter">:(before &quot;End Mu Types Initialization&quot;)</span>
put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;offset&quot;</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span>

<span class="Delimiter">:(scenario jump_backward)</span>
<span class="muRecipe">def</span> main [
  jump <span class="Constant">1:offset</span>  <span class="Comment"># 0 -+</span>
  jump <span class="Constant">3:offset</span>  <span class="Comment">#    |   +-+ 1</span>
                 <span class="Comment">#   \/  /\ |</span>
  jump <span class="Constant">-2:offset</span> <span class="Comment">#  2 +--&gt;+ |</span>
]                <span class="Comment">#         \/ 3</span>
<span class="traceContains">+run: jump {1: &quot;offset&quot;}</span>
<span class="traceContains">+run: jump {-2: &quot;offset&quot;}</span>
<span class="traceContains">+run: jump {3: &quot;offset&quot;}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
JUMP_IF<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;jump-if&quot;</span><span class="Delimiter">,</span> JUMP_IF<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> JUMP_IF: <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-if' requires exactly two ingredients, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-if' requires a boolean for its first ingredient, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-if' requires a label or offset for its second ingredient, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Comment">// End JUMP_IF Checks</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> JUMP_IF: <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>initialized<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>
    trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;jump-if fell through&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  current_step_index<span class="Delimiter">()</span> += ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>+<span class="Constant">1</span><span class="Delimiter">;</span>
  trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;jumping to instruction &quot;</span> &lt;&lt; current_step_index<span class="Delimiter">()</span> &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Identifier">continue</span><span class="Delimiter">;</span>  <span class="Comment">// skip rest of this instruction</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(scenario jump_if)</span>
<span class="muRecipe">def</span> main [
  jump-<span class="Normal">if</span> <span class="Constant">999</span><span class="Delimiter">,</span> <span class="Constant">1:offset</span>
  <span class="Constant">123</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
]
<span class="traceContains">+run: jump-if {999: &quot;literal&quot;}, {1: &quot;offset&quot;}</span>
<span class="traceContains">+run: jumping to instruction 2</span>
<span class="traceAbsent">-run: {1: &quot;number&quot;} &lt;- copy {1: &quot;literal&quot;}</span>
<span class="traceAbsent">-mem: storing 1 in location 123</span>

<span class="Delimiter">:(scenario jump_if_fallthrough)</span>
<span class="muRecipe">def</span> main [
  jump-<span class="Normal">if</span> <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1:offset</span>
  <span class="Constant">123</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
]
<span class="traceContains">+run: jump-if {0: &quot;literal&quot;}, {1: &quot;offset&quot;}</span>
<span class="traceContains">+run: jump-if fell through</span>
<span class="traceContains">+run: {123: &quot;number&quot;} &lt;- copy {1: &quot;literal&quot;}</span>
<span class="traceContains">+mem: storing 1 in location 123</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
JUMP_UNLESS<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;jump-unless&quot;</span><span class="Delimiter">,</span> JUMP_UNLESS<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> JUMP_UNLESS: <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-unless' requires exactly two ingredients, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-unless' requires a boolean for its first ingredient, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-unless' requires a label or offset for its second ingredient, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Comment">// End JUMP_UNLESS Checks</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> JUMP_UNLESS: <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>initialized<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>
    trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;jump-unless fell through&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  current_step_index<span class="Delimiter">()</span> += ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>+<span class="Constant">1</span><span class="Delimiter">;</span>
  trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;jumping to instruction &quot;</span> &lt;&lt; current_step_index<span class="Delimiter">()</span> &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Identifier">continue</span><span class="Delimiter">;</span>  <span class="Comment">// skip rest of this instruction</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(scenario jump_unless)</span>
<span class="muRecipe">def</span> main [
  jump-unless <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1:offset</span>
  <span class="Constant">123</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
]
<span class="traceContains">+run: jump-unless {0: &quot;literal&quot;}, {1: &quot;offset&quot;}</span>
<span class="traceContains">+run: jumping to instruction 2</span>
<span class="traceAbsent">-run: {123: &quot;number&quot;} &lt;- copy {1: &quot;literal&quot;}</span>
<span class="traceAbsent">-mem: storing 1 in location 123</span>

<span class="Delimiter">:(scenario jump_unless_fallthrough)</span>
<span class="muRecipe">def</span> main [
  jump-unless <span class="Constant">999</span><span class="Delimiter">,</span> <span class="Constant">1:offset</span>
  <span class="Constant">123</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
]
<span class="traceContains">+run: jump-unless {999: &quot;literal&quot;}, {1: &quot;offset&quot;}</span>
<span class="traceContains">+run: jump-unless fell through</span>
<span class="traceContains">+run: {123: &quot;number&quot;} &lt;- copy {1: &quot;literal&quot;}</span>
<span class="traceContains">+mem: storing 1 in location 123</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->