Memory allocation: Difference between revisions

m
→‎{{header|Retro}}: update for retro12
m (→‎{{header|Retro}}: update for retro12)
Line 1,261:
 
=={{header|Retro}}==
Retro's memory is directly accessible via '''@fetch''' and '''!store'''. This is used for all functions and data structures. A variable, '''heapHeap''', points to the next free address. '''allot''' can be used to allocate or free memory. The amount of memory varies by the runtime, and can be accessed via the '''memoryEOM''' variableconstant.
 
<lang Retro>( display total memory available )
@memory putn
 
~~~
( display unused memory )
EOM n:put
@memory here - putn
~~~
 
( display next free addressunused )memory
here putn
 
~~~
( allocate 1000 cells )
EOM here - n:put
1000 allot
~~~
 
(display next free 500 cells )address
 
-500 allot</lang>
~~~
here putnn:put
~~~
 
( allocate 1000 cells )
 
~~~
#1000 allot
~~~
 
free 500 cells
 
~~~
#-500 allot</lang>
~~~</lang>
 
=={{header|REXX}}==
Anonymous user