5 - first stab at allocator, just for ints

Still can't write to a pointer.
This commit is contained in:
Kartik K. Agaram 2014-07-26 12:48:54 -07:00
parent 29c2f5a398
commit 5b7de7f6d6
2 changed files with 19 additions and 0 deletions

5
mu.arc
View File

@ -99,6 +99,11 @@
;? (prn "jumping to " arg.1.1)
(= pc (+ pc arg.1.1)) ; relies on continue still incrementing (bug)
(continue))
copy
(= (memory* oarg.0.1) (memory* arg.0.1))
deref
(= (memory* oarg.0.1)
(memory* (memory* arg.0.1)))
reply
(do (= result arg)
(break))

14
new.mu Normal file
View File

@ -0,0 +1,14 @@
; memory map: 1-1000 reserved for the (currently non-reentrant) allocator
(main
((integer 1) <- literal 1000) ; location 1 contains the high-water mark for the memory allocator
((integer-pointer 4) <- new)
((integer 5) <- deref (integer-pointer 4))
)
(new
((integer-pointer 2) <- copy (integer 1))
((integer 3) <- literal 1)
((integer 1) <- add (integer 1) (integer 3))
(reply (integer-pointer 2)))
;; vim:ft=scheme