about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-10 22:47:30 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-10 22:47:30 -0700
commit4eda8c599c6b6fa35d25e6760617709d7cb56a25 (patch)
tree42f538e57d0073478ae25681e6952a0fdefa8b48
parent34d3cb48e9e66d7c2281ea68bf0da294e376663d (diff)
downloadmu-4eda8c599c6b6fa35d25e6760617709d7cb56a25.tar.gz
debugging helper: heap remaining
-rw-r--r--120allocate.subx12
-rw-r--r--400.mu1
2 files changed, 13 insertions, 0 deletions
diff --git a/120allocate.subx b/120allocate.subx
index 26d2a74b..bb4b3cb1 100644
--- a/120allocate.subx
+++ b/120allocate.subx
@@ -75,6 +75,18 @@ $allocate:end:
     5d/pop-to-ebp
     c3/return
 
+heap-bound:  # -> _/eax: int
+    # . prologue
+    55/push-ebp
+    89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
+    #
+    8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           0/r32/eax   Heap/disp32     .                 # copy *Heap to eax
+$heap-bound:end:
+    # . epilogue
+    89/copy                         3/mod/direct    4/rm32/esp    .           .             .           5/r32/ebp   .               .                 # copy ebp to esp
+    5d/pop-to-ebp
+    c3/return
+
 # Claim the next 'n' bytes of memory starting at ad->curr and update ad->curr.
 # Abort if there isn't enough memory in 'ad'.
 allocate-raw:  # ad: (addr allocation-descriptor), n: int, out: (addr handle _)
diff --git a/400.mu b/400.mu
index d1143ea8..7eba6f46 100644
--- a/400.mu
+++ b/400.mu
@@ -38,6 +38,7 @@ sig turn-on-debug-print
 sig turn-off-debug-print
 sig abort e: (addr array byte)
 sig dump-call-stack
+sig heap-bound -> _/eax: int
 
 sig count-event
 sig count-of-events -> _/eax: int