SW500009 Microchip Technology, SW500009 Datasheet - Page 92

HI-TECH FOR DSPIC/PIC24

SW500009

Manufacturer Part Number
SW500009
Description
HI-TECH FOR DSPIC/PIC24
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC24 & DsPICr
Datasheet

Specifications of SW500009

Supported Families
PIC24
Core Architecture
PIC, DsPIC
Software Edition
Standard
Kit Contents
Software And Docs
Tool Type
Compiler
Mcu Supported Families
PIC24 MCUs And DsPIC DSCs
Lead Free Status / RoHS Status
Not applicable / RoHS Compliant
For Use With/related Products
DSPIC3X/PIC24
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
025
778-1003
778-1003
Linking Programs
3.13.2 Signature Checking
The compiler automatically produces signatures for all functions. A signature is a 16-bit value
computed from a combination of the function’s return data type, the number of its parameters and
other information affecting the calling sequence for the function. This signature is output in the
object code of any function referencing or defining the function.
likely to issue a mismatch error from the linker when the routine is either a precompiled object file
or an assembly routine. Other function mismatches are reported by the code generator.
extern declaration. Such assembly language functions should include a signature which is compati-
ble with the C prototype used to call them. The simplest method of determining the correct signature
for a function is to write a dummy C function with the same prototype and compile it to assembly
language using the PICC -S option. For example, suppose you have an assembly language routine
called _widget which takes two int arguments and returns a char value. The prototype used to call
this function from C would be:
arguments and a char return value would be generated. In order to match the correct signature the
source code for widget needs to contain an assembler SIGNAT pseudo-op which defines the same
signature value. To determine the correct value, you would write the following code:
the value 8249 with symbol _widget. The value 8249 is the correct signature for a function with
two int arguments and a char return value. If this line is copied into the .as file where _widget is
defined, it will associate the correct signature with the function and the linker will be able to check
for correct argument passing. For example, if another .c file contains the declaration:
will alert you to the possible existence of incompatible calling conventions.
78
At link time the linker will report any mismatch of signatures. HI-TECH PICC STD is only
It is sometimes necessary to write assembly language routines which are called from C using an
extern char widget(int, int);
Where a call to _widget is made in the C code, the signature for a function with two int
char widget(int arg1, int arg2)
{
}
and compile it to assembler code using
PICC -S x.c
The resultant assembler code includes the following line:
SIGNAT _widget,8249
The SIGNAT pseudo-op tells the assembler to include a record in the .obj file which associates
extern char widget(long);
then a different signature will be generated and the linker will report a signature mis-match which
C Language Features

Related parts for SW500009