
97
Chapter 2 Applications Programming
2.2.1 OS Preparations before Calling start In crt0
According to the HIF specification, operating system initialization procedures
must establish appropriate values for the general registers mentioned below before
execution of a user’s application code commences. Linked application code normal-
ly commences at address label
start
in module
crt0.s
. This module is automatically
linked with application code modules and libraries when the compiler is used to pro-
duce the final application executable. In addition, file descriptors for the standard in-
put and output devices must be opened, and any Am29027 floating–point coproces-
sor support as well as other trapware support must be initialized.
Register Stack Pointer
(
gr1
)
Register
gr1
points to the top of the register stack. It contains the main memory
address in which the local register
lr0
will be saved, should it be spilled, and from
which it will be restored. The processor can also use the
gr1
register as the base in
base–plus–offset addressing of the local register file. The content of
rsp
is compared
to the content of
rab
to determine when it is necessary to spill part of the local register
stack to memory. On startup, the values in
rab,
rsp
, and
rfb
should be initialized to
prevent a spill trap from occurring on entry to the
crt0
code, as shown by the follow-
ing relations:
((64*4) +
rab)
≤
rsp
<
rfb
rfb
=
rab
+ 512
This provides the
crt0
code with at least 64 registers on entry, which should be a
sufficient number to accomplish its purpose. Note,
rab
and
rfb
are normally set to be a
window distance apart, 128 words (512 bytes), but this is not the only valid settings,
see section 2.3.2 and 4.3.1.
Register Free Bound (gr127)
The register stack free–bound pointer,
rfb
, contains the register stack address of
the lowest-addressed word not contained within the register file. Register
rfb
is refer-
enced in the epilog of most user program functions to determine whether a register
fill operation is necessary to restore previously spilled registers needed by the func-
tion’s caller. The
rfb
register should be initialized to point to the highest address of the
memory region allocated for register stack use. It is recommended that this memory
region not be less than 6k bytes.
Register Allocate Bound (gr126)
The register stack allocate–bound pointer,
rab
, contains the register stack ad-
dress of the lowest-addressed word contained within the register file. Register
rab
is
referenced in the prolog of most user program functions to determine whether a regis-