about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-07-17 23:04:45 -0700
committerKartik Agaram <vc@akkartik.com>2019-07-17 23:04:45 -0700
commit5030d67c85f63fc09ee506a90394c50f2db4f3be (patch)
tree4b24be1d2d510b787ad52481e123df5c2021a604 /subx
parent7fe1e2434911d682f9ac5358c8cabbaab7964084 (diff)
downloadmu-5030d67c85f63fc09ee506a90394c50f2db4f3be.tar.gz
5415
Bugfix thirteen: displacement calculations were wrong because current
offset was not being updated properly as words were being read and
emitted.

Now 10/12 example programs are translated correctly.
Diffstat (limited to 'subx')
-rw-r--r--subx/Readme.md12
-rwxr-xr-xsubx/apps/surveybin41174 -> 41174 bytes
-rw-r--r--subx/apps/survey.subx4
-rwxr-xr-xsubx/test_apps48
4 files changed, 56 insertions, 8 deletions
diff --git a/subx/Readme.md b/subx/Readme.md
index 171e04b5..f505d9ce 100644
--- a/subx/Readme.md
+++ b/subx/Readme.md
@@ -340,16 +340,16 @@ runnable on a Linux system running on Intel x86 processors, either 32- or
 * Bootstrapping a SubX-\>ELF translator in SubX
   ✓ examples/ex1
   ✓ examples/ex2
-  - examples/ex3
+  ✓ examples/ex3
   ✓ examples/ex4
-  - examples/ex5
+  ✓ examples/ex5
   - examples/ex6
   ✓ examples/ex7
-  - examples/ex8
-  - examples/ex9
-  - examples/ex10
+  ✓ examples/ex8
+  ✓ examples/ex9
+  ✓ examples/ex10
   - examples/ex11
-  - examples/ex12
+  ✓ examples/ex12
   - apps/factorial.subx
   - apps/crenshaw2-1.subx
   - apps/crenshaw2-1b.subx
diff --git a/subx/apps/survey b/subx/apps/survey
index 6971e511..61e2f974 100755
--- a/subx/apps/survey
+++ b/subx/apps/survey
Binary files differdiff --git a/subx/apps/survey.subx b/subx/apps/survey.subx
index bc96fe14..d868132a 100644
--- a/subx/apps/survey.subx
+++ b/subx/apps/survey.subx
@@ -1884,8 +1884,8 @@ $emit-segments:check0:
     e8/call  num-bytes/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
-    # . EBX = EAX
-    89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EBX
+    # . EBX += EAX
+    01/add                          3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # add EAX to EBX
 $emit-segments:word-loop:
     # next-word(line, word-slice)
     # . . push args
diff --git a/subx/test_apps b/subx/test_apps
index ff75ce89..cc0f301f 100755
--- a/subx/test_apps
+++ b/subx/test_apps
@@ -240,16 +240,64 @@ test `uname` = 'Linux'  &&  {
   cat examples/ex2.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex2 -
 }
 
+echo ex3
+cat examples/ex3.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/ex3 -
+test `uname` = 'Linux'  &&  {
+  cat examples/ex3.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex3 -
+}
+
 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 ex5
+cat examples/ex5.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/ex5 -
+test `uname` = 'Linux'  &&  {
+  cat examples/ex5.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex5 -
+}
+
+#? echo ex6
+#? cat examples/ex6.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/ex6 -
+#? test `uname` = 'Linux'  &&  {
+#?   cat examples/ex6.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex6 -
+#? }
+
 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 -
 }
 
+echo ex8
+cat examples/ex8.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/ex8 -
+test `uname` = 'Linux'  &&  {
+  cat examples/ex8.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex8 -
+}
+
+echo ex9
+cat examples/ex9.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/ex9 -
+test `uname` = 'Linux'  &&  {
+  cat examples/ex9.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex9 -
+}
+
+echo ex10
+cat examples/ex10.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/ex10 -
+test `uname` = 'Linux'  &&  {
+  cat examples/ex10.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex10 -
+}
+
+#? echo ex11
+#? cat examples/ex11.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/ex11 -
+#? test `uname` = 'Linux'  &&  {
+#?   cat examples/ex11.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex11 -
+#? }
+
+echo ex12
+cat examples/ex12.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/ex12 -
+test `uname` = 'Linux'  &&  {
+  cat examples/ex12.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex12 -
+}
+
 exit 0