about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-01-02 14:12:46 -0800
committerKartik Agaram <vc@akkartik.com>2020-01-02 14:12:46 -0800
commit8bbafb13974bbfd7223e8c69156493a123702c0d (patch)
tree5226f807ced58b0c4f96ec59f596834e2f31ea81 /apps
parent42b4da908edc6a35a864bd656aca737f70823adf (diff)
downloadmu-8bbafb13974bbfd7223e8c69156493a123702c0d.tar.gz
5872
Diffstat (limited to 'apps')
-rw-r--r--apps/ex1.mu13
-rw-r--r--apps/ex1.subx2
2 files changed, 14 insertions, 1 deletions
diff --git a/apps/ex1.mu b/apps/ex1.mu
new file mode 100644
index 00000000..f6d67001
--- /dev/null
+++ b/apps/ex1.mu
@@ -0,0 +1,13 @@
+# First example: return the answer to the Ultimate Question of Life, the
+# Universe, and Everything.
+#
+# To run:
+#   $ ./translate_mu apps/ex1.mu
+#   $ ./a.elf
+# Expected result:
+#   $ echo $?
+#   42
+
+fn main -> result/ebx: int {
+  result <- copy 0x2a  # Mu requires hexadecimal
+}
diff --git a/apps/ex1.subx b/apps/ex1.subx
index 5558d310..a851613c 100644
--- a/apps/ex1.subx
+++ b/apps/ex1.subx
@@ -12,7 +12,7 @@
 
 Entry:
 # exit(42)
-bb/copy-to-ebx  2a/imm32  # 42 in hex
+bb/copy-to-ebx  0x2a/imm32  # 42 in hex
 e8/call  syscall_exit/disp32
 
 # . . vim:nowrap:textwidth=0