--- /dev/null
+# (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com>
+# All rights reserved.
+
+include ../config.mk
+
+all: randomheap
+
+randomheap:
+ $(CPP) $(CPP_FLAGS) -o temp.pvvs randomheap.pvvs
+ $(VVS_COMPILER) -i temp.pvvs -o randomheap.vvs
+ @rm -f temp.pvvs
+
+run: randomheap
+ $(VVS_INTERPRETER) -i randomheap.vvs
+
+clean:
+ @rm -f randomheap.vvs temp.pvvs
--- /dev/null
+@@ Populate heap[18]-heap[29] with random values
+SSSTSTTN | PUSH 11
+SSSTSSTSN | PUSH 18
+NSTTTSTSN | JSR > 11010 (memrand)
+
+@@ Print heap[16]-heap[31]
+SSSTTTTTN | PUSH 31
+SSSTSSSSN | PUSH 16
+NSTTTTSSSN | JSR > 111000 (dump heap)
+NNN | DIE
+
+#include "debug.pvvs"
+#include "heap.pvvs"
011xxx - heap functions
11000 ----- memset (heap.pvvs)
11001 ----- memcpy (heap.pvvs)
+ 11010 ----- memrand (heap.pvvs)
100xxx - unassigned
101xxx - unassigned
110xxx - conversion functions
SNN | DROP
NTN | RTS
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@ Description:
+@ This function writes random words into the memory locations:
+@ startaddr -> startaddr+count
+@ Call Stack:
+@ count
+@ startaddr <-- TOS
+@ Return Stack:
+@ <empty>
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+NSSVTTSTSN | Mark: 11010 (memrand)
+SSSSN | PUSH 0 (ptr)
+SNT | SWAP
+TTS | STORE
+
+@ Store random word into one memory location on each pass through this loop.
+NSSVSSSTTSTSSSSSSSSSN | Mark: 00011010 00000000
+SNS | DUP
+SSSSN | PUSH 0 (ptr)
+TTT | LOAD
+TSSS | ADD
+NSTTSSSSN | JSR > 10000 (random)
+TTS | STORE
+
+@ Decrement and check loop end conditions
+SNS | DUP
+NTSSSSTTSTSSSSSSSSTN | BRZ > 00011010 00000001
+SSSTN | PUSH 1
+TSST | SUBTRACT
+NSNSSSTTSTSSSSSSSSSN | JMP > 00011010 00000000
+
+NNN
+@ Clean up and return
+NSSVSSSTTSTSSSSSSSSTN | Mark: 00011010 00000001
+SNN | DROP
+NTN | RTS
+
+#include <math.pvvs>
+
#endif