SW006010 Microchip Technology, SW006010 Datasheet - Page 59

no-image

SW006010

Manufacturer Part Number
SW006010
Description
MPLAB 17C SOFTWARE
Manufacturer
Microchip Technology
Datasheets

Specifications of SW006010

Tool Function
Compiler
Tool Type
Compiler
Processor Series
PIC17C
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
MPLAB®
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
5.9
5.10
 2002 Microchip Technology Inc.
SOFTWARE STACK CALL CONVENTIONS
FUNCTION CALL CONVENTIONS
The size of the software stack required by a program varies with the complexity of the
program. The following should be kept in mind:
• One RAM location will be reserved by the compiler for use as the Stack Pointer.
• When nesting function calls, all arguments and local variables (auto variables
5.8.2
MPLAB C17 supports parameters and local variables allocated either on the software
stack or directly from global memory. The
function parameter in global memory instead of on the software stack. Stack-based
local variables and arguments require more code to access than static local variables
and supporting arguments. See 10.3 “Static Locals And Parameters” for more
information on static parameters and locals. Functions that use stack-based variables
are more flexible in that they are reentrant and recursive.
The MPLAB C17 software stack is an upwards growing stack data structure on which
the compiler places function arguments and local variables. The software stack is
distinct from the hardware stack upon which the PICmicro MCU places function call
return addresses.
The stack pointer always points to the next available stack location. MPLAB C17
allocates the first location of the stack for use as the stack pointer, leaving both FSR0
and FSR1 available for other use by the compiler.
When a function is invoked, its stack based arguments are pushed onto the stack in
right-to-left order and the function is called. The leftmost function argument is on the
top of the software stack upon entry into the function.
MPLAB C17 immediately adds the total size of the stack based local variables for the
function to the stack pointer, allocating space for instances of those variables.
References to stack based argument values and stack based local variables are
resolved according to offsets from the stack pointer.
A function is reentrant if it may be safely called from multiple threads of control at the
same time. For instance, if a function is called by an interrupt service routine, it must
be reentrant because if an interrupt occurs while the function is executing, the function
will be called again by the interrupt routine.
In general, a function which only manipulates stack-based local variables and
stack-based parameters is reentrant. References to global variables or the use of
static parameters or static local variables may cause a function be non-reentrant.
included) of the calling function will remain on the stack. Therefore, the stack must
be large enough to accommodate the requirements by all functions in a tree.
Note: Stack Overflow Avoidance – For MPLAB SIM or MPLAB ICE 2000, use a
Controlling What Goes on the Stack
break
then a stack overflow would have occurred in the next byte
statement at the last location on the stack. If the program breaks,
static
Runtime Environment
keyword places a local variable or a
apRNOVM^-page 53
Part
Part
Part
Part
1
2
3
4

Related parts for SW006010