
180
Evaluating and Programming the 29K RISC Family
A called procedure can locate its dynamic parent and the variables of the dy-
namic parent because of the the caller–callee activation record linkage (see section
3.5). However, the linkage is not adequate to locate variables of the static parent
which may be referenced in the procedure. If such references appear in a procedure,
the procedure must be provided with a local register which forms part of the static
link pointer chain. Since there can be a hierarchy of static parents, the
slp
points to the
slp
of the immediate parent, which in turn points to the
slp
of its immediate parent.
The memory–stack support register
gr125
(
msp
) and the register–stack support
registers
gr126
(
rab
),
gr127
(
rfb
) and
gr1
(
rsp
), were discussed in detail in Chapter 2.
They maintain the current positions of the stack resources.
The calling convention does not assign any particular task to the registers in the
operating system (OS) group (
gr64–gr95
). However, over time a convention has
evolved among 29K processor users.The subdivision of the OS registers shown in
Figure 3-3 is widely adhered to. The subgroups are known as: the interrupt freeze
mode temporaries (given synonyms
it0–it3
); the operating system temporaries
(
kt0–kt11
); and the operating system statics support registers (
ks0–ks15
). Note, static
register
ks0
is often combined with
it0–kt11
to form an interrupt context cache (see
section 2.5.1). Consequently,
ks1
is the first available static support register.
When developing a new assembly language procedure a useful technique is to
construct a C language routine which receives any passed parameters and imple-
ments the appropriate task. With the AMD High C 29K compiler, the procedure can
be compiled to produce an assembly language output file with the “–S –Hanno” com-
piler switches. The Assembly level code can then be directly modified into the re-
quired code sequence.
3.3.1 Useful Macro–Instructions
The code examples shown in later chapters make use of a number macros for
pushing and popping special registers to an external memory stack. A macro instruc-
tion is composed of a sequence of simpler instructions. Effectively, a macro is an in–
line procedure call. Using macros is faster than making an actual procedure call but
consumes more instruction memory space.The macro definitions are presented be-
low:
.macro pushsr,sp,reg,sreg
mfsr
sub
store
.endm
;
.macro popsr,sreg,reg,sp
load
add
mtsr
.endm
;macro name and parameters
;copy from special
;decrement pointer
;store on stack
reg,sreg
sp,sp,4
0,0,reg,sp
;macro name and parameters
;get from stack
;increment pointer
;move to special
0,0,reg,sp
sp,sp,4
sreg,reg