8 how the compiler compiles to memory – Jameco Electronics Rabbit 3000 User Manual

Page 136

Advertising
background image

User’s Manual

127

8.8 How the Compiler Compiles to Memory

The compiler actually generates code for root code and constants and extended code and
extended constants. It allocates space for data variables, but does not generate data bits to
be stored in memory.

In any but the smallest programs, most of the code is compiled to extended memory. This
code executes in the 8K window from E000 to FFFF. This 8K 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 64K space. Special instructions, particularly long call, long
jump and long return, are used to access code outside of the 8K window. When one of
these transfer of control instructions is executed, both the address and the view through the
8K window or page are changed. This allows transfer to any instruction in the 1M memory
space. The 8-bit XPC register controls which of the 256 4K pages the 8K window aligns
with. The 16-bit PC controls the address of the instruction, usually in the region E000 to
FFFF. The advantage of paged access is that most instructions continue to use 16-bit
addressing. Only when an out-of-range transfer of control is made does a 20-bit transfer of
control need to be made. The beauty of having a 4K minimum step in page alignment
while the size of the page is 8K is that code can be compiled continuously without gaps
caused by change of page. When the page is moved by 4K, the previous end of code is still
visible in the window, provided that the midpoint of the page was crossed before moving
the page alignment.

As the compiler compiles code in the extended code window, it checks at opportune times
to see if the code has passed the midpoint of the window or F000. When the code passes
F000, the compiler slides the window down by 4K so that the code at F000+x becomes
resident at E000+x. This results in the code being divided into segments that are typically
4K long, but which can very short or as long as 8K. Transfer of control can be accom-
plished within each segment by 16-bit addressing; 20-bit addressing is required between
segments.

Advertising
This manual is related to the following products: