about summary refs log tree commit diff stats
path: root/subx/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-07-10 10:55:30 -0700
committerKartik Agaram <vc@akkartik.com>2019-07-10 10:55:30 -0700
commitc6ec8fa3f77ba24e92ce8fda32b6919f0f67e496 (patch)
tree06e93c409f88d37e09fbcfd1971b83b52e4033c3 /subx/apps
parent3f097f3fd6f91830f007d6ee9db5f6be9d5e191c (diff)
downloadmu-c6ec8fa3f77ba24e92ce8fda32b6919f0f67e496.tar.gz
zero out new rows returned by get-or-insert
Diffstat (limited to 'subx/apps')
-rwxr-xr-xsubx/apps/assortbin32098 -> 32242 bytes
-rwxr-xr-xsubx/apps/crenshaw2-1bin23725 -> 23839 bytes
-rwxr-xr-xsubx/apps/crenshaw2-1bbin24284 -> 24398 bytes
-rwxr-xr-xsubx/apps/dquotesbin38451 -> 38595 bytes
-rwxr-xr-xsubx/apps/factorialbin22641 -> 22755 bytes
-rwxr-xr-xsubx/apps/handlebin23500 -> 23614 bytes
-rwxr-xr-xsubx/apps/hexbin26734 -> 26848 bytes
-rwxr-xr-xsubx/apps/packbin44464 -> 44608 bytes
-rw-r--r--subx/apps/subx-common.subx19
-rwxr-xr-xsubx/apps/surveybin38602 -> 38746 bytes
10 files changed, 19 insertions, 0 deletions
diff --git a/subx/apps/assort b/subx/apps/assort
index dc437fba..83a063f0 100755
--- a/subx/apps/assort
+++ b/subx/apps/assort
Binary files differdiff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index 2dc6e6d4..e5e6560c 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 efa0ece7..eebd667a 100755
--- a/subx/apps/crenshaw2-1b
+++ b/subx/apps/crenshaw2-1b
Binary files differdiff --git a/subx/apps/dquotes b/subx/apps/dquotes
index c803fa9e..e982690c 100755
--- a/subx/apps/dquotes
+++ b/subx/apps/dquotes
Binary files differdiff --git a/subx/apps/factorial b/subx/apps/factorial
index 2433b2a6..55a59123 100755
--- a/subx/apps/factorial
+++ b/subx/apps/factorial
Binary files differdiff --git a/subx/apps/handle b/subx/apps/handle
index d1cbb74b..3ea729c6 100755
--- a/subx/apps/handle
+++ b/subx/apps/handle
Binary files differdiff --git a/subx/apps/hex b/subx/apps/hex
index 5bfa5863..315e855c 100755
--- a/subx/apps/hex
+++ b/subx/apps/hex
Binary files differdiff --git a/subx/apps/pack b/subx/apps/pack
index 8eff81dd..7ad19415 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 e8b3140c..129c9821 100644
--- a/subx/apps/subx-common.subx
+++ b/subx/apps/subx-common.subx
@@ -24,6 +24,7 @@ get-or-insert:  # table : (address stream {string, _}), key : (address string),
     #     curr += row-size
     #   if table->write >= table->length
     #     abort
+    #   zero-out(max, row-size)
     #   *max = key
     #   table->write += row-size
     #   return max+4
@@ -72,6 +73,14 @@ $get-or-insert:not-found:
     8b/copy                         0/mod/indirect  6/rm32/ESI    .           .             .           1/r32/ECX   .               .                 # copy *ESI to ECX
     3b/compare                      1/mod/*+disp8   6/rm32/ESI    .           .             .           1/r32/ECX   8/disp8         .                 # compare ECX with *(ESI+8)
     73/jump-if-greater-or-equal-unsigned  $get-or-insert:abort/disp8
+    # zero-out(max, row-size)
+    # . . push args
+    ff          6/subop/push        1/mod/*+disp8   5/rm32/EBP    .           .             .           .           0x10/disp8      .                 # push *(EBP+16)
+    52/push-EDX
+    # . . call
+    e8/call  zero-out/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
     # *max = key
     # . EAX = key
     8b/copy                         1/mod/*+disp8   5/rm32/EBP    .           .             .           0/r32/EAX   0xc/disp8       .                 # copy *(EBP+12) to EAX
@@ -258,6 +267,7 @@ $test-get-or-insert:end:
 # scan 'table' for a row with a key 'key' and return the address of the corresponding value
 # if no row is found, save 'key' in the next available row
 # if there are no rows free, abort
+# WARNING: leaks memory
 # TODO: pass in an allocation descriptor
 get-or-insert-slice:  # table : (address stream {string, _}), key : (address slice), row-size : int -> EAX : (address _)
     # pseudocode:
@@ -269,6 +279,7 @@ get-or-insert-slice:  # table : (address stream {string, _}), key : (address sli
     #     curr += row-size
     #   if table->write >= table->length
     #     abort
+    #   zero-out(max, row-size)
     #   *max = slice-to-string(Heap, key)
     #   table->write += row-size
     #   return max+4
@@ -317,6 +328,14 @@ $get-or-insert-slice:not-found:
     8b/copy                         0/mod/indirect  6/rm32/ESI    .           .             .           1/r32/ECX   .               .                 # copy *ESI to ECX
     3b/compare                      1/mod/*+disp8   6/rm32/ESI    .           .             .           1/r32/ECX   8/disp8         .                 # compare ECX with *(ESI+8)
     7d/jump-if-greater-or-equal  $get-or-insert-slice:abort/disp8
+    # zero-out(max, row-size)
+    # . . push args
+    ff          6/subop/push        1/mod/*+disp8   5/rm32/EBP    .           .             .           .           0x10/disp8      .                 # push *(EBP+16)
+    52/push-EDX
+    # . . call
+    e8/call  zero-out/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
     # *max = slice-to-string(Heap, key)
     # . EAX = slice-to-string(Heap, key)
     # . . push args
diff --git a/subx/apps/survey b/subx/apps/survey
index 9290e1ae..0c900562 100755
--- a/subx/apps/survey
+++ b/subx/apps/survey
Binary files differ