User`s manual
Rabbit 4000 Designer’s Handbook rabbit.com 55
6.5.2.8 Origin Directive to Reserve Blocks of Memory
With the Rabbit 4000, the compiler generates an origin table that contains the blocks that are reserved for
code and data origin or other non-xalloc use. With this change, the method of reserving a block of memory
so that xalloc() does not use it has also changed. To reserve a block of memory in DC 9.30 and later,
the #resvorg should be used. All other origins (e.g., #rcodorg, #rvarorg, etc.) are also tracked by
the compiler and those blocks are entered into the origin table generated by the compiler so they are not
used by xalloc().
The #resvorg is used as follows:
#resvorg <NAME> segment offset size [reserve]
For example, the following code would reserve the entire flash memory in flash compile mode
#resvorg flashmem 0x0 0x0 0x80000 reserve
The reserve keyword must be added to the end to reserve the entire block of memory.
Some applications may require that fixed regions of RAM be reserved for their own use. For example, you
may want to reserve the upper half of a 512K RAM in Flash compile mode. To reserve this you need to
add the following line of code to \LIB\BIOSLIB\STDBIOS.C just below the “#resvorg removeflash
0x0 0x0 0x80000 reserve.”
#ifdef RESERVE_UPPER_RAM
#resvorg reserveupperram 0xC0 0x0 RESERVE_UPPER_RAM
batterybacked reserve
#endif
This tells the compiler to reserve RESERVE_UPPER_RAM bytes from physical address 0xC0000 by add-
ing it to the origin table. This removes this memory block from the available xalloc memory.
In the Defines tab of the Options | Project Options dialog, enter the amount of memory you want to
reserve. For example,
RESERVE_UPPER_RAM=0x40000
would reserve physical memory from 0xC0000-0xFFFFF and make it unavailable for xalloc. You can then
access this memory directly from your program as follows:
main() {
long addr;
addr = 0xC0000; // point to block reserved for my use
}