7439 - start translating Mu programs to baremetal

This commit is contained in:
Kartik Agaram 2020-12-28 09:26:15 -08:00
parent 7566d80ade
commit dff67029ad
10 changed files with 19 additions and 19 deletions

View File

@ -4,7 +4,7 @@ Layers in the 1xx series are in bare SubX, without any syntax sugar. They are
intended to be used by the phases of the self-hosted translator to replicate
the functionality of the C++ bootstrap:
apps/hex.subx
apps/survey.subx
apps/survey_elf.subx
apps/pack.subx
apps/dquotes.subx
apps/assort.subx

View File

@ -15,7 +15,7 @@ Some apps written in SubX and Mu. Check out:
all the different syntax sugars and what they expand to.
* Code unique to phases of our build toolchain:
* Core SubX: `hex`, `survey`, `pack`, `dquotes`, `assort`, `tests`
* Core SubX: `hex`, `survey_elf`, `pack`, `dquotes`, `assort`, `tests`
* Syntax sugar for SubX: `sigils`, `calls`, `braces`
* More ambitious translator for a memory-safe language (in progress): `mu`

View File

@ -2,13 +2,13 @@
# (landscape).
# Use the addresses assigned to:
# a) replace labels
# b) add segment headers with addresses and offsets correctly filled in
# b) add an ELF header and segment headers with addresses and offsets correctly filled in
#
# To build:
# $ ./bootstrap translate init.linux 0*.subx apps/subx-params.subx apps/survey.subx -o apps/survey
# $ ./bootstrap translate init.linux 0*.subx apps/subx-params.subx apps/survey_elf.subx -o apps/survey_elf
#
# The expected input is a stream of bytes with segment headers, comments and
# some interspersed labels.
# The expected input is a stream of bytes with '==' segment headers, comments
# and some interspersed labels.
# $ cat x
# == code 0x1
# l1:
@ -23,7 +23,7 @@
# The output is the stream of bytes without segment headers or label definitions,
# and with label references replaced with numeric values/displacements.
#
# $ cat x |./bootstrap run apps/survey
# $ cat x |./bootstrap run apps/survey_elf
# ...ELF header bytes...
# # ELF header above will specify that code segment begins at this offset
# aa bb nn # some computed address

View File

@ -4,7 +4,7 @@ apps/factorial.subx 120 44
apps/crenshaw2-1.subx 561 180
apps/crenshaw2-1b.subx 757 186
apps/hex.subx 1442 149
apps/survey.subx 4733 905
apps/survey_elf.subx 4733 905
apps/pack.subx 5881 840
apps/dquotes.subx 1925 383
apps/assort.subx 905 183
@ -20,7 +20,7 @@ apps/factorial.subx 8436 1700
apps/crenshaw2-1.subx 8644 1925
apps/crenshaw2-1b.subx 8736 1931
apps/hex.subx 9065 1908
apps/survey.subx 10217 3248
apps/survey_elf.subx 10217 3248
apps/pack.subx 10589 2727
apps/dquotes.subx 9262 2468
apps/assort.subx 8686 2425
@ -36,7 +36,7 @@ apps/crenshaw2-1 41 4.3
apps/crenshaw2-1b 42 5.2
apps/factorial 42 5.2
apps/hex 45 5.0
apps/survey 51 9.6
apps/survey_elf 51 9.6
apps/pack 54 7.6
apps/dquotes 46 6.5
apps/assort 42 6.4

View File

@ -133,15 +133,15 @@ translate itself. For example, running natively on Linux:
```sh
# generate translator phases using the C++ translator
$ ./bootstrap translate init.linux 0*.subx apps/subx-params.subx apps/hex.subx -o hex
$ ./bootstrap translate init.linux 0*.subx apps/subx-params.subx apps/survey.subx -o survey
$ ./bootstrap translate init.linux 0*.subx apps/subx-params.subx apps/survey_elf.subx -o survey_elf
$ ./bootstrap translate init.linux 0*.subx apps/subx-params.subx apps/pack.subx -o pack
$ ./bootstrap translate init.linux 0*.subx apps/subx-params.subx apps/assort.subx -o assort
$ ./bootstrap translate init.linux 0*.subx apps/subx-params.subx apps/dquotes.subx -o dquotes
$ ./bootstrap translate init.linux 0*.subx apps/subx-params.subx apps/tests.subx -o tests
$ chmod +x hex survey pack assort dquotes tests
$ chmod +x hex survey_elf pack assort dquotes tests
# use the generated translator phases to translate SubX programs
$ cat init.linux apps/ex1.subx |./tests |./dquotes |./assort |./pack |./survey |./hex > a.elf
$ cat init.linux apps/ex1.subx |./tests |./dquotes |./assort |./pack |./survey_elf |./hex > a.elf
$ chmod +x a.elf
$ ./a.elf
$ echo $?

View File

@ -214,7 +214,7 @@ test "$1" = 'record' || git diff --exit-code apps/crenshaw2-1b
# Phases of the self-hosted SubX translator.
for phase in hex survey pack assort dquotes tests
for phase in hex survey_elf pack assort dquotes tests
do
echo $phase
./bootstrap_bin translate init.linux [01]*.subx apps/subx-params.subx apps/$phase.subx -o apps/$phase
@ -307,7 +307,7 @@ done
# Phases of the self-hosted SubX translator.
for app in hex survey pack assort dquotes tests
for app in hex survey_elf pack assort dquotes tests
do
echo $app
./translate_subx init.linux [01]*.subx apps/subx-params.subx apps/$app.subx

View File

@ -152,7 +152,7 @@ test "$1" = 'record' || git diff --exit-code apps/crenshaw2-1b
# Phases of the self-hosted SubX translator.
for phase in hex survey pack assort dquotes tests
for phase in hex survey_elf pack assort dquotes tests
do
echo $phase
./bootstrap_bin translate init.linux [01]*.subx apps/subx-params.subx apps/$phase.subx -o apps/$phase
@ -225,7 +225,7 @@ done
# Phases of the self-hosted SubX translator.
for app in hex survey pack assort dquotes tests
for app in hex survey_elf pack assort dquotes tests
do
echo $app
./translate_subx_emulated init.linux [01]*.subx apps/subx-params.subx apps/$app.subx

View File

@ -33,7 +33,7 @@ cat a.dquotes |apps/assort > a.assort2
cat a.assort2 |apps/pack > a.pack
cat a.pack |apps/survey > a.survey
cat a.pack |apps/survey_elf > a.survey
cat a.survey |apps/hex > a.elf

View File

@ -16,7 +16,7 @@ cat a.tests |./bootstrap_bin run apps/assort > a.assort
cat a.assort |./bootstrap_bin run apps/dquotes > a.dquotes
cat a.dquotes |./bootstrap_bin run apps/assort > a.assort2
cat a.assort2 |./bootstrap_bin run apps/pack > a.pack
cat a.pack |./bootstrap_bin run apps/survey > a.survey
cat a.pack |./bootstrap_bin run apps/survey_elf > a.survey
cat a.survey |./bootstrap_bin run apps/hex > a.elf
chmod +x a.elf