about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-25 19:26:18 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-25 19:26:18 -0700
commit3b5b19df66c0de4f916ba00298c6e000fc69de71 (patch)
treed9dbf680c2bf2df45de3be3f11b44069c3715166
parentd796318101775f9150af5d5f3bca61cdf31c41fa (diff)
downloadmu-3b5b19df66c0de4f916ba00298c6e000fc69de71.tar.gz
6406 - primitive 'copy-handle'
-rw-r--r--069allocate.subx23
-rwxr-xr-xapps/assortbin44250 -> 44275 bytes
-rwxr-xr-xapps/bracesbin46121 -> 46146 bytes
-rwxr-xr-xapps/callsbin50782 -> 50807 bytes
-rwxr-xr-xapps/crenshaw2-1bin43601 -> 43626 bytes
-rwxr-xr-xapps/crenshaw2-1bbin44148 -> 44173 bytes
-rwxr-xr-xapps/dquotesbin47872 -> 47897 bytes
-rwxr-xr-xapps/factorialbin42694 -> 42719 bytes
-rwxr-xr-xapps/hexbin46440 -> 46465 bytes
-rwxr-xr-xapps/mubin254249 -> 254274 bytes
-rwxr-xr-xapps/packbin56585 -> 56610 bytes
-rwxr-xr-xapps/sigilsbin58506 -> 58531 bytes
-rwxr-xr-xapps/surveybin54196 -> 54221 bytes
-rwxr-xr-xapps/testsbin43022 -> 43047 bytes
14 files changed, 23 insertions, 0 deletions
diff --git a/069allocate.subx b/069allocate.subx
index 0c75ece0..c65a369e 100644
--- a/069allocate.subx
+++ b/069allocate.subx
@@ -489,6 +489,29 @@ $handle-equal?:end:
     5d/pop-to-ebp
     c3/return
 
+copy-handle:  # src: handle, dest: (addr handle)
+    # . prologue
+    55/push-ebp
+    89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
+    # . save registers
+    50/push-eax
+    51/push-ecx
+    # ecx = dest
+    8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .             .           1/r32/ecx   0x10/disp8      .                 # copy *(ebp+16) to ecx
+    # *dest = src
+    8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .             .           0/r32/eax   8/disp8         .                 # copy *(ebp+8) to eax
+    89/copy                         0/mod/indirect  1/rm32/ecx    .           .             .           0/r32/eax   .               .                 # copy eax to *ecx
+    8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .             .           0/r32/eax   0xc/disp8       .                 # copy *(ebp+12) to eax
+    89/copy                         1/mod/*+disp8   1/rm32/ecx    .           .             .           0/r32/eax   4/disp8         .                 # copy eax to *(ecx+4)
+$copy-handle:end:
+    # . restore registers
+    59/pop-to-ecx
+    58/pop-to-eax
+    # . epilogue
+    89/copy                         3/mod/direct    4/rm32/esp    .           .             .           5/r32/ebp   .               .                 # copy ebp to esp
+    5d/pop-to-ebp
+    c3/return
+
 # helper: create a nested allocation descriptor (useful for tests)
 allocate-region:  # ad: (addr allocation-descriptor), n: int, out: (addr handle allocation-descriptor)
     # . prologue
diff --git a/apps/assort b/apps/assort
index 86ac7113..bc4b2eb9 100755
--- a/apps/assort
+++ b/apps/assort
Binary files differdiff --git a/apps/braces b/apps/braces
index 5b80b0ea..e7618b4e 100755
--- a/apps/braces
+++ b/apps/braces
Binary files differdiff --git a/apps/calls b/apps/calls
index 26a1a287..16a1c90b 100755
--- a/apps/calls
+++ b/apps/calls
Binary files differdiff --git a/apps/crenshaw2-1 b/apps/crenshaw2-1
index 5ebbb3d5..34a50dcb 100755
--- a/apps/crenshaw2-1
+++ b/apps/crenshaw2-1
Binary files differdiff --git a/apps/crenshaw2-1b b/apps/crenshaw2-1b
index 39cd305d..cc00dc48 100755
--- a/apps/crenshaw2-1b
+++ b/apps/crenshaw2-1b
Binary files differdiff --git a/apps/dquotes b/apps/dquotes
index d0ebf897..a49d897d 100755
--- a/apps/dquotes
+++ b/apps/dquotes
Binary files differdiff --git a/apps/factorial b/apps/factorial
index c4bbc51e..92e0523a 100755
--- a/apps/factorial
+++ b/apps/factorial
Binary files differdiff --git a/apps/hex b/apps/hex
index 398cb046..cd183977 100755
--- a/apps/hex
+++ b/apps/hex
Binary files differdiff --git a/apps/mu b/apps/mu
index 8db63c71..700919ca 100755
--- a/apps/mu
+++ b/apps/mu
Binary files differdiff --git a/apps/pack b/apps/pack
index 3cbb7528..22a66caf 100755
--- a/apps/pack
+++ b/apps/pack
Binary files differdiff --git a/apps/sigils b/apps/sigils
index ea4a30f9..76becaf3 100755
--- a/apps/sigils
+++ b/apps/sigils
Binary files differdiff --git a/apps/survey b/apps/survey
index daa6f40f..018e9fa7 100755
--- a/apps/survey
+++ b/apps/survey
Binary files differdiff --git a/apps/tests b/apps/tests
index 38e774a3..4b1eea42 100755
--- a/apps/tests
+++ b/apps/tests
Binary files differ