
6-12
Motorola DSP56000 Family Optimizing C Compiler User’s Manual
For More Information On This Product,
Go to: www.freescale.com
Motorola
Setjmp File
The mechanisms used to implement the C signal interface may be altered to fit a particular
hardware application. Any series of alterations applied to the signal file must leave an
implementation conforming to the ANSI standard X3.159 for C. Alteration of the signal
file is done at one’s own risk and is not generally advised. Again, the contents of the signal
file must remain consistent with the include file
signal.h
.
6.10 Setjmp File
The functions
setjmp()
and
longjmp()
are implemented in the
setjmp
file. The
setjmp()
function stores the current process status (i.e., the current execution context) in a buffer
that is passed. The
longjmp()
function is used to restore the process status to the execution
context which was saved by
setjmp()
.
Saving the current execution context is done by saving the stack pointer, the return
program counter value, the frame pointer and all of the callee-save registers into the
buffer. The buffer that is passed to
setjmp
() should have enough space for the saving
process. The structure
jmp_buf
defined in setjmp.h allocates the buffer space needed for
the operation. The function
setjmp()
always returns a zero.
The function
longjmp
() takes two arguments, an environment buffer and a return value. It
restores all registers from the buffer passed, including the frame pointer and stack pointer.
It then places the return value passed into accumulator A and sets the ccr to reflect the
return value just stored in accumulator A. The function
longjmp()
discards the return
program counter on the hardware stack and jumps to the address pointed to by the program
counter stored in the buffer.
This file must conform to the include files
setjmp.h
and
longjmp.h
.
Since these two
algorithms are very straightforward, modification of the file may be not needed. If
modification is absolutely necessary, then the ANSI standard of the functions
setjmp()
and
longjmp()
should be followed.
6.11 Host-Supported I/O (printf (), et al)
The library provided with DSP56KCC includes a full implementation of the ANSI C
standard input and output routines. These routines already work with Gdb56 and run56,
and can easily be embedded in custom applications. Anywhere that formatted I/O is
desired, these library routines can be included to simplify development. The entire suite of
routines is based upon a simple communication protocol between the DSP and a host
resident I/O driver, so porting the entire system to custom hardware is trivial.
F
Freescale Semiconductor, Inc.
n
.