This commit is contained in:
Kartik K. Agaram 2021-07-20 08:41:57 -07:00
parent 13ef425825
commit d0f39e75ca
3 changed files with 46 additions and 46 deletions

View File

@ -1,8 +1,8 @@
# Repeatedly read 32-bit numbers from /dev/random, print them to stdout. # Repeatedly read 32-bit numbers from /dev/random, print them to stdout.
# #
# To run: # To run:
# $ bootstrap/bootstrap translate [01]*.subx random.subx -o random # $ ./translate_subx [01]*.subx apps/random.subx
# $ bootstrap/bootstrap run random # $ ./a.elf
== code 0x09000000 == code 0x09000000
# instruction effective address register displacement immediate # instruction effective address register displacement immediate

View File

@ -17,7 +17,7 @@ echo "== translating using the bootstrap C++ translator"
# example programs # example programs
echo ex1 echo ex1
bootstrap/bootstrap translate 000init.subx ex1.subx -o ex1 bootstrap/bootstrap translate 000init.subx apps/ex1.subx -o ex1
{ {
bootstrap/bootstrap run ex1 || ret=$? bootstrap/bootstrap run ex1 || ret=$?
test $ret -eq 42 # life, the universe and everything test $ret -eq 42 # life, the universe and everything
@ -29,7 +29,7 @@ bootstrap/bootstrap translate 000init.subx ex1.subx -o ex1
} }
echo ex2 echo ex2
bootstrap/bootstrap translate 000init.subx ex2.subx -o ex2 bootstrap/bootstrap translate 000init.subx apps/ex2.subx -o ex2
{ {
bootstrap/bootstrap run ex2 || ret=$? bootstrap/bootstrap run ex2 || ret=$?
test $ret -eq 7 # 3 + 4 test $ret -eq 7 # 3 + 4
@ -41,7 +41,7 @@ bootstrap/bootstrap translate 000init.subx ex2.subx -o ex2
} }
echo ex3 echo ex3
bootstrap/bootstrap translate 000init.subx ex3.subx -o ex3 bootstrap/bootstrap translate 000init.subx apps/ex3.subx -o ex3
{ {
bootstrap/bootstrap run ex3 || ret=$? bootstrap/bootstrap run ex3 || ret=$?
test $ret -eq 55 # 1 + 2 + ... + 10 test $ret -eq 55 # 1 + 2 + ... + 10
@ -53,7 +53,7 @@ bootstrap/bootstrap translate 000init.subx ex3.subx -o ex3
} }
echo ex4 echo ex4
bootstrap/bootstrap translate 000init.subx ex4.subx -o ex4 bootstrap/bootstrap translate 000init.subx apps/ex4.subx -o ex4
{ {
echo a | bootstrap/bootstrap run ex4 >ex4.out || true echo a | bootstrap/bootstrap run ex4 >ex4.out || true
test `cat ex4.out` = 'a' test `cat ex4.out` = 'a'
@ -65,7 +65,7 @@ bootstrap/bootstrap translate 000init.subx ex4.subx -o ex4
} }
echo ex5 echo ex5
bootstrap/bootstrap translate 000init.subx ex5.subx -o ex5 bootstrap/bootstrap translate 000init.subx apps/ex5.subx -o ex5
{ {
echo a | bootstrap/bootstrap run ex5 >ex5.out || true echo a | bootstrap/bootstrap run ex5 >ex5.out || true
test `cat ex5.out` = 'a' test `cat ex5.out` = 'a'
@ -77,7 +77,7 @@ bootstrap/bootstrap translate 000init.subx ex5.subx -o ex5
} }
echo ex6 echo ex6
bootstrap/bootstrap translate 000init.subx ex6.subx -o ex6 bootstrap/bootstrap translate 000init.subx apps/ex6.subx -o ex6
{ {
bootstrap/bootstrap run ex6 >ex6.out || true bootstrap/bootstrap run ex6 >ex6.out || true
test "`cat ex6.out`" = 'Hello world!' test "`cat ex6.out`" = 'Hello world!'
@ -89,7 +89,7 @@ bootstrap/bootstrap translate 000init.subx ex6.subx -o ex6
} }
echo ex7 echo ex7
bootstrap/bootstrap translate 000init.subx ex7.subx -o ex7 bootstrap/bootstrap translate 000init.subx apps/ex7.subx -o ex7
{ {
bootstrap/bootstrap run ex7 || ret=$? bootstrap/bootstrap run ex7 || ret=$?
test $ret -eq 97 # 'a' test $ret -eq 97 # 'a'
@ -101,7 +101,7 @@ bootstrap/bootstrap translate 000init.subx ex7.subx -o ex7
} }
echo ex8 echo ex8
bootstrap/bootstrap translate 000init.subx ex8.subx -o ex8 bootstrap/bootstrap translate 000init.subx apps/ex8.subx -o ex8
{ {
bootstrap/bootstrap run ex8 abcd || ret=$? bootstrap/bootstrap run ex8 abcd || ret=$?
test $ret -eq 4 # length('abcd') test $ret -eq 4 # length('abcd')
@ -113,7 +113,7 @@ bootstrap/bootstrap translate 000init.subx ex8.subx -o ex8
} }
echo ex9 echo ex9
bootstrap/bootstrap translate 000init.subx ex9.subx -o ex9 bootstrap/bootstrap translate 000init.subx apps/ex9.subx -o ex9
{ {
bootstrap/bootstrap run ex9 z x || ret=$? bootstrap/bootstrap run ex9 z x || ret=$?
test $ret -eq 2 # 'z' - 'x' test $ret -eq 2 # 'z' - 'x'
@ -125,7 +125,7 @@ bootstrap/bootstrap translate 000init.subx ex9.subx -o ex9
} }
echo ex10 echo ex10
bootstrap/bootstrap translate 000init.subx ex10.subx -o ex10 bootstrap/bootstrap translate 000init.subx apps/ex10.subx -o ex10
{ {
bootstrap/bootstrap run ex10 abc abc || ret=$? bootstrap/bootstrap run ex10 abc abc || ret=$?
test $ret -eq 1 # equal test $ret -eq 1 # equal
@ -139,7 +139,7 @@ bootstrap/bootstrap translate 000init.subx ex10.subx -o ex10
} }
echo ex11 echo ex11
bootstrap/bootstrap translate 000init.subx ex11.subx -o ex11 bootstrap/bootstrap translate 000init.subx apps/ex11.subx -o ex11
{ {
bootstrap/bootstrap run ex11 bootstrap/bootstrap run ex11
echo echo
@ -151,13 +151,13 @@ bootstrap/bootstrap translate 000init.subx ex11.subx -o ex11
} }
echo ex12 echo ex12
bootstrap/bootstrap translate 000init.subx ex12.subx -o ex12 bootstrap/bootstrap translate 000init.subx apps/ex12.subx -o ex12
bootstrap/bootstrap run ex12 # final byte of mmap'd address is well-nigh guaranteed to be 0 bootstrap/bootstrap run ex12 # final byte of mmap'd address is well-nigh guaranteed to be 0
chmod +x ex12 chmod +x ex12
./ex12 ./ex12
echo ex13 echo ex13
bootstrap/bootstrap translate 000init.subx ex13.subx -o ex13 bootstrap/bootstrap translate 000init.subx apps/ex13.subx -o ex13
{ {
bootstrap/bootstrap run ex13 || ret=$? bootstrap/bootstrap run ex13 || ret=$?
test $ret -eq 1 # 3 == 3 test $ret -eq 1 # 3 == 3
@ -171,7 +171,7 @@ bootstrap/bootstrap translate 000init.subx ex13.subx -o ex13
# Larger apps that use the standard library. # Larger apps that use the standard library.
echo factorial echo factorial
bootstrap/bootstrap translate [01]*.subx factorial.subx -o factorial bootstrap/bootstrap translate [01]*.subx apps/factorial.subx -o factorial
{ {
bootstrap/bootstrap run factorial || ret=$? bootstrap/bootstrap run factorial || ret=$?
test $ret -eq 120 # factorial(5) test $ret -eq 120 # factorial(5)
@ -187,7 +187,7 @@ bootstrap/bootstrap translate [01]*.subx factorial.subx -o factorial
} }
echo random echo random
bootstrap/bootstrap translate [01]*.subx random.subx -o random bootstrap/bootstrap translate [01]*.subx apps/random.subx -o random
# don't run # don't run
# Phases of the self-hosted SubX translator. # Phases of the self-hosted SubX translator.
@ -275,7 +275,7 @@ echo "== translating using the self-hosted translator"
for n in `seq 1 12` for n in `seq 1 12`
do do
echo ex$n echo ex$n
./translate_subx 000init.subx ex$n.subx ./translate_subx 000init.subx apps/ex$n.subx
diff ex$n a.elf diff ex$n a.elf
done done
@ -284,7 +284,7 @@ done
for app in factorial for app in factorial
do do
echo $app echo $app
./translate_subx [01]*.subx $app.subx ./translate_subx [01]*.subx apps/$app.subx
diff $app a.elf diff $app a.elf
done done
@ -312,7 +312,7 @@ diff mu a.elf
# Mu programs # Mu programs
echo ex1.mu echo ex1.mu
./translate ex1.mu ./translate apps/ex1.mu
{ {
bootstrap/bootstrap run a.elf || ret=$? bootstrap/bootstrap run a.elf || ret=$?
test $ret -eq 42 # life, the universe and everything test $ret -eq 42 # life, the universe and everything
@ -323,7 +323,7 @@ echo ex1.mu
} }
echo ex2.mu echo ex2.mu
./translate ex2.mu ./translate apps/ex2.mu
{ {
bootstrap/bootstrap run a.elf || ret=$? bootstrap/bootstrap run a.elf || ret=$?
test $ret -eq 7 test $ret -eq 7
@ -334,7 +334,7 @@ echo ex2.mu
} }
echo ex3.mu echo ex3.mu
./translate ex3.mu ./translate apps/ex3.mu
{ {
bootstrap/bootstrap run a.elf || ret=$? bootstrap/bootstrap run a.elf || ret=$?
test $ret -eq 55 test $ret -eq 55
@ -345,7 +345,7 @@ echo ex3.mu
} }
echo ex3.2.mu echo ex3.2.mu
./translate ex3.2.mu ./translate apps/ex3.2.mu
{ {
bootstrap/bootstrap run a.elf || ret=$? bootstrap/bootstrap run a.elf || ret=$?
test $ret -eq 55 test $ret -eq 55
@ -356,7 +356,7 @@ echo ex3.2.mu
} }
echo factorial.mu echo factorial.mu
./translate factorial.mu ./translate apps/factorial.mu
{ {
bootstrap/bootstrap run a.elf || ret=$? bootstrap/bootstrap run a.elf || ret=$?
test $ret -eq 120 test $ret -eq 120

View File

@ -18,70 +18,70 @@ echo "== translating using the bootstrap C++ translator"
# example programs # example programs
echo ex1 echo ex1
bootstrap/bootstrap translate 000init.subx ex1.subx -o ex1 bootstrap/bootstrap translate 000init.subx apps/ex1.subx -o ex1
{ {
bootstrap/bootstrap run ex1 || ret=$? bootstrap/bootstrap run ex1 || ret=$?
test $ret -eq 42 # life, the universe and everything test $ret -eq 42 # life, the universe and everything
} }
echo ex2 echo ex2
bootstrap/bootstrap translate 000init.subx ex2.subx -o ex2 bootstrap/bootstrap translate 000init.subx apps/ex2.subx -o ex2
{ {
bootstrap/bootstrap run ex2 || ret=$? bootstrap/bootstrap run ex2 || ret=$?
test $ret -eq 7 # 3 + 4 test $ret -eq 7 # 3 + 4
} }
echo ex3 echo ex3
bootstrap/bootstrap translate 000init.subx ex3.subx -o ex3 bootstrap/bootstrap translate 000init.subx apps/ex3.subx -o ex3
{ {
bootstrap/bootstrap run ex3 || ret=$? bootstrap/bootstrap run ex3 || ret=$?
test $ret -eq 55 # 1 + 2 + ... + 10 test $ret -eq 55 # 1 + 2 + ... + 10
} }
echo ex4 echo ex4
bootstrap/bootstrap translate 000init.subx ex4.subx -o ex4 bootstrap/bootstrap translate 000init.subx apps/ex4.subx -o ex4
{ {
echo a | bootstrap/bootstrap run ex4 >ex4.out || true echo a | bootstrap/bootstrap run ex4 >ex4.out || true
test `cat ex4.out` = 'a' test `cat ex4.out` = 'a'
} }
echo ex5 echo ex5
bootstrap/bootstrap translate 000init.subx ex5.subx -o ex5 bootstrap/bootstrap translate 000init.subx apps/ex5.subx -o ex5
{ {
echo a | bootstrap/bootstrap run ex5 >ex5.out || true echo a | bootstrap/bootstrap run ex5 >ex5.out || true
test `cat ex5.out` = 'a' test `cat ex5.out` = 'a'
} }
echo ex6 echo ex6
bootstrap/bootstrap translate 000init.subx ex6.subx -o ex6 bootstrap/bootstrap translate 000init.subx apps/ex6.subx -o ex6
{ {
bootstrap/bootstrap run ex6 >ex6.out || true bootstrap/bootstrap run ex6 >ex6.out || true
test "`cat ex6.out`" = 'Hello world!' test "`cat ex6.out`" = 'Hello world!'
} }
echo ex7 echo ex7
bootstrap/bootstrap translate 000init.subx ex7.subx -o ex7 bootstrap/bootstrap translate 000init.subx apps/ex7.subx -o ex7
{ {
bootstrap/bootstrap run ex7 || ret=$? bootstrap/bootstrap run ex7 || ret=$?
test $ret -eq 97 # 'a' test $ret -eq 97 # 'a'
} }
echo ex8 echo ex8
bootstrap/bootstrap translate 000init.subx ex8.subx -o ex8 bootstrap/bootstrap translate 000init.subx apps/ex8.subx -o ex8
{ {
bootstrap/bootstrap run ex8 abcd || ret=$? bootstrap/bootstrap run ex8 abcd || ret=$?
test $ret -eq 4 # length('abcd') test $ret -eq 4 # length('abcd')
} }
echo ex9 echo ex9
bootstrap/bootstrap translate 000init.subx ex9.subx -o ex9 bootstrap/bootstrap translate 000init.subx apps/ex9.subx -o ex9
{ {
bootstrap/bootstrap run ex9 z x || ret=$? bootstrap/bootstrap run ex9 z x || ret=$?
test $ret -eq 2 # 'z' - 'x' test $ret -eq 2 # 'z' - 'x'
} }
echo ex10 echo ex10
bootstrap/bootstrap translate 000init.subx ex10.subx -o ex10 bootstrap/bootstrap translate 000init.subx apps/ex10.subx -o ex10
{ {
bootstrap/bootstrap run ex10 abc abc || ret=$? bootstrap/bootstrap run ex10 abc abc || ret=$?
test $ret -eq 1 # equal test $ret -eq 1 # equal
@ -89,18 +89,18 @@ bootstrap/bootstrap translate 000init.subx ex10.subx -o ex10
} }
echo ex11 echo ex11
bootstrap/bootstrap translate 000init.subx ex11.subx -o ex11 bootstrap/bootstrap translate 000init.subx apps/ex11.subx -o ex11
{ {
bootstrap/bootstrap run ex11 bootstrap/bootstrap run ex11
echo echo
} }
echo ex12 echo ex12
bootstrap/bootstrap translate 000init.subx ex12.subx -o ex12 bootstrap/bootstrap translate 000init.subx apps/ex12.subx -o ex12
bootstrap/bootstrap run ex12 # final byte of mmap'd address is well-nigh guaranteed to be 0 bootstrap/bootstrap run ex12 # final byte of mmap'd address is well-nigh guaranteed to be 0
echo ex13 echo ex13
bootstrap/bootstrap translate 000init.subx ex13.subx -o ex13 bootstrap/bootstrap translate 000init.subx apps/ex13.subx -o ex13
{ {
bootstrap/bootstrap run ex13 || ret=$? bootstrap/bootstrap run ex13 || ret=$?
test $ret -eq 1 # 3 == 3 test $ret -eq 1 # 3 == 3
@ -109,7 +109,7 @@ bootstrap/bootstrap translate 000init.subx ex13.subx -o ex13
# Larger apps that use the standard library. # Larger apps that use the standard library.
echo factorial echo factorial
bootstrap/bootstrap translate [01]*.subx factorial.subx -o factorial bootstrap/bootstrap translate [01]*.subx apps/factorial.subx -o factorial
{ {
bootstrap/bootstrap run factorial || ret=$? bootstrap/bootstrap run factorial || ret=$?
test $ret -eq 120 # factorial(5) test $ret -eq 120 # factorial(5)
@ -118,7 +118,7 @@ bootstrap/bootstrap translate [01]*.subx factorial.subx -o factorial
} }
echo random echo random
bootstrap/bootstrap translate [01]*.subx random.subx -o random bootstrap/bootstrap translate [01]*.subx apps/random.subx -o random
# don't run # don't run
# Phases of the self-hosted SubX translator. # Phases of the self-hosted SubX translator.
@ -182,7 +182,7 @@ echo "== translating using the self-hosted translator"
for n in `seq 1 12` for n in `seq 1 12`
do do
echo ex$n echo ex$n
./translate_subx_emulated 000init.subx ex$n.subx ./translate_subx_emulated 000init.subx apps/ex$n.subx
diff ex$n a.elf diff ex$n a.elf
done done
@ -191,7 +191,7 @@ done
for app in factorial for app in factorial
do do
echo $app echo $app
./translate_subx_emulated [01]*.subx $app.subx ./translate_subx_emulated [01]*.subx apps/$app.subx
diff $app a.elf diff $app a.elf
done done
@ -219,35 +219,35 @@ diff mu a.elf
# Mu programs # Mu programs
echo ex1.mu echo ex1.mu
./translate_emulated ex1.mu ./translate_emulated apps/ex1.mu
{ {
bootstrap/bootstrap run a.elf || ret=$? bootstrap/bootstrap run a.elf || ret=$?
test $ret -eq 42 # life, the universe and everything test $ret -eq 42 # life, the universe and everything
} }
echo ex2.mu echo ex2.mu
./translate_emulated ex2.mu ./translate_emulated apps/ex2.mu
{ {
bootstrap/bootstrap run a.elf || ret=$? bootstrap/bootstrap run a.elf || ret=$?
test $ret -eq 7 test $ret -eq 7
} }
echo ex3.mu echo ex3.mu
./translate_emulated ex3.mu ./translate_emulated apps/ex3.mu
{ {
bootstrap/bootstrap run a.elf || ret=$? bootstrap/bootstrap run a.elf || ret=$?
test $ret -eq 55 test $ret -eq 55
} }
echo ex3.2.mu echo ex3.2.mu
./translate_emulated ex3.2.mu ./translate_emulated apps/ex3.2.mu
{ {
bootstrap/bootstrap run a.elf || ret=$? bootstrap/bootstrap run a.elf || ret=$?
test $ret -eq 55 test $ret -eq 55
} }
echo factorial.mu echo factorial.mu
./translate_emulated factorial.mu ./translate_emulated apps/factorial.mu
{ {
bootstrap/bootstrap run a.elf || ret=$? bootstrap/bootstrap run a.elf || ret=$?
test $ret -eq 120 test $ret -eq 120