On Fri, 11 Aug 1995 16:14:37 +0100 (BST), Mr Keith Turner said: > > You don't have to refrain from using the heap; you just have to use it > > properly by going through the system interfaces. What's so hard about > > that?
> Is it documented in the Technical Manual (which I am still looking for)? Yes... > If somebody could send me a specific pointer to the relevant information > then I'd be happy to comply. The system heap is that area of memory between 4000 and 4B00, which is also shared by the BASIC stack (growing downwards from 4B00) and it is for user programs that need a bit of storage that is always paged in. It occupies the region between HEAPST [dpeek &5BCA] (which is usually 4000) and HEAPEND [dpeek $5BC8]. Anyway, it's very simple: to reserve some space you just call JHEAPROOM at 0106 with BC containing the number of spaces, and if there is enough room it will return with the carry flag set and HL pointing to the start of the reserved space. It's polite not to reserve too much space and to put non-essential routines somewhere else in memory. There is a page allocation table at 5100. The byte stored at (5100+x) gives information about page x (0 <= x < 32). If it is zero, the page is free. FF means the page does not exist (on a 256K machine). All other numbers mean the page is occupied. The number 20 (hex) means that the page is a utility page. Utility pages are further subdivided into 16 1K-long slots, except the last slot which is 1008 bytes long. The last 16 bytes of each utility page say whether the slots are occupied. FF denotes an occupied slot and 00 denotes a free slot. imc

