SW006012 Microchip Technology, SW006012 Datasheet - Page 34

C COMPILER FOR DSPIC30F FAMILY

SW006012

Manufacturer Part Number
SW006012
Description
C COMPILER FOR DSPIC30F FAMILY
Manufacturer
Microchip Technology
Type
MPLAB® C30 Compilerr
Series
PIC24 & DsPICr
Datasheets

Specifications of SW006012

Supported Families
PIC24, DsPIC30F And DsPIC33F
Core Architecture
PIC, DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24 MCUs And DsPIC DSCs
Tool Type
Compiler
Processor Series
PIC24, dsPIC
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
dsPIC30F
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
MPLAB
DS51284F-page 28
®
C30 User’s Guide
It is not safe for one function that uses a global register variable to call another such
function foo by way of a third function lose that was compiled without knowledge of
this variable (i.e., in a source file in which the variable wasn’t declared). This is because
lose might save the register and put some other value there. For example, you can’t
expect a global register variable to be available in the comparison-function that you
pass to qsort, since qsort might have put something else in that register. This
problem can be avoided by recompiling qsort with the same global register variable
definition.
If you want to recompile qsort or other source files that do not actually use your global
register variable, so that they will not use that register for any other purpose, then it
suffices to specify the compiler command-line option -ffixed-reg. You need not
actually add a global register declaration to their source code.
A function that can alter the value of a global register variable cannot safely be called
from a function compiled without this variable, because it could clobber the value the
caller expects to find there on return. Therefore, the function that is the entry point into
the part of the program that uses the global register variable must explicitly save and
restore the value that belongs to its caller.
The library function longjmp will restore to each global register variable the value it
had at the time of the setjmp.
All global register variable declarations must precede all function definitions. If such a
declaration appears after function definitions, the register may be used for other
purposes in the preceding functions.
Global register variables may not have initial values, because an executable file has no
means to supply initial contents for a register.
2.3.4.2
You can define a local register variable with a specified register like this:
register int *foo asm ("w8");
Here w8 is the name of the register that should be used. Note that this is the same
syntax used for defining global register variables, but for a local variable it would appear
within a function.
Defining such a register variable does not reserve the register; it remains available for
other uses in places where flow control determines the variable’s value is not live.
Using this feature may leave the compiler too few available registers to compile certain
functions.
This option does not ensure that MPLAB C30 will generate code that has this variable
in the register you specify at all times. You may not code an explicit reference to this
register in an asm statement and assume it will always refer to this variable.
Assignments to local register variables may be deleted when they appear to be
unused. References to local register variables may be deleted, moved or simplified.
2.3.5
MPLAB C30 supports complex data types. You can declare both complex integer types
and complex floating types, using the keyword __complex__.
For example, __complex__ float x; declares x as a variable whose real part and
imaginary part are both of type float. __complex__ short int y; declares y to
have real and imaginary parts of type short int.
To write a constant with a complex data type, use the suffix 'i' or 'j' (either one; they
are equivalent). For example, 2.5fi has type __complex__ float and 3i has type
__complex__ int. Such a constant is a purely imaginary value, but you can form
any complex value you like by adding one to a real constant.
SPECIFYING REGISTERS FOR LOCAL VARIABLES
Complex Numbers
© 2007 Microchip Technology Inc.

Related parts for SW006012