about summary refs log tree commit diff stats
path: root/subx/072slice.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-05-10 16:45:22 -0700
committerKartik Agaram <vc@akkartik.com>2019-05-10 16:45:22 -0700
commitc88b9e31259d433c7e63fcb19d430daf9b1c723c (patch)
tree12de1a20312a788d07ef6564084b7ca81aa15ba1 /subx/072slice.subx
parentcdfb2dbfcf18cd2f23bf74199082392c3692a599 (diff)
downloadmu-c88b9e31259d433c7e63fcb19d430daf9b1c723c.tar.gz
5151 - use mmap everywhere we need a heap
All tests passing now. Things are very explicit; before a program can `allocate`
memory, it has to first obtain a segment from the OS using `new-segment`.
Diffstat (limited to 'subx/072slice.subx')
-rw-r--r--subx/072slice.subx16
1 files changed, 14 insertions, 2 deletions
diff --git a/subx/072slice.subx b/subx/072slice.subx
index 9c285097..683c4c7b 100644
--- a/subx/072slice.subx
+++ b/subx/072slice.subx
@@ -917,14 +917,26 @@ test-slice-to-string:
     # . prolog
     55/push-EBP
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
+    # var heap/EDX : (address allocation-descriptor) = {0, 0}
+    68/push  0/imm32/limit
+    68/push  0/imm32/curr
+    89/copy                         3/mod/direct    2/rm32/EDX    .           .             .           4/r32/ESP   .               .                 # copy ESP to EDX
+    # heap = new-segment(512)
+    # . . push args
+    52/push-EDX
+    68/push  0x200/imm32
+    # . . call
+    e8/call  new-segment/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
     # var slice/ECX = "Abc"
     68/push  _test-slice-data-3/imm32/end
     68/push  _test-slice-data-0/imm32/start
     89/copy                         3/mod/direct    1/rm32/ECX    .           .             .           4/r32/ESP   .               .                 # copy ESP to ECX
-    # EAX = slice-to-string(Heap, slice)
+    # EAX = slice-to-string(heap, slice)
     # . . push args
     51/push-ECX
-    68/push  Heap/imm32
+    52/push-EDX
     # . . call
     e8/call  slice-to-string/disp32
     # . . discard args