This commit is contained in:
Kartik Agaram 2020-01-02 14:12:46 -08:00
parent 42b4da908e
commit 8bbafb1397
3 changed files with 21 additions and 8 deletions

View File

@ -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. 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/` That should be enough information for writing SubX programs. The `apps/`
directory provides some fodder for practice in the `apps/ex*` files, giving a directory provides some fodder for practice in the `apps/ex*.subx` files,
more gradual introduction to SubX features. This repo includes binaries for giving a more gradual introduction to SubX features. This repo includes
all examples. At any commit, an example's binary should be identical bit for binaries for all examples. At any commit, an example's binary should be
bit with the result of translating the corresponding `.subx` file. The binary identical bit for bit with the result of translating the corresponding `.subx`
should also be natively runnable on a Linux system running on Intel x86 file. The binary should also be natively runnable on a Linux system running on
processors, either 32- or 64-bit. If either of these invariants is broken it's Intel x86 processors, either 32- or 64-bit. If either of these invariants is
a bug on my part. broken it's a bug on my part.
## Running ## Running

13
apps/ex1.mu Normal file
View File

@ -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
}

View File

@ -12,7 +12,7 @@
Entry: Entry:
# exit(42) # 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 e8/call syscall_exit/disp32
# . . vim:nowrap:textwidth=0 # . . vim:nowrap:textwidth=0