retroforth/package/extensions/malloc.retro
crc 3962c08662 down to 10 words w/o recorded stack comments
FossilOrigin-Name: 9a36cf9d0e7ddd0131df3867aa4285f0c26ccde64ef7c193729932647d8829a3
2024-09-09 18:07:02 +00:00

27 lines
580 B
Forth

# Malloc
~~~
{{
:mem:invoke #15 io:scan-for io:invoke ;
#0 'ALLOC const
#1 'FREE const
#2 'STORE const
#3 'FETCH const
#4 'RESIZE const
---reveal---
:mem:alloc (:n--a) ALLOC mem:invoke ;
:mem:store (:an--) STORE mem:invoke ;
:mem:fetch (:a--n) FETCH mem:invoke ;
:mem:free (:a--) FREE mem:invoke ;
:mem:resize (:an--) RESIZE mem:invoke ;
}}
:mem:cell+ (:nn-n) #8 * + ;
:mem:fetch-double (:n-nn)
dup #1 mem:cell+ fetch push mem:fetch pop ;
:mem:store-double (:ann-nn)
push push dup-pair #1 mem:cell+ pop mem:store pop mem:store ;
~~~