This commit is contained in:
Kartik K. Agaram 2021-03-04 00:11:23 -08:00
parent baaf53aba4
commit 2d306e2a98
41 changed files with 52 additions and 54 deletions

View File

@ -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: For Macs and other Unix-like systems, use the (much slower) emulator:
```sh ```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: Mu programs can be written for two very different environments:

View File

@ -4,7 +4,7 @@
# graphics mode. # graphics mode.
# #
# To build a disk image: # To build a disk image:
# ./translate_subx_baremetal baremetal/ex2.subx # emits disk.img # ./translate_subx ex2.subx # emits disk.img
# To run: # To run:
# qemu-system-i386 disk.img # qemu-system-i386 disk.img
# Or: # Or:

2
ex2.mu
View File

@ -1,7 +1,7 @@
# Test out the video mode by filling in the screen with pixels. # Test out the video mode by filling in the screen with pixels.
# #
# To build a disk image: # To build a disk image:
# ./translate_mu_baremetal baremetal/ex2.mu # emits disk.img # ./translate ex2.mu # emits disk.img
# To run: # To run:
# qemu-system-i386 disk.img # qemu-system-i386 disk.img
# Or: # Or:

View File

@ -1,7 +1,7 @@
# Test out the video mode by filling in the screen with pixels. # Test out the video mode by filling in the screen with pixels.
# #
# To build a disk image: # To build a disk image:
# ./translate_subx_baremetal baremetal/ex2.subx # emits disk.img # ./translate_subx ex2.subx # emits disk.img
# To run: # To run:
# qemu-system-i386 disk.img # qemu-system-i386 disk.img
# Or: # Or:

2
ex3.mu
View File

@ -2,7 +2,7 @@
# and in raster order. # and in raster order.
# #
# To build a disk image: # To build a disk image:
# ./translate_mu_baremetal baremetal/ex3.mu # emits disk.img # ./translate ex3.mu # emits disk.img
# To run: # To run:
# qemu-system-i386 disk.img # qemu-system-i386 disk.img
# Or: # Or:

2
ex4.mu
View File

@ -1,7 +1,7 @@
# Draw a character using the built-in font (GNU unifont) # Draw a character using the built-in font (GNU unifont)
# #
# To build a disk image: # To build a disk image:
# ./translate_mu_baremetal baremetal/ex4.mu # emits disk.img # ./translate ex4.mu # emits disk.img
# To run: # To run:
# qemu-system-i386 disk.img # qemu-system-i386 disk.img
# Or: # Or:

2
ex5.mu
View File

@ -2,7 +2,7 @@
# Also demonstrates bounds-checking _before_ drawing. # Also demonstrates bounds-checking _before_ drawing.
# #
# To build a disk image: # To build a disk image:
# ./translate_mu_baremetal baremetal/ex5.mu # emits disk.img # ./translate ex5.mu # emits disk.img
# To run: # To run:
# qemu-system-i386 disk.img # qemu-system-i386 disk.img
# Or: # Or:

2
ex6.mu
View File

@ -1,7 +1,7 @@
# Drawing ASCII text incrementally. # Drawing ASCII text incrementally.
# #
# To build a disk image: # To build a disk image:
# ./translate_mu_baremetal baremetal/ex6.mu # emits disk.img # ./translate ex6.mu # emits disk.img
# To run: # To run:
# qemu-system-i386 disk.img # qemu-system-i386 disk.img
# Or: # Or:

2
ex7.mu
View File

@ -1,7 +1,7 @@
# Cursor-based motions. # Cursor-based motions.
# #
# To build a disk image: # To build a disk image:
# ./translate_mu_baremetal baremetal/ex7.mu # emits disk.img # ./translate ex7.mu # emits disk.img
# To run: # To run:
# qemu-system-i386 disk.img # qemu-system-i386 disk.img
# Or: # Or:

View File

@ -1,7 +1,7 @@
# Conway's Game of Life # Conway's Game of Life
# #
# To build: # To build:
# $ ./translate_mu_baremetal baremetal/life.mu # $ ./translate life.mu
# To run: # To run:
# $ qemu-system-i386 disk.img # $ qemu-system-i386 disk.img

View File

@ -367,13 +367,6 @@ fn test-shift-left-bytes-5 {
check-ints-equal result, 0, "F - shift-left-bytes >4" 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 # write a grapheme to a stream of bytes
# this is like write-to-stream, except we skip leading 0 bytes # this is like write-to-stream, except we skip leading 0 bytes
fn write-grapheme out: (addr stream byte), g: grapheme { fn write-grapheme out: (addr stream byte), g: grapheme {

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/advent2020/1a.mu # $ ./translate advent2020/1a.mu
# $ ./a.elf < input # $ ./a.elf < input
# found # found
# 1353 667 # 1353 667

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/advent2020/1b.mu # $ ./translate advent2020/1b.mu
# $ ./a.elf < input # $ ./a.elf < input
# found # found
# 143 407 1470 # 143 407 1470

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/advent2020/2a.mu # $ ./translate advent2020/2a.mu
# $ ./a.elf < input # $ ./a.elf < input
# #
# You'll need to register to download the 'input' file for yourself. # You'll need to register to download the 'input' file for yourself.

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/advent2020/2b.mu # $ ./translate advent2020/2b.mu
# $ ./a.elf < input # $ ./a.elf < input
# #
# You'll need to register to download the 'input' file for yourself. # You'll need to register to download the 'input' file for yourself.

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/advent2020/3a.mu # $ ./translate advent2020/3a.mu
# $ ./a.elf < input # $ ./a.elf < input
# #
# You'll need to register to download the 'input' file for yourself. # You'll need to register to download the 'input' file for yourself.

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/advent2020/3a.mu # $ ./translate advent2020/3a.mu
# $ ./a.elf < input # $ ./a.elf < input
# #
# You'll need to register to download the 'input' file for yourself. # You'll need to register to download the 'input' file for yourself.

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/advent2020/4a.mu # $ ./translate advent2020/4a.mu
# $ ./a.elf < input # $ ./a.elf < input
# #
# You'll need to register to download the 'input' file for yourself. # You'll need to register to download the 'input' file for yourself.

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/advent2020/4b.mu # $ ./translate advent2020/4b.mu
# $ ./a.elf < input # $ ./a.elf < input
# #
# You'll need to register to download the 'input' file for yourself. # You'll need to register to download the 'input' file for yourself.

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/advent2020/5a.mu # $ ./translate advent2020/5a.mu
# $ ./a.elf < input # $ ./a.elf < input
# #
# You'll need to register to download the 'input' file for yourself. # You'll need to register to download the 'input' file for yourself.

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/advent2020/5b.mu # $ ./translate advent2020/5b.mu
# $ ./a.elf < input # $ ./a.elf < input
# #
# You'll need to register to download the 'input' file for yourself. # You'll need to register to download the 'input' file for yourself.

View File

@ -7,7 +7,7 @@
# No division yet. # No division yet.
# #
# To build: # To build:
# $ ./translate_mu apps/arith.mu # $ ./translate arith.mu
# #
# Example session: # Example session:
# $ ./a.elf # $ ./a.elf

View File

@ -3,7 +3,8 @@ Render a subset of Markdown.
To run: To run:
``` ```
$ ./translate_mu apps/browse.mu $ cd linux
$ ./translate browse.mu
$ ./a.elf __text_file__ $ ./a.elf __text_file__
``` ```

View File

@ -2,7 +2,7 @@
# Universe, and Everything. # Universe, and Everything.
# #
# To run: # To run:
# $ ./translate_mu apps/ex1.mu # $ ./translate ex1.mu
# $ ./a.elf # $ ./a.elf
# Expected result: # Expected result:
# $ echo $? # $ echo $?

View File

@ -1,7 +1,7 @@
# Add 3 and 4, and return the result in the exit code. # Add 3 and 4, and return the result in the exit code.
# #
# To run: # To run:
# $ ./translate_mu apps/ex2.mu # $ ./translate ex2.mu
# $ ./a.elf # $ ./a.elf
# Expected result: # Expected result:
# $ echo $? # $ echo $?

View File

@ -1,7 +1,7 @@
# Unnecessarily use an array to sum 1..10 # Unnecessarily use an array to sum 1..10
# #
# To run: # To run:
# $ ./translate_mu apps/ex3.2.mu # $ ./translate ex3.2.mu
# $ ./a.elf # $ ./a.elf
# $ echo $? # $ echo $?
# 55 # 55

View File

@ -1,7 +1,7 @@
# Add the first 10 numbers, and return the result in the exit code. # Add the first 10 numbers, and return the result in the exit code.
# #
# To run: # To run:
# $ ./translate_mu apps/browse.mu # $ ./translate browse.mu
# $ ./a.elf # $ ./a.elf
# Expected result: # Expected result:
# $ echo $? # $ echo $?

View File

@ -1,7 +1,7 @@
# compute the factorial of 5, and return the result in the exit code # compute the factorial of 5, and return the result in the exit code
# #
# To run: # To run:
# $ ./translate_mu apps/factorial.mu # $ ./translate factorial.mu
# $ ./a.elf # $ ./a.elf
# $ echo $? # $ echo $?
# 120 # 120

View File

@ -1,7 +1,7 @@
# Meaningless conventional example. # Meaningless conventional example.
# #
# To run: # To run:
# $ ./translate_mu apps/hello.mu # $ ./translate hello.mu
# $ ./a.elf # $ ./a.elf
fn main -> _/ebx: int { fn main -> _/ebx: int {

View File

@ -1,7 +1,7 @@
# parse a decimal int at the commandline # parse a decimal int at the commandline
# #
# To run: # To run:
# $ ./translate_mu apps/parse-int.mu # $ ./translate parse-int.mu
# $ ./a.elf 123 # $ ./a.elf 123
# $ echo $? # $ echo $?
# 123 # 123

View File

@ -2,7 +2,7 @@
# only ascii right now, just like the rest of Mu # only ascii right now, just like the rest of Mu
# #
# To run: # To run:
# $ ./translate_mu apps/print-file.mu # $ ./translate print-file.mu
# $ echo abc > x # $ echo abc > x
# $ ./a.elf x # $ ./a.elf x
# abc # abc

View File

@ -4,7 +4,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/raytracing/1.mu # $ ./translate raytracing/1.mu
# $ ./a.elf > 1.ppm # $ ./a.elf > 1.ppm
fn main -> _/ebx: int { fn main -> _/ebx: int {

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/raytracing/2.mu # $ ./translate raytracing/2.mu
# $ ./a.elf > 2.ppm # $ ./a.elf > 2.ppm
fn main -> _/ebx: int { fn main -> _/ebx: int {

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/raytracing/3.mu # $ ./translate raytracing/3.mu
# $ ./a.elf > 3.ppm # $ ./a.elf > 3.ppm
fn ray-color _in: (addr ray), _out: (addr rgb) { fn ray-color _in: (addr ray), _out: (addr rgb) {

View File

@ -4,7 +4,7 @@
# No division yet. # No division yet.
# #
# To build: # To build:
# $ ./translate_mu apps/rpn.mu # $ ./translate rpn.mu
# #
# Example session: # Example session:
# $ ./a.elf # $ ./a.elf

View File

@ -3,7 +3,7 @@
# To run (on Linux): # To run (on Linux):
# $ git clone https://github.com/akkartik/mu # $ git clone https://github.com/akkartik/mu
# $ cd mu # $ cd mu
# $ ./translate_mu apps/texture.mu # $ ./translate texture.mu
# $ ./a.elf > a.ppm # $ ./a.elf > a.ppm
fn main -> _/ebx: int { fn main -> _/ebx: int {

View File

@ -5,20 +5,21 @@ A programming environment that tries to [&ldquo;stop drawing dead fish&rdquo;](h
To run: To run:
``` ```
./translate_mu apps/tile/*.mu $ cd linux
./a.elf screen $ ./translate tile/*.mu
$ ./a.elf screen
``` ```
To run tests: To run tests:
``` ```
./a.elf test $ ./a.elf test
``` ```
To run a conventional REPL (for debugging): To run a conventional REPL (for debugging):
``` ```
./a.elf type $ ./a.elf type
``` ```
## hacking ## hacking

View File

@ -1,7 +1,7 @@
# Test some primitives for text-mode. # Test some primitives for text-mode.
# #
# To run: # To run:
# $ ./translate_mu apps/tui.mu # $ ./translate tui.mu
# $ ./a.elf # $ ./a.elf
fn main -> _/ebx: int { fn main -> _/ebx: int {

View File

@ -1,8 +1,9 @@
# Initialize the minimal runtime for Mu programs. # 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 == code

2
rpn.mu
View File

@ -4,7 +4,7 @@
# Division not implemented yet. # Division not implemented yet.
# #
# To build: # To build:
# $ ./translate_mu_baremetal baremetal/rpn.mu # $ ./translate rpn.mu
# #
# Example session: # Example session:
# $ qemu-system-i386 disk.img # $ qemu-system-i386 disk.img

View File

@ -1,10 +1,11 @@
### A debugging helper that lets you zoom in/out on a trace. ### 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/` To try it out, first create an example trace:
directory):
```shell ```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`. 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: Now browse this trace:
```shell ```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 You should now find yourself in a UI showing a subsequence of lines from the