7846
This commit is contained in:
parent
baaf53aba4
commit
2d306e2a98
|
@ -93,7 +93,7 @@ Mu programs build natively either on Linux or on Windows using [WSL 2](https://d
|
|||
For Macs and other Unix-like systems, use the (much slower) emulator:
|
||||
|
||||
```sh
|
||||
$ ./translate_mu_emulated ex2.mu # ~2 mins to emit disk.img
|
||||
$ ./translate_emulated ex2.mu # ~2 mins to emit disk.img
|
||||
```
|
||||
|
||||
Mu programs can be written for two very different environments:
|
||||
|
|
2
ex1.subx
2
ex1.subx
|
@ -4,7 +4,7 @@
|
|||
# graphics mode.
|
||||
#
|
||||
# To build a disk image:
|
||||
# ./translate_subx_baremetal baremetal/ex2.subx # emits disk.img
|
||||
# ./translate_subx ex2.subx # emits disk.img
|
||||
# To run:
|
||||
# qemu-system-i386 disk.img
|
||||
# Or:
|
||||
|
|
2
ex2.mu
2
ex2.mu
|
@ -1,7 +1,7 @@
|
|||
# Test out the video mode by filling in the screen with pixels.
|
||||
#
|
||||
# To build a disk image:
|
||||
# ./translate_mu_baremetal baremetal/ex2.mu # emits disk.img
|
||||
# ./translate ex2.mu # emits disk.img
|
||||
# To run:
|
||||
# qemu-system-i386 disk.img
|
||||
# Or:
|
||||
|
|
2
ex2.subx
2
ex2.subx
|
@ -1,7 +1,7 @@
|
|||
# Test out the video mode by filling in the screen with pixels.
|
||||
#
|
||||
# To build a disk image:
|
||||
# ./translate_subx_baremetal baremetal/ex2.subx # emits disk.img
|
||||
# ./translate_subx ex2.subx # emits disk.img
|
||||
# To run:
|
||||
# qemu-system-i386 disk.img
|
||||
# Or:
|
||||
|
|
2
ex3.mu
2
ex3.mu
|
@ -2,7 +2,7 @@
|
|||
# and in raster order.
|
||||
#
|
||||
# To build a disk image:
|
||||
# ./translate_mu_baremetal baremetal/ex3.mu # emits disk.img
|
||||
# ./translate ex3.mu # emits disk.img
|
||||
# To run:
|
||||
# qemu-system-i386 disk.img
|
||||
# Or:
|
||||
|
|
2
ex4.mu
2
ex4.mu
|
@ -1,7 +1,7 @@
|
|||
# Draw a character using the built-in font (GNU unifont)
|
||||
#
|
||||
# To build a disk image:
|
||||
# ./translate_mu_baremetal baremetal/ex4.mu # emits disk.img
|
||||
# ./translate ex4.mu # emits disk.img
|
||||
# To run:
|
||||
# qemu-system-i386 disk.img
|
||||
# Or:
|
||||
|
|
2
ex5.mu
2
ex5.mu
|
@ -2,7 +2,7 @@
|
|||
# Also demonstrates bounds-checking _before_ drawing.
|
||||
#
|
||||
# To build a disk image:
|
||||
# ./translate_mu_baremetal baremetal/ex5.mu # emits disk.img
|
||||
# ./translate ex5.mu # emits disk.img
|
||||
# To run:
|
||||
# qemu-system-i386 disk.img
|
||||
# Or:
|
||||
|
|
2
ex6.mu
2
ex6.mu
|
@ -1,7 +1,7 @@
|
|||
# Drawing ASCII text incrementally.
|
||||
#
|
||||
# To build a disk image:
|
||||
# ./translate_mu_baremetal baremetal/ex6.mu # emits disk.img
|
||||
# ./translate ex6.mu # emits disk.img
|
||||
# To run:
|
||||
# qemu-system-i386 disk.img
|
||||
# Or:
|
||||
|
|
2
ex7.mu
2
ex7.mu
|
@ -1,7 +1,7 @@
|
|||
# Cursor-based motions.
|
||||
#
|
||||
# To build a disk image:
|
||||
# ./translate_mu_baremetal baremetal/ex7.mu # emits disk.img
|
||||
# ./translate ex7.mu # emits disk.img
|
||||
# To run:
|
||||
# qemu-system-i386 disk.img
|
||||
# Or:
|
||||
|
|
2
life.mu
2
life.mu
|
@ -1,7 +1,7 @@
|
|||
# Conway's Game of Life
|
||||
#
|
||||
# To build:
|
||||
# $ ./translate_mu_baremetal baremetal/life.mu
|
||||
# $ ./translate life.mu
|
||||
# To run:
|
||||
# $ qemu-system-i386 disk.img
|
||||
|
||||
|
|
|
@ -367,13 +367,6 @@ fn test-shift-left-bytes-5 {
|
|||
check-ints-equal result, 0, "F - shift-left-bytes >4"
|
||||
}
|
||||
|
||||
# To run all tests, uncomment this and run:
|
||||
# $ ./translate_mu && ./a.elf
|
||||
#? fn main -> _/ebx: int {
|
||||
#? run-tests
|
||||
#? r <- copy 0
|
||||
#? }
|
||||
|
||||
# write a grapheme to a stream of bytes
|
||||
# this is like write-to-stream, except we skip leading 0 bytes
|
||||
fn write-grapheme out: (addr stream byte), g: grapheme {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/advent2020/1a.mu
|
||||
# $ ./translate advent2020/1a.mu
|
||||
# $ ./a.elf < input
|
||||
# found
|
||||
# 1353 667
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/advent2020/1b.mu
|
||||
# $ ./translate advent2020/1b.mu
|
||||
# $ ./a.elf < input
|
||||
# found
|
||||
# 143 407 1470
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/advent2020/2a.mu
|
||||
# $ ./translate advent2020/2a.mu
|
||||
# $ ./a.elf < input
|
||||
#
|
||||
# You'll need to register to download the 'input' file for yourself.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/advent2020/2b.mu
|
||||
# $ ./translate advent2020/2b.mu
|
||||
# $ ./a.elf < input
|
||||
#
|
||||
# You'll need to register to download the 'input' file for yourself.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/advent2020/3a.mu
|
||||
# $ ./translate advent2020/3a.mu
|
||||
# $ ./a.elf < input
|
||||
#
|
||||
# You'll need to register to download the 'input' file for yourself.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/advent2020/3a.mu
|
||||
# $ ./translate advent2020/3a.mu
|
||||
# $ ./a.elf < input
|
||||
#
|
||||
# You'll need to register to download the 'input' file for yourself.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/advent2020/4a.mu
|
||||
# $ ./translate advent2020/4a.mu
|
||||
# $ ./a.elf < input
|
||||
#
|
||||
# You'll need to register to download the 'input' file for yourself.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/advent2020/4b.mu
|
||||
# $ ./translate advent2020/4b.mu
|
||||
# $ ./a.elf < input
|
||||
#
|
||||
# You'll need to register to download the 'input' file for yourself.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/advent2020/5a.mu
|
||||
# $ ./translate advent2020/5a.mu
|
||||
# $ ./a.elf < input
|
||||
#
|
||||
# You'll need to register to download the 'input' file for yourself.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/advent2020/5b.mu
|
||||
# $ ./translate advent2020/5b.mu
|
||||
# $ ./a.elf < input
|
||||
#
|
||||
# You'll need to register to download the 'input' file for yourself.
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# No division yet.
|
||||
#
|
||||
# To build:
|
||||
# $ ./translate_mu apps/arith.mu
|
||||
# $ ./translate arith.mu
|
||||
#
|
||||
# Example session:
|
||||
# $ ./a.elf
|
||||
|
|
|
@ -3,7 +3,8 @@ Render a subset of Markdown.
|
|||
To run:
|
||||
|
||||
```
|
||||
$ ./translate_mu apps/browse.mu
|
||||
$ cd linux
|
||||
$ ./translate browse.mu
|
||||
$ ./a.elf __text_file__
|
||||
```
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Universe, and Everything.
|
||||
#
|
||||
# To run:
|
||||
# $ ./translate_mu apps/ex1.mu
|
||||
# $ ./translate ex1.mu
|
||||
# $ ./a.elf
|
||||
# Expected result:
|
||||
# $ echo $?
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Add 3 and 4, and return the result in the exit code.
|
||||
#
|
||||
# To run:
|
||||
# $ ./translate_mu apps/ex2.mu
|
||||
# $ ./translate ex2.mu
|
||||
# $ ./a.elf
|
||||
# Expected result:
|
||||
# $ echo $?
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Unnecessarily use an array to sum 1..10
|
||||
#
|
||||
# To run:
|
||||
# $ ./translate_mu apps/ex3.2.mu
|
||||
# $ ./translate ex3.2.mu
|
||||
# $ ./a.elf
|
||||
# $ echo $?
|
||||
# 55
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Add the first 10 numbers, and return the result in the exit code.
|
||||
#
|
||||
# To run:
|
||||
# $ ./translate_mu apps/browse.mu
|
||||
# $ ./translate browse.mu
|
||||
# $ ./a.elf
|
||||
# Expected result:
|
||||
# $ echo $?
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# compute the factorial of 5, and return the result in the exit code
|
||||
#
|
||||
# To run:
|
||||
# $ ./translate_mu apps/factorial.mu
|
||||
# $ ./translate factorial.mu
|
||||
# $ ./a.elf
|
||||
# $ echo $?
|
||||
# 120
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Meaningless conventional example.
|
||||
#
|
||||
# To run:
|
||||
# $ ./translate_mu apps/hello.mu
|
||||
# $ ./translate hello.mu
|
||||
# $ ./a.elf
|
||||
|
||||
fn main -> _/ebx: int {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# parse a decimal int at the commandline
|
||||
#
|
||||
# To run:
|
||||
# $ ./translate_mu apps/parse-int.mu
|
||||
# $ ./translate parse-int.mu
|
||||
# $ ./a.elf 123
|
||||
# $ echo $?
|
||||
# 123
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# only ascii right now, just like the rest of Mu
|
||||
#
|
||||
# To run:
|
||||
# $ ./translate_mu apps/print-file.mu
|
||||
# $ ./translate print-file.mu
|
||||
# $ echo abc > x
|
||||
# $ ./a.elf x
|
||||
# abc
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/raytracing/1.mu
|
||||
# $ ./translate raytracing/1.mu
|
||||
# $ ./a.elf > 1.ppm
|
||||
|
||||
fn main -> _/ebx: int {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/raytracing/2.mu
|
||||
# $ ./translate raytracing/2.mu
|
||||
# $ ./a.elf > 2.ppm
|
||||
|
||||
fn main -> _/ebx: int {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/raytracing/3.mu
|
||||
# $ ./translate raytracing/3.mu
|
||||
# $ ./a.elf > 3.ppm
|
||||
|
||||
fn ray-color _in: (addr ray), _out: (addr rgb) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# No division yet.
|
||||
#
|
||||
# To build:
|
||||
# $ ./translate_mu apps/rpn.mu
|
||||
# $ ./translate rpn.mu
|
||||
#
|
||||
# Example session:
|
||||
# $ ./a.elf
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# To run (on Linux):
|
||||
# $ git clone https://github.com/akkartik/mu
|
||||
# $ cd mu
|
||||
# $ ./translate_mu apps/texture.mu
|
||||
# $ ./translate texture.mu
|
||||
# $ ./a.elf > a.ppm
|
||||
|
||||
fn main -> _/ebx: int {
|
||||
|
|
|
@ -5,20 +5,21 @@ A programming environment that tries to [“stop drawing dead fish”](h
|
|||
To run:
|
||||
|
||||
```
|
||||
./translate_mu apps/tile/*.mu
|
||||
./a.elf screen
|
||||
$ cd linux
|
||||
$ ./translate tile/*.mu
|
||||
$ ./a.elf screen
|
||||
```
|
||||
|
||||
To run tests:
|
||||
|
||||
```
|
||||
./a.elf test
|
||||
$ ./a.elf test
|
||||
```
|
||||
|
||||
To run a conventional REPL (for debugging):
|
||||
|
||||
```
|
||||
./a.elf type
|
||||
$ ./a.elf type
|
||||
```
|
||||
|
||||
## hacking
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Test some primitives for text-mode.
|
||||
#
|
||||
# To run:
|
||||
# $ ./translate_mu apps/tui.mu
|
||||
# $ ./translate tui.mu
|
||||
# $ ./a.elf
|
||||
|
||||
fn main -> _/ebx: int {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# Initialize the minimal runtime for Mu programs.
|
||||
#
|
||||
# See translate_mu_baremetal for how this file is used.
|
||||
# See translate for how this file is used.
|
||||
#
|
||||
# Mu baremetal programs start at a function called 'main' without inouts or outputs.
|
||||
# Mu programs start at a function called 'main' without inouts or outputs.
|
||||
# All tests must pass first (the "power-on unit test").
|
||||
|
||||
== code
|
||||
|
||||
|
|
2
rpn.mu
2
rpn.mu
|
@ -4,7 +4,7 @@
|
|||
# Division not implemented yet.
|
||||
#
|
||||
# To build:
|
||||
# $ ./translate_mu_baremetal baremetal/rpn.mu
|
||||
# $ ./translate rpn.mu
|
||||
#
|
||||
# Example session:
|
||||
# $ qemu-system-i386 disk.img
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
### A debugging helper that lets you zoom in/out on a trace.
|
||||
|
||||
To try it out, first create an example trace (from the top-level `mu/`
|
||||
directory):
|
||||
To try it out, first create an example trace:
|
||||
|
||||
```shell
|
||||
./subx --trace run apps/factorial
|
||||
$ cd linux
|
||||
$ bootstrap/bootstrap translate [01]*.subx factorial.subx -o factorial
|
||||
$ bootstrap/bootstrap --trace run factorial
|
||||
```
|
||||
|
||||
This command will save a trace of its execution in a file called `last_run`.
|
||||
|
@ -14,7 +15,8 @@ and a single-word 'label', followed by a colon and whitespace.
|
|||
Now browse this trace:
|
||||
|
||||
```shell
|
||||
tools/browse_trace last_run
|
||||
$ cd ..
|
||||
$ tools/browse_trace linux/last_run
|
||||
```
|
||||
|
||||
You should now find yourself in a UI showing a subsequence of lines from the
|
||||
|
|
Loading…
Reference in New Issue