about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-04-11 01:19:22 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-18 00:44:46 -0700
commit27cced79be369784b0130c2cdc042c55c20ab593 (patch)
tree6cdf71a1252ed758d17d33e2977d7a223c88e017
parentf7360e493ac7e4d3fc27a1823db0ba62ef271433 (diff)
downloadmu-27cced79be369784b0130c2cdc042c55c20ab593.tar.gz
all syntax sugar now working
I just needed to adjust row-sizes when accessing the Registers table.

This commit dedicated to a fun hour on https://hn.town.siempre.io. Thanks
Cyrus!
(via https://news.ycombinator.com/item?id=22818300)
-rwxr-xr-xapps/bracesbin42676 -> 45973 bytes
-rwxr-xr-xapps/callsbin47337 -> 50634 bytes
-rwxr-xr-xapps/sigilsbin55061 -> 58358 bytes
-rw-r--r--apps/sigils.subx48
-rwxr-xr-xtest_apps120
5 files changed, 96 insertions, 72 deletions
diff --git a/apps/braces b/apps/braces
index 59a7abfd..a79cfb55 100755
--- a/apps/braces
+++ b/apps/braces
Binary files differdiff --git a/apps/calls b/apps/calls
index 815c1a3d..240972dd 100755
--- a/apps/calls
+++ b/apps/calls
Binary files differdiff --git a/apps/sigils b/apps/sigils
index 4879cb36..9f33941e 100755
--- a/apps/sigils
+++ b/apps/sigils
Binary files differdiff --git a/apps/sigils.subx b/apps/sigils.subx
index 93ca612a..fd973fab 100644
--- a/apps/sigils.subx
+++ b/apps/sigils.subx
@@ -1373,6 +1373,30 @@ emit-direct-mode:  # out: (addr buffered-file), word-slice: (addr slice)
     # ++local-slice->start to skip '%'
     # . ++(*eax)
     ff          0/subop/increment   0/mod/indirect  0/rm32/eax    .           .             .           .           .               .                 # increment *eax
+#?     # write-slice-buffered(Stderr, word-slice) {{{
+#?     # . . push args
+#?     50/push-eax
+#?     68/push  Stderr/imm32
+#?     # . . call
+#?     e8/call  write-slice-buffered/disp32
+#?     # . . discard args
+#?     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
+#?     # . flush(Stderr)
+#?     # . . push args
+#?     68/push  Stderr/imm32
+#?     # . . call
+#?     e8/call  flush/disp32
+#?     # . . discard args
+#?     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               4/imm32           # add to esp
+#?     # . write(2/stderr, "$\n")
+#?     # . . push args
+#?     68/push  "$\n"/imm32
+#?     68/push  2/imm32/stderr
+#?     # . . call
+#?     e8/call  write/disp32
+#?     # . . discard args
+#?     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
+#?     # }}}
     # local-slice = next-token-from-slice(local-slice->start, local-slice->end, "/")
     # . . push args
     50/push-eax
@@ -1383,10 +1407,10 @@ emit-direct-mode:  # out: (addr buffered-file), word-slice: (addr slice)
     e8/call  next-token-from-slice/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # add to esp
-    # reg-num/eax = get-slice(Registers, local-slice, row-size=8)
+    # reg-num/eax = get-slice(Registers, local-slice, row-size=12)
     # . . push args
     68/push  "Registers"/imm32
-    68/push  8/imm32/row-size
+    68/push  0xc/imm32/row-size
     50/push-eax
     68/push  Registers/imm32
     # . . call
@@ -2214,7 +2238,7 @@ parse-effective-address:  # word-slice: (addr slice) -> base/eax, index/ecx, sca
     #   initialize defaults: base=0, index=4, scale=0, disp=0
     #   if (*local-slice->start != '(') {
     #     local-slice = next-token-from-slice(local-slice->start, local-slice->end, "/")
-    #     base = get-slice(Registers, local-slice, row-size=8)
+    #     base = get-slice(Registers, local-slice, row-size=12)
     #     return
     #   }
     #   # compound expressions
@@ -2281,11 +2305,11 @@ $parse-effective-address:simple-register:
     e8/call  next-token-from-slice/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # add to esp
-    # base = get-slice(Registers, local-slice, row-size=8)
-    # . eax = get-slice(Registers, local-slice, row-size=8)
+    # base = get-slice(Registers, local-slice, row-size=12)
+    # . eax = get-slice(Registers, local-slice, row-size=12)
     # . . push args
     68/push  "Registers"/imm32
-    68/push  8/imm32/row-size
+    68/push  0xc/imm32/row-size
     56/push-esi
     68/push  Registers/imm32
     # . . call
@@ -2370,9 +2394,9 @@ $parse-effective-address:resolve-ambiguity:
     51/push-ecx
     # . . copy esp to ecx
     89/copy                         3/mod/direct    1/rm32/ecx    .           .             .           4/r32/esp   .               .                 # copy esp to ecx
-    # . eax = maybe-get-slice(Register, tmp, row-size=8)
+    # . eax = maybe-get-slice(Register, tmp, row-size=12)
     # . . push args
-    68/push  8/imm32/row-size
+    68/push  0xc/imm32/row-size
     51/push-ecx
     68/push  Registers/imm32
     # . . call
@@ -2687,10 +2711,10 @@ next-register:  # in: (addr slice) -> reg/eax: int
     89/copy                         3/mod/direct    1/rm32/ecx    .           .             .           4/r32/esp   .               .                 # copy esp to ecx
     # in->start += 3
     81          0/subop/add         0/mod/indirect  6/rm32/esi    .           .             .           .           .               3/imm32           # add to *esi
-    # eax = get-slice(Registers, reg-slice, row-size=8)
+    # eax = get-slice(Registers, reg-slice, row-size=12)
     # . . push args
     68/push  "next-register"/imm32
-    68/push  8/imm32/row-size
+    68/push  0xc/imm32/row-size
     51/push-ecx
     68/push  Registers/imm32
     # . . call
@@ -3889,9 +3913,9 @@ $disp32-mode?:check-for-register:
     e8/call  next-token-from-slice/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # add to esp
-    # reg-num/eax = maybe-get-slice(Registers, local-slice, row-size=8)
+    # reg-num/eax = maybe-get-slice(Registers, local-slice, row-size=12)
     # . . push args
-    68/push  8/imm32/row-size
+    68/push  0xc/imm32/row-size
     56/push-esi
     68/push  Registers/imm32
     # . . cal
diff --git a/test_apps b/test_apps
index e6276cb7..6a637fcd 100755
--- a/test_apps
+++ b/test_apps
@@ -238,50 +238,50 @@ do
   }
 done
 
-#? # Higher-level syntax.
-#? 
-#? # Certain phases of translation run native beyond this point. We're starting
-#? # to go beyond functionality of the C++ bootstrap.
-#? 
-#? echo sigils
-#? ./bootstrap translate init.$OS 0*.subx apps/subx-params.subx apps/sigils.subx  -o apps/sigils
-#? [ "$1" != record ]  &&  git diff --exit-code apps/sigils
-#? test $EMULATED  &&  {
-#?   ./bootstrap run apps/sigils test
-#?   echo
-#? }
-#? test `uname` = 'Linux'  &&  {
-#?   apps/sigils test
-#?   echo
-#? }
-#? 
-#? test $NATIVE  ||  { echo 'there are more tests, but you need Linux to run them'; exit 0; }
-#? 
-#? echo calls
-#? cat init.$OS 0*.subx apps/subx-params.subx apps/calls.subx  |  apps/sigils  > a.sigils
-#? ./bootstrap translate a.sigils -o apps/calls
-#? [ "$1" != record ]  &&  git diff --exit-code apps/calls
-#? test $EMULATED  &&  {
-#?   ./bootstrap run apps/calls test
-#?   echo
-#? }
-#? test `uname` = 'Linux'  &&  {
-#?   apps/calls test
-#?   echo
-#? }
-#? 
-#? echo braces
-#? cat init.$OS 0*.subx apps/subx-params.subx apps/braces.subx  |  apps/calls  |  apps/sigils  > a.sigils
-#? ./bootstrap translate a.sigils -o apps/braces
-#? [ "$1" != record ]  &&  git diff --exit-code apps/braces
-#? test $EMULATED  &&  {
-#?   ./bootstrap run apps/braces test
-#?   echo
-#? }
-#? test `uname` = 'Linux'  &&  {
-#?   apps/braces test
-#?   echo
-#? }
+# Higher-level syntax.
+
+# Certain phases of translation run native beyond this point. We're starting
+# to go beyond functionality of the C++ bootstrap.
+
+echo sigils
+./bootstrap translate init.$OS 0*.subx apps/subx-params.subx apps/sigils.subx  -o apps/sigils
+[ "$1" != record ]  &&  git diff --exit-code apps/sigils
+test $EMULATED  &&  {
+  ./bootstrap run apps/sigils test
+  echo
+}
+test `uname` = 'Linux'  &&  {
+  apps/sigils test
+  echo
+}
+
+test $NATIVE  ||  { echo 'there are more tests, but you need Linux to run them'; exit 0; }
+
+echo calls
+cat init.$OS 0*.subx apps/subx-params.subx apps/calls.subx  |  apps/sigils  > a.sigils
+./bootstrap translate a.sigils -o apps/calls
+[ "$1" != record ]  &&  git diff --exit-code apps/calls
+test $EMULATED  &&  {
+  ./bootstrap run apps/calls test
+  echo
+}
+test `uname` = 'Linux'  &&  {
+  apps/calls test
+  echo
+}
+
+echo braces
+cat init.$OS 0*.subx apps/subx-params.subx apps/braces.subx  |  apps/calls  |  apps/sigils  > a.sigils
+./bootstrap translate a.sigils -o apps/braces
+[ "$1" != record ]  &&  git diff --exit-code apps/braces
+test $EMULATED  &&  {
+  ./bootstrap run apps/braces test
+  echo
+}
+test `uname` = 'Linux'  &&  {
+  apps/braces test
+  echo
+}
 
 #? echo mu
 #? cat init.$OS [0-9]*.subx apps/mu.subx  |  apps/braces  |  apps/calls  |  apps/sigils  > a.sigils
@@ -317,22 +317,22 @@ do
   diff apps/$app a.elf
 done
 
-#? # Phases of the self-hosted SubX translator.
-#? 
-#? for app in hex survey pack assort dquotes tests
-#? do
-#?   echo $app
-#?   ./translate_subx init.$OS 0[0-8]*.subx apps/subx-params.subx apps/$app.subx
-#?   diff apps/$app a.elf
-#? done
-#? 
-#? for app in sigils calls braces
-#? do
-#?   echo $app
-#?   ./translate_subx init.$OS 0*.subx apps/subx-params.subx apps/$app.subx
-#?   diff apps/$app a.elf
-#? done
-#? 
+# Phases of the self-hosted SubX translator.
+
+for app in hex survey pack assort dquotes tests
+do
+  echo $app
+  ./translate_subx init.$OS 0[0-8]*.subx apps/subx-params.subx apps/$app.subx
+  diff apps/$app a.elf
+done
+
+for app in sigils calls braces
+do
+  echo $app
+  ./translate_subx init.$OS 0*.subx apps/subx-params.subx apps/$app.subx
+  diff apps/$app a.elf
+done
+
 #? # Mu translator
 #? echo mu
 #? ./translate_subx init.$OS [0-9]*.subx apps/mu.subx