about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/README.md6
-rwxr-xr-xapps/ex2bin214 -> 219 bytes
-rw-r--r--apps/ex2.2.mu19
-rw-r--r--apps/ex2.mu2
-rw-r--r--apps/ex2.subx10
5 files changed, 12 insertions, 25 deletions
diff --git a/apps/README.md b/apps/README.md
index 1e1a5685..c246b44b 100644
--- a/apps/README.md
+++ b/apps/README.md
@@ -9,3 +9,9 @@ Some apps written in SubX and Mu, in 3 categories:
   * More ambitious translator for a memory-safe language (in progress): `mu`
 
 * Miscellaneous test programs.
+
+All SubX apps include binaries. 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.
diff --git a/apps/ex2 b/apps/ex2
index e18440e1..0917c0aa 100755
--- a/apps/ex2
+++ b/apps/ex2
Binary files differdiff --git a/apps/ex2.2.mu b/apps/ex2.2.mu
deleted file mode 100644
index b177e770..00000000
--- a/apps/ex2.2.mu
+++ /dev/null
@@ -1,19 +0,0 @@
-# Increment a number, and return the result in the exit code.
-#
-# To run:
-#   $ ./translate_mu apps/ex2.2.mu
-#   $ ./a.elf
-# Expected result:
-#   $ echo $?
-#   7
-
-fn main -> result/ebx: int {
-  result <- foo
-}
-
-fn foo -> result/ebx: int {
-  var n: int
-  copy-to n, 3
-  increment n
-  result <- copy n
-}
diff --git a/apps/ex2.mu b/apps/ex2.mu
index fc20aa2e..c3a73874 100644
--- a/apps/ex2.mu
+++ b/apps/ex2.mu
@@ -1,4 +1,4 @@
-# Add two numbers, and return the result in the exit code.
+# Add 3 and 4, and return the result in the exit code.
 #
 # To run:
 #   $ ./translate_mu apps/ex2.mu
diff --git a/apps/ex2.subx b/apps/ex2.subx
index 11c04432..14007329 100644
--- a/apps/ex2.subx
+++ b/apps/ex2.subx
@@ -1,4 +1,4 @@
-# Add 1 and 1, and return the result in the exit code.
+# Add 3 and 4, and return the result in the exit code.
 #
 # To run:
 #   $ ./bootstrap translate init.linux apps/ex2.subx -o apps/ex2
@@ -10,10 +10,10 @@
 == code
 
 Entry:
-# ebx = 1
-bb/copy-to-ebx  1/imm32
-# increment ebx
-43/increment-ebx
+# ebx = 3
+bb/copy-to-ebx  3/imm32
+# add 4 to ebx
+81 0/subop/add 3/mod/direct 3/rm32/ebx 4/imm32
 # exit(ebx)
 e8/call  syscall_exit/disp32