about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-07-22 01:25:33 -0700
committerKartik Agaram <vc@akkartik.com>2019-07-22 01:25:33 -0700
commit37cf4e0581b586f0b28ab96876f43794323d4b60 (patch)
tree01b59189d287598ed0488bc9b0141cb0d1d6d960
parentf2d63490706bb042ccc5f99104b17c380246cb93 (diff)
downloadmu-37cf4e0581b586f0b28ab96876f43794323d4b60.tar.gz
5443 - standard library is now self-hosted
Translates 5k lines of input in 26 seconds.

I'm not sure why I need to grow the label table. It was already 512 entries
long, and I'm only using 373 so far.
-rwxr-xr-xsubx/apps/assortbin34326 -> 34330 bytes
-rwxr-xr-xsubx/apps/dquotesbin40882 -> 40886 bytes
-rwxr-xr-xsubx/apps/hexbin36881 -> 36885 bytes
-rwxr-xr-xsubx/apps/packbin46978 -> 46982 bytes
-rw-r--r--subx/apps/subx-common.subx8
-rwxr-xr-xsubx/apps/surveybin42976 -> 42981 bytes
-rw-r--r--subx/apps/survey.subx14
-rwxr-xr-xsubx/apps/testsbin33138 -> 33142 bytes
8 files changed, 17 insertions, 5 deletions
diff --git a/subx/apps/assort b/subx/apps/assort
index 01813914..5fd51058 100755
--- a/subx/apps/assort
+++ b/subx/apps/assort
Binary files differdiff --git a/subx/apps/dquotes b/subx/apps/dquotes
index be36b0c4..5c7ee1c0 100755
--- a/subx/apps/dquotes
+++ b/subx/apps/dquotes
Binary files differdiff --git a/subx/apps/hex b/subx/apps/hex
index 8b903e5d..4bd5acce 100755
--- a/subx/apps/hex
+++ b/subx/apps/hex
Binary files differdiff --git a/subx/apps/pack b/subx/apps/pack
index 792c30ba..370ced9b 100755
--- a/subx/apps/pack
+++ b/subx/apps/pack
Binary files differdiff --git a/subx/apps/subx-common.subx b/subx/apps/subx-common.subx
index 413edc9a..27f488c9 100644
--- a/subx/apps/subx-common.subx
+++ b/subx/apps/subx-common.subx
@@ -1,6 +1,6 @@
-# some common helpers shared by phases of the SubX converter
+# common helpers shared by phases of the SubX translator
 
-# - buffer sizes shared by all phases
+# - some limits on the programs we can translate
 == data
 
 # maximum memory available for allocation
@@ -15,6 +15,10 @@ Segment-size:
 Input-size:
   0x80000/imm32/512KB
 
+# maximum size of the 'labels' table in survey.subx
+Max-labels:
+  0x4000/imm32/1K-labels/16KB
+
 == code
 #   instruction                     effective address                                                   register    displacement    immediate
 # . op          subop               mod             rm32          base        index         scale       r32
diff --git a/subx/apps/survey b/subx/apps/survey
index 308c6ee8..54ed0c41 100755
--- a/subx/apps/survey
+++ b/subx/apps/survey
Binary files differdiff --git a/subx/apps/survey.subx b/subx/apps/survey.subx
index 9bee7e16..8af8204c 100644
--- a/subx/apps/survey.subx
+++ b/subx/apps/survey.subx
@@ -136,16 +136,24 @@ convert:  # infile : (address buffered-file), out : (address buffered-file) -> <
     68/push  0/imm32/read
     68/push  0/imm32/write
     89/copy                         3/mod/direct    1/rm32/ECX    .           .             .           4/r32/ESP   .               .                 # copy ESP to ECX
-    # var labels/EDX = stream(512 * 16)
-    81          5/subop/subtract    3/mod/direct    4/rm32/ESP    .           .             .           .           .               0x2000/imm32      # subtract from ESP
-    68/push  0x2000/imm32/length
+    # var labels/EDX = stream(1024 * 16)
+    # . data
+    2b/subtract                     0/mod/indirect  5/rm32/.disp32            .             .           4/r32/ESP   Max-labels/disp32                 # subtract *Max-labels from ESP
+    # . length
+    ff          6/subop/push        0/mod/indirect  5/rm32/.disp32            .             .           .           Max-labels/disp32                 # push *Max-labels
+    # . read
     68/push  0/imm32/read
+    # . write
     68/push  0/imm32/write
     89/copy                         3/mod/direct    2/rm32/EDX    .           .             .           4/r32/ESP   .               .                 # copy ESP to EDX
     # var in/ESI = stream(Input-size * 1)
+    # . data
     2b/subtract                     0/mod/indirect  5/rm32/.disp32            .             .           4/r32/ESP   Input-size/disp32                 # subtract *Input-size from ESP
+    # . length
     ff          6/subop/push        0/mod/indirect  5/rm32/.disp32            .             .           .           Input-size/disp32                 # push *Input-size
+    # . read
     68/push  0/imm32/read
+    # . write
     68/push  0/imm32/write
     89/copy                         3/mod/direct    6/rm32/ESI    .           .             .           4/r32/ESP   .               .                 # copy ESP to ESI
 #?     # dump labels->write {{{
diff --git a/subx/apps/tests b/subx/apps/tests
index 20375e67..edaf4709 100755
--- a/subx/apps/tests
+++ b/subx/apps/tests
Binary files differ