Developing a native pascal/c compiler for 65c816 one problem is implement new()/dispose() procedures and malloc()/free() functions that take advantage of large memory addressable by cpu.
In attached file an attempt of a possible implementation of 2 routines:
- GetMem: allocate a block of memory from heap (max size of one block = $fff6 bytes)
- FreeMem: free memory previously allocated with GetMem
Allocated block can span banks, and global heap size is limited only by available ram. Pointers to allocated blocks are long pointer (24 bit).
Heap require a simple initialitation of some dp variables, especially hStart and hTop (24 bit pointers extended to 32 bit) that define heap size.
Marco
_________________
http://65xx.unet.bz/ - Hardware & Software 65XX family