PROCEDURE CALLS
7-11
7
7.1.5
Mapping Local Registers to the Procedure Stack
Each local register set is mapped to a register save area of its respective frame in the procedure
stack (
Figure 7-1
). Saved local register sets are frequently cached on-chip rather than saved to
memory. The caching mechanism is not write-through. Local register set contents are not saved
automatically to the save area in memory when the register set is cached. This would cause a
significant performance loss for call operations.
Also, no automatic update policy is implemented for the register cache. When the register save area
in memory for a cached register set is modified, there is no guarantee that the modification is
reflected when the register set is restored. For a frame spill, the set must be flushed to memory
prior to the modification for the modification to be valid.
The
flushreg
instruction causes the contents of all cached local register sets to be written (flushed)
to their associated stack frames in memory. The register cache is then invalidated, meaning that all
flushed register sets are restored from their save areas in memory. The current set of local registers
is not written to memory.
flushreg
is commonly used in debuggers or fault handlers to gain access
to all saved local registers. In this way, call history may be traced back through nested procedures.
flushreg
is also used when implementing task switches in multitasking kernels. The procedure
stack is changed as part of the task switch. To change the procedure stack,
flushreg
is executed to
update the current procedure stack and invalidate all entries in the local register cache. Next, the
procedure stack is changed by directly modifying the FP and SP registers and executing a call
operation. After
flushreg
executes, the procedure stack may also be changed by modifying the
previous frame in memory and executing a return operation.
When a set of local registers is assigned to a new procedure, the processor may or may not clear or
initialize these registers. Therefore, initial register contents are unpredictable. Also, the processor
does not initialize the local register save area in the newly created stack frame for the procedure; its
contents are equally unpredictable.
7.2
MODIFYING THE PFP REGISTER
The FP must not be directly modified by user software or risk corrupting the local registers.
Instead, implement context switches by modifying the PFP.
Modification of the PFP is typically for context switches; as part of the switch, the active procedure
changes the pointer to the frame that it returns to (previous frame pointer — PFP). Great care should
be taken in modifying the PFP. In the general case, a
flushreg
must be issued before and after
modifying the PFP when the local register cache is enabled (see
Example 7-1
). This requirement
ensures the correct operation of a context switch on all i960 processors in all situations.
Summary of Contents for i960 Jx
Page 1: ...Release Date December 1997 Order Number 272483 002 i960 Jx Microprocessor Developer s Manual ...
Page 24: ......
Page 25: ...1 INTRODUCTION ...
Page 26: ......
Page 35: ...2 DATA TYPES AND MEMORY ADDRESSING MODES ...
Page 36: ......
Page 46: ......
Page 47: ...3 PROGRAMMING ENVIRONMENT ...
Page 48: ......
Page 73: ...4 CACHE AND ON CHIP DATA RAM ...
Page 74: ......
Page 85: ...5 INSTRUCTION SET OVERVIEW ...
Page 86: ......
Page 111: ...6 INSTRUCTION SET REFERENCE ...
Page 112: ......
Page 233: ...7 PROCEDURE CALLS ...
Page 234: ......
Page 256: ......
Page 257: ...8 FAULTS ...
Page 258: ......
Page 291: ...9 TRACING AND DEBUGGING ...
Page 292: ......
Page 309: ...10 TIMERS ...
Page 310: ......
Page 324: ......
Page 325: ...11 INTERRUPTS ...
Page 326: ......
Page 369: ...12 INITIALIZATION AND SYSTEM REQUIREMENTS ...
Page 370: ......
Page 412: ......
Page 413: ...13 MEMORY CONFIGURATION ...
Page 414: ......
Page 429: ...14 EXTERNAL BUS ...
Page 430: ......
Page 468: ......
Page 469: ...15 TEST FEATURES ...
Page 470: ......
Page 493: ...A CONSIDERATIONS FOR WRITING PORTABLE CODE ...
Page 494: ......
Page 502: ......
Page 503: ...B OPCODES AND EXECUTION TIMES ...
Page 504: ......
Page 515: ...C MACHINE LEVEL INSTRUCTION FORMATS ...
Page 516: ......
Page 523: ...D REGISTER AND DATA STRUCTURES ...
Page 524: ......
Page 550: ......
Page 551: ...GLOSSARY ...
Page 552: ......
Page 561: ...INDEX ...
Page 562: ......
Page 578: ......