about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
Diffstat (limited to 'subx')
-rw-r--r--subx/Readme.md23
-rwxr-xr-xsubx/examples/ex10bin163 -> 195 bytes
-rw-r--r--subx/examples/ex10.subx2
-rw-r--r--subx/examples/ex12.subx1
-rwxr-xr-xsubx/examples/ex2bin97 -> 129 bytes
-rw-r--r--subx/examples/ex2.subx3
-rwxr-xr-xsubx/examples/ex3bin114 -> 146 bytes
-rw-r--r--subx/examples/ex3.subx3
-rw-r--r--subx/examples/ex4.subx1
-rwxr-xr-xsubx/examples/ex5bin139 -> 171 bytes
-rw-r--r--subx/examples/ex5.subx2
-rw-r--r--subx/examples/ex6.subx1
-rw-r--r--subx/examples/ex7.subx1
-rwxr-xr-xsubx/examples/ex8bin133 -> 165 bytes
-rw-r--r--subx/examples/ex8.subx3
-rwxr-xr-xsubx/examples/ex9bin127 -> 159 bytes
-rw-r--r--subx/examples/ex9.subx3
-rwxr-xr-xsubx/test_apps42
18 files changed, 72 insertions, 13 deletions
diff --git a/subx/Readme.md b/subx/Readme.md
index 5d294629..8aaa528f 100644
--- a/subx/Readme.md
+++ b/subx/Readme.md
@@ -337,7 +337,28 @@ runnable on a Linux system running on Intel x86 processors, either 32- or
 
 ## Roadmap and status
 
-* Bootstrapping a SubX-\>ELF translator in SubX (90% complete; now in testing)
+* Bootstrapping a SubX-\>ELF translator in SubX
+  - examples/ex1 ✓
+  - examples/ex2 ✓
+  - examples/ex3
+  - examples/ex4 ✓
+  - examples/ex5
+  - examples/ex6
+  - examples/ex7 ✓
+  - examples/ex8
+  - examples/ex9
+  - examples/ex10
+  - examples/ex11
+  - examples/ex12
+  - apps/factorial.subx
+  - apps/crenshaw2-1.subx
+  - apps/crenshaw2-1b.subx
+  - apps/handle.subx
+  - apps/hex.subx
+  - apps/survey.subx
+  - apps/pack.subx
+  - apps/assort.subx
+  - apps/dquotes.subx
 
 * Testable, dependency-injected vocabulary of primitives
   - Streams: `read()`, `write()`. (✓)
diff --git a/subx/examples/ex10 b/subx/examples/ex10
index 9cdfb983..d8ad528e 100755
--- a/subx/examples/ex10
+++ b/subx/examples/ex10
Binary files differdiff --git a/subx/examples/ex10.subx b/subx/examples/ex10.subx
index fd2ccc08..51cc0a8c 100644
--- a/subx/examples/ex10.subx
+++ b/subx/examples/ex10.subx
@@ -67,4 +67,6 @@ $argv-equal:false:
     b8/copy-to-EAX  0/imm32
     c3/return
 
+== data 0x0a000000
+
 # . . vim:nowrap:textwidth=0
diff --git a/subx/examples/ex12.subx b/subx/examples/ex12.subx
index 4d43b033..358da1d3 100644
--- a/subx/examples/ex12.subx
+++ b/subx/examples/ex12.subx
@@ -11,6 +11,7 @@
 # . op          subop               mod             rm32          base        index         scale       r32
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
+Entry:
     # syscall(mmap, 0x1000)
     bb/copy-to-EBX  Mmap-new-segment/imm32
     b8/copy-to-EAX  0x5a/imm32/mmap
diff --git a/subx/examples/ex2 b/subx/examples/ex2
index f7ddb783..55a87a3f 100755
--- a/subx/examples/ex2
+++ b/subx/examples/ex2
Binary files differdiff --git a/subx/examples/ex2.subx b/subx/examples/ex2.subx
index 3605fcc8..025eb0fa 100644
--- a/subx/examples/ex2.subx
+++ b/subx/examples/ex2.subx
@@ -9,6 +9,7 @@
 
 == code 0x09000000
 
+Entry:
 # EBX = 1
 bb/copy-to-EBX  1/imm32
 # increment EBX
@@ -17,4 +18,6 @@ bb/copy-to-EBX  1/imm32
 b8/copy-to-EAX  1/imm32/exit
 cd/syscall  0x80/imm8
 
+== data 0x0a000000
+
 # . . vim:nowrap:textwidth=0
diff --git a/subx/examples/ex3 b/subx/examples/ex3
index 884da188..d85aba8e 100755
--- a/subx/examples/ex3
+++ b/subx/examples/ex3
Binary files differdiff --git a/subx/examples/ex3.subx b/subx/examples/ex3.subx
index c9ad3e38..1d52e87f 100644
--- a/subx/examples/ex3.subx
+++ b/subx/examples/ex3.subx
@@ -12,6 +12,7 @@
 # . op          subop               mod             rm32          base        index         scale       r32
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
+Entry:
     # result: EBX = 0
     bb/copy-to-EBX  0/imm32
     # counter: ECX = 1
@@ -33,4 +34,6 @@ $exit:
     b8/copy-to-EAX  1/imm32/exit
     cd/syscall  0x80/imm8
 
+== data 0x0a000000
+
 # . . vim:nowrap:textwidth=0
diff --git a/subx/examples/ex4.subx b/subx/examples/ex4.subx
index a1f042ed..31c1c10c 100644
--- a/subx/examples/ex4.subx
+++ b/subx/examples/ex4.subx
@@ -12,6 +12,7 @@ X:
 
 == code 0x09000000
 
+Entry:
 # syscall(read, stdin, X, 1)
 # . fd = 0 (stdin)
 bb/copy-to-EBX  0/imm32
diff --git a/subx/examples/ex5 b/subx/examples/ex5
index 090e1f60..37689c98 100755
--- a/subx/examples/ex5
+++ b/subx/examples/ex5
Binary files differdiff --git a/subx/examples/ex5.subx b/subx/examples/ex5.subx
index f051a91f..6f5b1d90 100644
--- a/subx/examples/ex5.subx
+++ b/subx/examples/ex5.subx
@@ -40,4 +40,6 @@ Entry:
     b8/copy-to-EAX  1/imm32/exit
     cd/syscall  0x80/imm8
 
+== data 0x0a000000
+
 # . . vim:nowrap:textwidth=0
diff --git a/subx/examples/ex6.subx b/subx/examples/ex6.subx
index c5999033..a90f11df 100644
--- a/subx/examples/ex6.subx
+++ b/subx/examples/ex6.subx
@@ -10,6 +10,7 @@
 # . op          subop               mod             rm32          base        index         scale       r32
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
+Entry:
     # syscall(write, stdout, X, Size)
     # . fd = 1 (stdout)
     bb/copy-to-EBX  1/imm32
diff --git a/subx/examples/ex7.subx b/subx/examples/ex7.subx
index ee043c86..d3b33f23 100644
--- a/subx/examples/ex7.subx
+++ b/subx/examples/ex7.subx
@@ -16,6 +16,7 @@
 # . op          subop               mod             rm32          base        index         scale       r32
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
+Entry:
     # syscall(creat, Filename)
     bb/copy-to-EBX  Filename/imm32
     b9/copy-to-ECX  0x180/imm32/fixed-perms
diff --git a/subx/examples/ex8 b/subx/examples/ex8
index fcbf4fcf..5be0e1e6 100755
--- a/subx/examples/ex8
+++ b/subx/examples/ex8
Binary files differdiff --git a/subx/examples/ex8.subx b/subx/examples/ex8.subx
index 85fe1568..9d7255e1 100644
--- a/subx/examples/ex8.subx
+++ b/subx/examples/ex8.subx
@@ -19,6 +19,7 @@
 # . op          subop               mod             rm32          base        index         scale       r32
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
+Entry:
     # . prolog
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
     # EAX = ascii-length(argv[1])
@@ -55,4 +56,6 @@ $ascii-length:end:
     # return EAX
     c3/return
 
+== data 0x0a000000
+
 # . . vim:nowrap:textwidth=0
diff --git a/subx/examples/ex9 b/subx/examples/ex9
index ffbea21b..fce7629c 100755
--- a/subx/examples/ex9
+++ b/subx/examples/ex9
Binary files differdiff --git a/subx/examples/ex9.subx b/subx/examples/ex9.subx
index 344c62ae..e3318b05 100644
--- a/subx/examples/ex9.subx
+++ b/subx/examples/ex9.subx
@@ -22,6 +22,7 @@
 # . op          subop               mod             rm32          base        index         scale       r32
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
+Entry:
     # . prolog
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
     # ascii-difference(argv[1], argv[2])
@@ -49,4 +50,6 @@ ascii-difference:  # (s1, s2) : null-terminated ascii strings
     29/subtract                     3/mod/direct    0/rm32/EAX    .           .             .           1/r32/ECX   .               .                 # subtract ECX from EAX
     c3/return
 
+== data 0x0a000000
+
 # . . vim:nowrap:textwidth=0
diff --git a/subx/test_apps b/subx/test_apps
index 068712a7..3c64c712 100755
--- a/subx/test_apps
+++ b/subx/test_apps
@@ -130,18 +130,6 @@ echo ex12
 ./subx run examples/ex12  # final byte of mmap'd address is well-nigh guaranteed to be 0
 test `uname` = 'Linux'  &&  examples/ex12
 
-echo handle
-./subx translate 0*.subx apps/handle.subx  -o apps/handle
-[ "$1" != record ]  &&  git diff --exit-code apps/handle
-./subx run apps/handle > handle.out 2>&1  ||  true
-grep -q 'lookup succeeded' handle.out  ||  { echo "missing success test"; exit 1; }
-grep -q 'lookup failed' handle.out  ||  { echo "missing failure test"; exit 1; }
-test `uname` = 'Linux'  &&  {
-  apps/handle > handle.out 2>&1  ||  true
-  grep -q 'lookup succeeded' handle.out  ||  { echo "missing success test"; exit 1; }
-  grep -q 'lookup failed' handle.out  ||  { echo "missing failure test"; exit 1; }
-}
-
 echo factorial
 ./subx translate 0*.subx apps/factorial.subx  -o apps/factorial
 [ "$1" != record ]  &&  git diff --exit-code apps/factorial
@@ -176,6 +164,18 @@ test `uname` = 'Linux'  &&  {
   echo
 }
 
+echo handle
+./subx translate 0*.subx apps/handle.subx  -o apps/handle
+[ "$1" != record ]  &&  git diff --exit-code apps/handle
+./subx run apps/handle > handle.out 2>&1  ||  true
+grep -q 'lookup succeeded' handle.out  ||  { echo "missing success test"; exit 1; }
+grep -q 'lookup failed' handle.out  ||  { echo "missing failure test"; exit 1; }
+test `uname` = 'Linux'  &&  {
+  apps/handle > handle.out 2>&1  ||  true
+  grep -q 'lookup succeeded' handle.out  ||  { echo "missing success test"; exit 1; }
+  grep -q 'lookup failed' handle.out  ||  { echo "missing failure test"; exit 1; }
+}
+
 echo hex
 ./subx translate 0*.subx apps/hex.subx  -o apps/hex
 [ "$1" != record ]  &&  git diff --exit-code apps/hex
@@ -234,4 +234,22 @@ test `uname` = 'Linux'  &&  {
   cat examples/ex1.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex1 -
 }
 
+echo ex2
+cat examples/ex2.subx |subx_bin run apps/dquotes |subx_bin run apps/assort |subx_bin run apps/pack |subx_bin run apps/survey |subx_bin run apps/hex |diff examples/ex2 -
+test `uname` = 'Linux'  &&  {
+  cat examples/ex2.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex2 -
+}
+
+echo ex4
+cat examples/ex4.subx |subx_bin run apps/dquotes |subx_bin run apps/assort |subx_bin run apps/pack |subx_bin run apps/survey |subx_bin run apps/hex |diff examples/ex4 -
+test `uname` = 'Linux'  &&  {
+  cat examples/ex4.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex4 -
+}
+
+echo ex7
+cat examples/ex7.subx |subx_bin run apps/dquotes |subx_bin run apps/assort |subx_bin run apps/pack |subx_bin run apps/survey |subx_bin run apps/hex |diff examples/ex7 -
+test `uname` = 'Linux'  &&  {
+  cat examples/ex7.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex7 -
+}
+
 exit 0