232/317
8 - C Language and the C Compiler
Special care has to be taken at this stage: the linker normally optimizes the code by removing
unused declarations. If we let it do so, it will remove some of the register declarations, and
thus shift the addresses of the following registers. To prevent the linker from unwisely opti-
mizing the declaration file (and only this file), the name of this file must be followed by a + sign
in the list of the object files to be linked:
NAMES
main.o
interrup.o
map_7225.o+
start07.o
ansi.lib
END
All these directives are grouped in the file
LINK.PRM
. The working of the linker is explained in
more detail later in this chapter.
8.3.4 Interrupt handling
Interrupts are very much like subroutine calls, so they can easily be handled using C lan-
guage. However, the following precautions must be taken:
A function may be declared as being an interrupt service routine. This function must have no
argument and must not return any value. The declaration must be preceded by the statement
#pragma TRAP_PROC
that says that the routine must end with a IRET instruction.
Since the ST7 does not have a large stack, the standard interrupt call only saves the registers
necessary for character and integer arithmetic. However, it is possible to use long and float
arithmetic in interrupt subroutines, provided that the work area used for this arithmetic is ex-
plicitly saved using procedures provided for that purpose with the package. More details are
given in the following paragraph.
8.3.5 Limitations put on the full implementation of C language
In typical implementations of C, all the function parameters, return values, and local variables
are stored on the stack. This provides for nesting, recursion and re-entrance at a depth that is
only limited by the size of the stack. Thus, C may require a large amount of stack for function
nesting and parameter passing in complicated constructs.
The ST7 family provides a limited RAM size, of which the stack takes only a part, that can be
as small as 64 bytes. This does not allow the use of the stack for parameter passing. Thus, the
implementation of C for the ST7 uses registers and a few memory locations to pass the pa-
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...