From 2d306e2a989386b41eb9626324f6702a64e87b77 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 4 Mar 2021 00:11:23 -0800 Subject: [PATCH] 7846 --- README.md | 2 +- ex1.subx | 2 +- ex2.mu | 2 +- ex2.subx | 2 +- ex3.mu | 2 +- ex4.mu | 2 +- ex5.mu | 2 +- ex6.mu | 2 +- ex7.mu | 2 +- life.mu | 2 +- linux/403unicode.mu | 7 ------- linux/advent2020/1a.mu | 2 +- linux/advent2020/1b.mu | 2 +- linux/advent2020/2a.mu | 2 +- linux/advent2020/2b.mu | 2 +- linux/advent2020/3a.mu | 2 +- linux/advent2020/3b.mu | 2 +- linux/advent2020/4a.mu | 2 +- linux/advent2020/4b.mu | 2 +- linux/advent2020/5a.mu | 2 +- linux/advent2020/5b.mu | 2 +- linux/arith.mu | 2 +- linux/browse/README.md | 3 ++- linux/ex1.mu | 2 +- linux/ex2.mu | 2 +- linux/ex3.2.mu | 2 +- linux/ex3.mu | 2 +- linux/factorial.mu | 2 +- linux/hello.mu | 2 +- linux/parse-int.mu | 2 +- linux/print-file.mu | 2 +- linux/raytracing/1.mu | 2 +- linux/raytracing/2.mu | 2 +- linux/raytracing/3.mu | 2 +- linux/rpn.mu | 2 +- linux/texture.mu | 2 +- linux/tile/README.md | 9 +++++---- linux/tui.mu | 2 +- mu-init.subx | 5 +++-- rpn.mu | 2 +- tools/browse_trace.readme.md | 10 ++++++---- 41 files changed, 52 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 5a792534..9bbf91df 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/ex1.subx b/ex1.subx index 8a5dfdb7..502d8c4a 100644 --- a/ex1.subx +++ b/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: diff --git a/ex2.mu b/ex2.mu index adc905e9..b1eafcf3 100644 --- a/ex2.mu +++ b/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: diff --git a/ex2.subx b/ex2.subx index 074d641e..277c2aad 100644 --- a/ex2.subx +++ b/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: diff --git a/ex3.mu b/ex3.mu index e174ca22..b98304b1 100644 --- a/ex3.mu +++ b/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: diff --git a/ex4.mu b/ex4.mu index 5b883131..54da7c20 100644 --- a/ex4.mu +++ b/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: diff --git a/ex5.mu b/ex5.mu index 1f3bea10..3a3c1563 100644 --- a/ex5.mu +++ b/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: diff --git a/ex6.mu b/ex6.mu index d209e3f6..7d11069c 100644 --- a/ex6.mu +++ b/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: diff --git a/ex7.mu b/ex7.mu index 30e3c1bc..788ff121 100644 --- a/ex7.mu +++ b/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: diff --git a/life.mu b/life.mu index c8643ea9..da16ff4b 100644 --- a/life.mu +++ b/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 diff --git a/linux/403unicode.mu b/linux/403unicode.mu index 948e6618..9f857c7f 100644 --- a/linux/403unicode.mu +++ b/linux/403unicode.mu @@ -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 { diff --git a/linux/advent2020/1a.mu b/linux/advent2020/1a.mu index 67fdc358..886329f1 100644 --- a/linux/advent2020/1a.mu +++ b/linux/advent2020/1a.mu @@ -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 diff --git a/linux/advent2020/1b.mu b/linux/advent2020/1b.mu index a638d228..bfdbe47c 100644 --- a/linux/advent2020/1b.mu +++ b/linux/advent2020/1b.mu @@ -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 diff --git a/linux/advent2020/2a.mu b/linux/advent2020/2a.mu index dc67b94a..4492e7ea 100644 --- a/linux/advent2020/2a.mu +++ b/linux/advent2020/2a.mu @@ -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. diff --git a/linux/advent2020/2b.mu b/linux/advent2020/2b.mu index 13f60f0f..f228b451 100644 --- a/linux/advent2020/2b.mu +++ b/linux/advent2020/2b.mu @@ -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. diff --git a/linux/advent2020/3a.mu b/linux/advent2020/3a.mu index 76bda961..d2dfc15e 100644 --- a/linux/advent2020/3a.mu +++ b/linux/advent2020/3a.mu @@ -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. diff --git a/linux/advent2020/3b.mu b/linux/advent2020/3b.mu index fcc9261a..7db91eea 100644 --- a/linux/advent2020/3b.mu +++ b/linux/advent2020/3b.mu @@ -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. diff --git a/linux/advent2020/4a.mu b/linux/advent2020/4a.mu index e645da24..1b16712d 100644 --- a/linux/advent2020/4a.mu +++ b/linux/advent2020/4a.mu @@ -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. diff --git a/linux/advent2020/4b.mu b/linux/advent2020/4b.mu index 1ab29456..00e99eeb 100644 --- a/linux/advent2020/4b.mu +++ b/linux/advent2020/4b.mu @@ -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. diff --git a/linux/advent2020/5a.mu b/linux/advent2020/5a.mu index 5a456608..19d342c4 100644 --- a/linux/advent2020/5a.mu +++ b/linux/advent2020/5a.mu @@ -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. diff --git a/linux/advent2020/5b.mu b/linux/advent2020/5b.mu index fbc0d618..e6a3520f 100644 --- a/linux/advent2020/5b.mu +++ b/linux/advent2020/5b.mu @@ -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. diff --git a/linux/arith.mu b/linux/arith.mu index 3183cd31..0608d476 100644 --- a/linux/arith.mu +++ b/linux/arith.mu @@ -7,7 +7,7 @@ # No division yet. # # To build: -# $ ./translate_mu apps/arith.mu +# $ ./translate arith.mu # # Example session: # $ ./a.elf diff --git a/linux/browse/README.md b/linux/browse/README.md index 8f92b584..0c2bd8cf 100644 --- a/linux/browse/README.md +++ b/linux/browse/README.md @@ -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__ ``` diff --git a/linux/ex1.mu b/linux/ex1.mu index 41609fac..fbf38d0c 100644 --- a/linux/ex1.mu +++ b/linux/ex1.mu @@ -2,7 +2,7 @@ # Universe, and Everything. # # To run: -# $ ./translate_mu apps/ex1.mu +# $ ./translate ex1.mu # $ ./a.elf # Expected result: # $ echo $? diff --git a/linux/ex2.mu b/linux/ex2.mu index 16f04d29..21dee1df 100644 --- a/linux/ex2.mu +++ b/linux/ex2.mu @@ -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 $? diff --git a/linux/ex3.2.mu b/linux/ex3.2.mu index d06928fe..8ca6c992 100644 --- a/linux/ex3.2.mu +++ b/linux/ex3.2.mu @@ -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 diff --git a/linux/ex3.mu b/linux/ex3.mu index d7e73140..f96fd099 100644 --- a/linux/ex3.mu +++ b/linux/ex3.mu @@ -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 $? diff --git a/linux/factorial.mu b/linux/factorial.mu index 15ac8cf4..d2088486 100644 --- a/linux/factorial.mu +++ b/linux/factorial.mu @@ -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 diff --git a/linux/hello.mu b/linux/hello.mu index 9e8fdb6f..ac280b8a 100644 --- a/linux/hello.mu +++ b/linux/hello.mu @@ -1,7 +1,7 @@ # Meaningless conventional example. # # To run: -# $ ./translate_mu apps/hello.mu +# $ ./translate hello.mu # $ ./a.elf fn main -> _/ebx: int { diff --git a/linux/parse-int.mu b/linux/parse-int.mu index 5bef26ab..8f572784 100644 --- a/linux/parse-int.mu +++ b/linux/parse-int.mu @@ -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 diff --git a/linux/print-file.mu b/linux/print-file.mu index 57e044dc..6dded6ba 100644 --- a/linux/print-file.mu +++ b/linux/print-file.mu @@ -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 diff --git a/linux/raytracing/1.mu b/linux/raytracing/1.mu index fbc76f1d..8c92710f 100644 --- a/linux/raytracing/1.mu +++ b/linux/raytracing/1.mu @@ -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 { diff --git a/linux/raytracing/2.mu b/linux/raytracing/2.mu index e23ce3b4..7de89518 100644 --- a/linux/raytracing/2.mu +++ b/linux/raytracing/2.mu @@ -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 { diff --git a/linux/raytracing/3.mu b/linux/raytracing/3.mu index e190222d..c64ea035 100644 --- a/linux/raytracing/3.mu +++ b/linux/raytracing/3.mu @@ -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) { diff --git a/linux/rpn.mu b/linux/rpn.mu index 762d9605..9b290d28 100644 --- a/linux/rpn.mu +++ b/linux/rpn.mu @@ -4,7 +4,7 @@ # No division yet. # # To build: -# $ ./translate_mu apps/rpn.mu +# $ ./translate rpn.mu # # Example session: # $ ./a.elf diff --git a/linux/texture.mu b/linux/texture.mu index 4cfd3bbe..8178424b 100644 --- a/linux/texture.mu +++ b/linux/texture.mu @@ -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 { diff --git a/linux/tile/README.md b/linux/tile/README.md index a13f7662..602b1466 100644 --- a/linux/tile/README.md +++ b/linux/tile/README.md @@ -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 diff --git a/linux/tui.mu b/linux/tui.mu index c58a82c6..b34c3e0a 100644 --- a/linux/tui.mu +++ b/linux/tui.mu @@ -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 { diff --git a/mu-init.subx b/mu-init.subx index 26b83451..8c68f280 100644 --- a/mu-init.subx +++ b/mu-init.subx @@ -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 diff --git a/rpn.mu b/rpn.mu index eaccccdf..341f942d 100644 --- a/rpn.mu +++ b/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 diff --git a/tools/browse_trace.readme.md b/tools/browse_trace.readme.md index d607095e..8c3f50f4 100644 --- a/tools/browse_trace.readme.md +++ b/tools/browse_trace.readme.md @@ -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