User`s manual
34 rabbit.com Rabbit Memory Organization
address space for constants) and bit 3 enables inversion of MSB for the data space data segment (i.e., the
logical address space for root data).
5.3.3 Customizing Interrupts
No special code is required to customize interrupts using separate I&D space on the Rabbit 4000 with the
addition of the RAM segment register (RAMSR). Use SetVectIntern() and SetVectExtern()
to set interrupts. Please see the Dynamic C Function Reference Manual for more information on these
functions.
5.4 How The Compiler Compiles to Memory
The compiler generates code for root code, root constants, extended code, extended constants, and far con-
stants. It allocates space for data variables, but, except for constants, does not generate data to be stored in
memory. Any initialization of RAM variables must be accomplished by code since the compiler is not
present when the program starts in the field. (Please see #GLOBAL_INIT in the Dynamic C User’s Man-
ual.)
Static variables are not zeroed out by default.The BIOS macro ZERO_OUT_STATIC_DATA may be set
to “1” which will only zero out static variables on board power-up or reset. Zeroing out static variables is
not compatible with the use of “protected” variables because they will be zeroed out along with the rest of
the static data.
5.4.1 Placement of Code in Memory
Code may be placed in either extended memory or root memory. Functions execute at the same speed, but
calls to functions in root memory are slightly more efficient than calls to functions in extended memory.
In all but the smallest programs, most of the code is compiled to extended memory. Root constants share
the memory space needed for root code (when separate I&D space is disabled), so as the memory needed
for root constants increases, the amount of code that can be stored in root memory decreases and code
must be moved to extended memory.
Please see the Dynamic C User’s Manual regarding the compiler directive #memmap for more informa-
tion about controlling the placement of code in memory.
5.4.2 Paged Access in Extended Memory
The code in extended memory executes in the 8 KB window from 0xE000 to 0xFFFF. This 8 KB window
uses paged access. Instructions that use 16-bit addressing can jump within the page and also outside of the
page to the remainder of the 64 KB logical space. Special instructions, particularly LCALL, LJP, and
LRET, are used to access code outside of the 8 KB window for addresses below 0x100000. Similarly,
LLCALL, LLJP, and LLRET can be used to access code outside of the 8KB window to any place in the
physical address space. When one of these transfer-of-control instructions is executed, both the address
and the view through the 8 KB window change, allowing transfer to any instruction in the physical mem-
ory space. The 12-bit LXPC register controls which of two consecutive 4 KB pages the 8 KB window
aligns with (there are 256 pages in a 1 MB physical address space). The 16-bit PC controls the address of
the instruction, usually in the region 0xE000 to 0xFFFF. The advantage of paged access is that most
instructions continue to use 16-bit addressing. Only when a page change is needed does a physical address
transfer of control need to be made.