about summary refs log tree commit diff stats
path: root/subx/070new-stream.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/070new-stream.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/070new-stream.subx')
-rw-r--r--subx/070new-stream.subx15
1 files changed, 8 insertions, 7 deletions
diff --git a/subx/070new-stream.subx b/subx/070new-stream.subx
index ad6ab68d..8a833581 100644
--- a/subx/070new-stream.subx
+++ b/subx/070new-stream.subx
@@ -68,20 +68,21 @@ test-new-stream:
     # . prolog
     55/push-EBP
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
-    # var ad/ECX : (address allocation-descriptor) = allocate-region(Heap, 512)
-    # . EAX = allocate-region(Heap, 512)
+    # var heap/ECX : (address allocation-descriptor) = {0, 0}
+    68/push  0/imm32/limit
+    68/push  0/imm32/curr
+    89/copy                         3/mod/direct    1/rm32/ECX    .           .             .           4/r32/ESP   .               .                 # copy ESP to ECX
+    # heap = new-segment(512)
     # . . push args
+    51/push-ECX
     68/push  0x200/imm32
-    68/push  Heap/imm32
     # . . call
-    e8/call  allocate-region/disp32
+    e8/call  new-segment/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-    # . ECX = EAX
-    89/copy                         3/mod/direct    1/rm32/ECX    .           .             .           0/r32/EAX   .               .                 # copy EAX to ECX
     # var start/EDX = ad->curr
     8b/copy                         0/mod/indirect  1/rm32/ECX    .           .             .           2/r32/EDX   .               .                 # copy *ECX to EDX
-    # EAX = new-stream(ad, 3, 2)
+    # EAX = new-stream(heap, 3, 2)
     # . . push args
     68/push  2/imm32
     68/push  3/imm32