diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-07-05 15:28:37 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-07-06 01:05:10 -0700 |
commit | 9a524793ee01ce47f3963768559a0d6c348631c5 (patch) | |
tree | aa1045424609f1a14a7a8e5bfaa1517101acd894 /apps | |
parent | 3ccb2c83280e22ad5b7f7c47d7bd95748b969521 (diff) | |
download | mu-9a524793ee01ce47f3963768559a0d6c348631c5.tar.gz |
6618 - new docs
Diffstat (limited to 'apps')
-rw-r--r-- | apps/README.md | 6 | ||||
-rwxr-xr-x | apps/ex2 | bin | 214 -> 219 bytes | |||
-rw-r--r-- | apps/ex2.2.mu | 19 | ||||
-rw-r--r-- | apps/ex2.mu | 2 | ||||
-rw-r--r-- | apps/ex2.subx | 10 |
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 |