about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--subx/069allocate.subx24
-rwxr-xr-xsubx/apps/assortbin34330 -> 34384 bytes
-rwxr-xr-xsubx/apps/crenshaw2-1bin24734 -> 24788 bytes
-rwxr-xr-xsubx/apps/crenshaw2-1bbin25293 -> 25347 bytes
-rwxr-xr-xsubx/apps/dquotesbin40886 -> 40940 bytes
-rwxr-xr-xsubx/apps/factorialbin23650 -> 23704 bytes
-rwxr-xr-xsubx/apps/handlebin24509 -> 24558 bytes
-rw-r--r--subx/apps/handle.subx2
-rwxr-xr-xsubx/apps/hexbin27743 -> 27797 bytes
-rwxr-xr-xsubx/apps/packbin47016 -> 47070 bytes
-rw-r--r--subx/apps/subx-common.subx6
-rwxr-xr-xsubx/apps/surveybin43551 -> 43605 bytes
-rw-r--r--subx/apps/survey.subx4
-rwxr-xr-xsubx/apps/testsbin33142 -> 33196 bytes
14 files changed, 24 insertions, 12 deletions
diff --git a/subx/069allocate.subx b/subx/069allocate.subx
index e262b4d5..6521b43a 100644
--- a/subx/069allocate.subx
+++ b/subx/069allocate.subx
@@ -22,7 +22,7 @@
 # . 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
 
 # Claim the next 'n' bytes of memory starting at ad->curr and update ad->curr.
-# If there isn't enough memory before ad->limit, return 0 and leave 'ad' unmodified.
+# Abort if there isn't enough memory in 'ad'.
 allocate:  # ad : (address allocation-descriptor), n : int -> address-or-null/EAX
     # . prolog
     55/push-EBP
@@ -39,10 +39,7 @@ allocate:  # ad : (address allocation-descriptor), n : int -> address-or-null/EA
     89/copy                         3/mod/direct    2/rm32/EDX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EDX
     03/add                          1/mod/*+disp8   5/rm32/EBP    .           .             .           2/r32/EDX   0xc/disp8       .                 # add *(EBP+12) to EDX
     3b/compare                      1/mod/*+disp8   1/rm32/ECX    .           .             .           2/r32/EDX   4/disp8         .                 # compare EDX with *(ECX+4)
-    72/jump-if-lesser-signed  $allocate:commit/disp8
-    # return null if not
-    b8/copy-to-EAX  0/imm32
-    eb/jump  $allocate:end/disp8
+    73/jump-if-greater-or-equal-signed  $allocate:abort/disp8
 $allocate:commit:
     # update ad->curr
     89/copy                         0/mod/indirect  1/rm32/ECX    .           .             .           2/r32/EDX   .               .                 # copy EDX to *ECX
@@ -55,6 +52,21 @@ $allocate:end:
     5d/pop-to-EBP
     c3/return
 
+$allocate:abort:
+    # . _write(2/stderr, error)
+    # . . push args
+    68/push  "allocate: failed to allocate\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
+    # . syscall(exit, 1)
+    bb/copy-to-EBX  1/imm32
+    b8/copy-to-EAX  1/imm32/exit
+    cd/syscall  0x80/imm8
+    # never gets here
+
 test-allocate-success:
     # . prolog
     55/push-EBP
@@ -94,7 +106,7 @@ test-allocate-success:
     5d/pop-to-EBP
     c3/return
 
-test-allocate-failure:
+_pending-test-allocate-failure:
     # . prolog
     55/push-EBP
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
diff --git a/subx/apps/assort b/subx/apps/assort
index 6b31712a..c0fc6873 100755
--- a/subx/apps/assort
+++ b/subx/apps/assort
Binary files differdiff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index 93183803..47ee601e 100755
--- a/subx/apps/crenshaw2-1
+++ b/subx/apps/crenshaw2-1
Binary files differdiff --git a/subx/apps/crenshaw2-1b b/subx/apps/crenshaw2-1b
index c0eae5f9..fba81a7d 100755
--- a/subx/apps/crenshaw2-1b
+++ b/subx/apps/crenshaw2-1b
Binary files differdiff --git a/subx/apps/dquotes b/subx/apps/dquotes
index bbaa4119..6b88fbde 100755
--- a/subx/apps/dquotes
+++ b/subx/apps/dquotes
Binary files differdiff --git a/subx/apps/factorial b/subx/apps/factorial
index c015a3c9..b82be120 100755
--- a/subx/apps/factorial
+++ b/subx/apps/factorial
Binary files differdiff --git a/subx/apps/handle b/subx/apps/handle
index f098c715..b6794474 100755
--- a/subx/apps/handle
+++ b/subx/apps/handle
Binary files differdiff --git a/subx/apps/handle.subx b/subx/apps/handle.subx
index 97a6c622..ba824f85 100644
--- a/subx/apps/handle.subx
+++ b/subx/apps/handle.subx
@@ -143,7 +143,7 @@ test-new:
     5d/pop-to-EBP
     c3/return
 
-test-new-failure:
+_pending-test-new-failure:
     # . prolog
     55/push-EBP
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
diff --git a/subx/apps/hex b/subx/apps/hex
index ff5d30b5..c5d1f415 100755
--- a/subx/apps/hex
+++ b/subx/apps/hex
Binary files differdiff --git a/subx/apps/pack b/subx/apps/pack
index efd22fef..fd29e9aa 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 27f488c9..baf247f2 100644
--- a/subx/apps/subx-common.subx
+++ b/subx/apps/subx-common.subx
@@ -5,11 +5,11 @@
 
 # maximum memory available for allocation
 Heap-size:
-  0x100000/imm32/1MB
+  0x200000/imm32/2MB
 
 # maximum size of a single segment
 Segment-size:
-  0x40000/imm32/256KB
+  0x80000/imm32/512KB
 
 # maximum size of input textual stream (spanning all segments)
 Input-size:
@@ -17,7 +17,7 @@ Input-size:
 
 # maximum size of the 'labels' table in survey.subx
 Max-labels:
-  0x4000/imm32/1K-labels/16KB
+  0x10000/imm32/4K-labels/64KB
 
 == code
 #   instruction                     effective address                                                   register    displacement    immediate
diff --git a/subx/apps/survey b/subx/apps/survey
index 80dea805..348e20f0 100755
--- a/subx/apps/survey
+++ b/subx/apps/survey
Binary files differdiff --git a/subx/apps/survey.subx b/subx/apps/survey.subx
index bd7596da..15957fa2 100644
--- a/subx/apps/survey.subx
+++ b/subx/apps/survey.subx
@@ -117,7 +117,7 @@ convert:  # infile : (address buffered-file), out : (address buffered-file) -> <
     #   var in : (address stream byte) = stream(4096)
     #   slurp(infile, in)
     #   var segments = new-stream(10 rows, 16 bytes each)
-    #   var labels = new-stream(512 rows, 16 bytes each)
+    #   var labels = new-stream(Max-labels rows, 16 bytes each)
     #   compute-offsets(in, segments, labels)
     #   compute-addresses(segments, labels)
     #   rewind-stream(in)
@@ -136,7 +136,7 @@ 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(1024 * 16)
+    # var labels/EDX = stream(Max-labels * 16)
     # . data
     2b/subtract                     0/mod/indirect  5/rm32/.disp32            .             .           4/r32/ESP   Max-labels/disp32                 # subtract *Max-labels from ESP
     # . length
diff --git a/subx/apps/tests b/subx/apps/tests
index c4a9aaa5..08e586e3 100755
--- a/subx/apps/tests
+++ b/subx/apps/tests
Binary files differ