Skip to content
SashaCrofter edited this page Jul 7, 2012 · 7 revisions

Heap Manager

heap.init

(location, length, blocksize) heap.init reserves a 4 word header followed by a bit map of all blocks. The size of the bit map is (maxlength/blocksize)/16. length is actually the length of the heap, excluding the header and bit map.

The header consists of a magic word, 0x9ea9, the location of the first block in memory, the size of each block, and the maximum length of the heap.

This subroutine clears all of the space given to it.

returns location of header

heap.alloc (length)

Reserves the first consecutive length of memory in the heap.

returns the location of the reserved memory, or 1 if no such block of memory is available UNDER DEVELOPMENT; DO NOT USE

heap.free (location, length)

Marks the blocks specified by location and length as free, and clears them.

returns location

heap.mark (block, number, used/unused)

Marks number of blocks used or unused, starting from the index block. 1 in used/unused denotes used, and 0 denotes unused.

return block

Clone this wiki locally