about summary refs log tree commit diff stats
path: root/tutorial/task7-solution.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-10-21 21:02:37 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-10-21 21:02:52 -0700
commit5de772bebd986c2abb3b7c34715f13b07a4f6c2a (patch)
tree102550555f255644f5944271143e83d19a16ac7d /tutorial/task7-solution.mu
parent42002973c13e464ae77e3d352cd14b338f00f8c6 (diff)
downloadmu-5de772bebd986c2abb3b7c34715f13b07a4f6c2a.tar.gz
task: using a runbook
Diffstat (limited to 'tutorial/task7-solution.mu')
-rw-r--r--tutorial/task7-solution.mu18
1 files changed, 18 insertions, 0 deletions
diff --git a/tutorial/task7-solution.mu b/tutorial/task7-solution.mu
new file mode 100644
index 00000000..9611e0a8
--- /dev/null
+++ b/tutorial/task7-solution.mu
@@ -0,0 +1,18 @@
+fn foo -> _/eax: int {
+  var x/edx: int <- copy 0
+  # statement 1: store 3 in x
+  x <- copy 3
+  # statement 2: define a new variable 'y' in register eax and store 4 in it
+  var y/eax: int <- copy 4
+  # statement 3: add y to x, storing the result in x
+  x <- add y
+  return x
+}
+
+fn test-foo {
+  var result/eax: int <- foo
+  check-ints-equal result, 7, "F - foo should return 7, but didn't"
+}
+
+fn main {
+}