about summary refs log tree commit diff stats
path: root/subx/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-02-18 21:48:19 -0800
committerKartik Agaram <vc@akkartik.com>2019-02-18 21:48:19 -0800
commit8188bbbc9408322c18cdc2d1049126900abf793c (patch)
tree2141b32bc1b7df6106980e12f0edbacc7dcfd329 /subx/apps
parent6607a30415e2bede27c43b57ce3c5cbc42278fa9 (diff)
downloadmu-8188bbbc9408322c18cdc2d1049126900abf793c.tar.gz
4981 - no, go back to 3 phases
Considering how much trouble a merge phase would be (commit 4978), it seems
simpler to just add the extra syntax for controlling the entry point of
the generated ELF binary.

But I wouldn't have noticed this if I hadn't taken the time to write out
the commit messages of 4976 and 4978.

Even if we happened to already have linked list primitives built, this
may still be a good idea considering that I'm saving quite a lot of code
in duplicated entrypoints.
Diffstat (limited to 'subx/apps')
-rwxr-xr-xsubx/apps/crenshaw2-1bin18370 -> 18028 bytes
-rw-r--r--subx/apps/crenshaw2-1.subx3
-rwxr-xr-xsubx/apps/crenshaw2-1bbin18929 -> 18587 bytes
-rw-r--r--subx/apps/crenshaw2-1b.subx3
-rwxr-xr-xsubx/apps/factorialbin17288 -> 16946 bytes
-rw-r--r--subx/apps/factorial.subx7
-rwxr-xr-xsubx/apps/handlebin18081 -> 17721 bytes
-rw-r--r--subx/apps/handle.subx7
-rwxr-xr-xsubx/apps/hexbin21349 -> 21007 bytes
-rw-r--r--subx/apps/hex.subx5
-rw-r--r--subx/apps/merge.subx36
-rwxr-xr-xsubx/apps/packbin21526 -> 21184 bytes
-rw-r--r--subx/apps/pack.subx5
13 files changed, 17 insertions, 49 deletions
diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index 99d08ba4..6588d8e7 100755
--- a/subx/apps/crenshaw2-1
+++ b/subx/apps/crenshaw2-1
Binary files differdiff --git a/subx/apps/crenshaw2-1.subx b/subx/apps/crenshaw2-1.subx
index ad8dad46..8acdde59 100644
--- a/subx/apps/crenshaw2-1.subx
+++ b/subx/apps/crenshaw2-1.subx
@@ -30,11 +30,12 @@
 # . 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:  # run tests if necessary, call 'compile' if not
+
 #?     # for debugging: run a single test; don't bother setting status code
 #?     e8/call test-get-num-reads-single-digit/disp32
 #?     eb/jump  $main:end/disp8
 
-# main: run tests if necessary, call 'compile' if not
     # . prolog
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
     # - if argc > 1 and argv[1] == "test", then return run_tests()
diff --git a/subx/apps/crenshaw2-1b b/subx/apps/crenshaw2-1b
index ae66b7b4..08c5f45e 100755
--- a/subx/apps/crenshaw2-1b
+++ b/subx/apps/crenshaw2-1b
Binary files differdiff --git a/subx/apps/crenshaw2-1b.subx b/subx/apps/crenshaw2-1b.subx
index 044221eb..55689cca 100644
--- a/subx/apps/crenshaw2-1b.subx
+++ b/subx/apps/crenshaw2-1b.subx
@@ -30,11 +30,12 @@
 # . 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:  # run tests if necessary, call 'compile' if not
+
 #?     # for debugging: run a single test; don't bother setting status code
 #?     e8/call test-get-num-reads-single-digit/disp32
 #?     eb/jump  $main:end/disp8
 
-# main: run tests if necessary, call 'compile' if not
     # . prolog
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
     # - if argc > 1 and argv[1] == "test", then return run_tests()
diff --git a/subx/apps/factorial b/subx/apps/factorial
index 90193370..d8cd6766 100755
--- a/subx/apps/factorial
+++ b/subx/apps/factorial
Binary files differdiff --git a/subx/apps/factorial.subx b/subx/apps/factorial.subx
index 912285e2..8f4bf47d 100644
--- a/subx/apps/factorial.subx
+++ b/subx/apps/factorial.subx
@@ -18,7 +18,12 @@
 # . 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
 
-# main:
+Entry:  # run tests if necessary, compute `factorial(5)` if not
+
+#?     # for debugging: run a single test; don't bother setting status code
+#?     e8/call test-get-num-reads-single-digit/disp32
+#?     eb/jump  $main:end/disp8
+
     # . prolog
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
     # - if argc > 1 and argv[1] == "test", then return run_tests()
diff --git a/subx/apps/handle b/subx/apps/handle
index 5708c864..fe9e4cce 100755
--- a/subx/apps/handle
+++ b/subx/apps/handle
Binary files differdiff --git a/subx/apps/handle.subx b/subx/apps/handle.subx
index 3848eb76..8f82759a 100644
--- a/subx/apps/handle.subx
+++ b/subx/apps/handle.subx
@@ -25,12 +25,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
 
-# main:
-    e8/call  run-tests/disp32  # 'run-tests' is a function created automatically by SubX. It calls all functions that start with 'test-'.
-    # syscall(exit, Num-test-failures)
-    8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           3/r32/EBX   Num-test-failures/disp32          # copy *Num-test-failures to EBX
-    b8/copy-to-EAX  1/imm32/exit
-    cd/syscall  0x80/imm8
+# no Entry; the standard library runs all tests by default
 
 new:  # ad : (address allocation-descriptor), n : int, out : (address handle)
     # . prolog
diff --git a/subx/apps/hex b/subx/apps/hex
index dcc77d5c..8ace80be 100755
--- a/subx/apps/hex
+++ b/subx/apps/hex
Binary files differdiff --git a/subx/apps/hex.subx b/subx/apps/hex.subx
index 49ca3bd4..4f65d03b 100644
--- a/subx/apps/hex.subx
+++ b/subx/apps/hex.subx
@@ -17,12 +17,13 @@
 # . 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
 
-    # for debugging: run a single test
+Entry:  # run tests if necessary, convert stdin if not
+
+#?     # for debugging: run a single test
 #?     e8/call test-skip-until-newline/disp32
 #?     8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           3/r32/EBX   Num-test-failures/disp32          # copy *Num-test-failures to EBX
 #?     eb/jump  $main:end/disp8
 
-# main: run tests if necessary, convert stdin if not
     # . prolog
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
     # - if argc > 1 and argv[1] == "test", then return run_tests()
diff --git a/subx/apps/merge.subx b/subx/apps/merge.subx
deleted file mode 100644
index a5ecc987..00000000
--- a/subx/apps/merge.subx
+++ /dev/null
@@ -1,36 +0,0 @@
-# Read a text file of SubX segment 'fragments' with duplicate names, and emit
-# a list of 'merged' segments.
-#
-# Example input:
-#   == A
-#   a
-#   b
-#   c
-#   == B
-#   d
-#   e
-#   == A
-#   f
-#   g
-#   == A
-#   h
-#
-# Output:
-#   == A
-#   h
-#   f
-#   g
-#   a
-#   b
-#   c
-#   == B
-#   d
-#   e
-#
-# The output gives each segment the contents of all its fragments, with later
-# fragments *prepended* to earlier ones.
-#
-# Prepending necessitates buffering output until the end. We'll convert
-# fragments to distinct streams, maintain each segment as a linked list of
-# fragments that's easy to prepend to, and finally emit the linked lists in
-# order.
diff --git a/subx/apps/pack b/subx/apps/pack
index b4d04abe..a16daf5b 100755
--- a/subx/apps/pack
+++ b/subx/apps/pack
Binary files differdiff --git a/subx/apps/pack.subx b/subx/apps/pack.subx
index 755f3d79..fa383042 100644
--- a/subx/apps/pack.subx
+++ b/subx/apps/pack.subx
@@ -20,12 +20,13 @@
 # . 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
 
-    # for debugging: run a single test
+Entry:  # run tests if necessary, convert stdin if not
+
+#?     # for debugging: run a single test
 #?     e8/call test-convert-instruction-passes-labels-through/disp32
 #?     8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           3/r32/EBX   Num-test-failures/disp32          # copy *Num-test-failures to EBX
 #?     eb/jump  $main:end/disp8
 
-# main: run tests if necessary, convert stdin if not
     # . prolog
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
     # - if argc > 1 and argv[1] == "test", then return run_tests()