about summary refs log tree commit diff stats
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
parent42b4da908edc6a35a864bd656aca737f70823adf (diff)
downloadmu-8bbafb13974bbfd7223e8c69156493a123702c0d.tar.gz
5872
-rw-r--r--README.md14
-rw-r--r--apps/ex1.mu13
-rw-r--r--apps/ex1.subx2
3 files changed, 21 insertions, 8 deletions
diff --git a/README.md b/README.md
index cddf9c7b..af139f95 100644
--- a/README.md
+++ b/README.md
@@ -329,13 +329,13 @@ transparently copy it to the `data` segment and replace it with its address.
 Strings are the only place where a SubX word is allowed to contain spaces.
 
 That should be enough information for writing SubX programs. The `apps/`
-directory provides some fodder for practice in the `apps/ex*` files, giving a
-more gradual introduction to SubX features. This repo includes binaries for
-all examples. At any commit, an example's binary should be identical bit for
-bit with the result of translating the corresponding `.subx` file. The binary
-should also be natively runnable on a Linux system running on Intel x86
-processors, either 32- or 64-bit. If either of these invariants is broken it's
-a bug on my part.
+directory provides some fodder for practice in the `apps/ex*.subx` files,
+giving a more gradual introduction to SubX features. This repo includes
+binaries for all examples. At any commit, an example's binary should be
+identical bit for bit with the result of translating the corresponding `.subx`
+file. The binary should also be natively runnable on a Linux system running on
+Intel x86 processors, either 32- or 64-bit. If either of these invariants is
+broken it's a bug on my part.
 
 ## Running
 
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