about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-07-24 17:05:22 -0700
committerKartik Agaram <vc@akkartik.com>2019-07-24 17:05:22 -0700
commitdccb5c66567b6ebf2663f620b3c404353cb731c6 (patch)
treef77eefe1852effe7754b34768c13304d55e56c60 /subx
parent29ec821cf77bf64d0cb9de0db1a54f032bbf2d94 (diff)
downloadmu-dccb5c66567b6ebf2663f620b3c404353cb731c6.tar.gz
5466 - demo self-hosting in Readme
Diffstat (limited to 'subx')
-rw-r--r--subx/Readme.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/subx/Readme.md b/subx/Readme.md
index 53b12ca4..8bf3efa6 100644
--- a/subx/Readme.md
+++ b/subx/Readme.md
@@ -59,6 +59,29 @@ covered by automated tests. SubX's tagline: tests before syntax.
   $ ./subx run apps/factorial test
   ```
 
+You can use SubX to translate itself. For example, running natively on Linux:
+
+  ```sh
+  # generate translator phases using C++
+  $ ./subx translate 0*.subx apps/subx-common.subx apps/hex.subx    -o hex
+  $ ./subx translate 0*.subx apps/subx-common.subx apps/survey.subx -o survey
+  $ ./subx translate 0*.subx apps/subx-common.subx apps/pack.subx   -o pack
+  $ ./subx translate 0*.subx apps/subx-common.subx apps/assort.subx -o assort
+  $ ./subx translate 0*.subx apps/subx-common.subx apps/dquotes.subx -o dquotes
+  $ ./subx translate 0*.subx apps/subx-common.subx apps/tests.subx  -o tests
+  $ chmod +x hex survey pack assort dquotes tests
+
+  # use the new translator phases to translate subx programs (including translator phases!)
+  $ cat examples/ex1.subx |./tests |./dquotes |./assort |./pack |./survey |./hex > a.elf
+  $ chmod +x a.elf
+  $ ./a.elf
+  $ echo $?
+  42
+  ```
+
+(For running emulated on other platforms, see the `translate` script. You'll
+need 16GB RAM for translating some of the larger programs.)
+
 You can use it to learn about the x86 processor that (almost certainly) runs
 your computer. (See below.)