SW006012 Microchip Technology, SW006012 Datasheet - Page 118

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 112
®
C30 User’s Guide
EXAMPLE 8-1:
/*
** file: ex1.c
*/
extern unsigned int asmVariable;
extern void asmFunction(void);
unsigned int cVariable;
void foo(void)
{
}
The file ex2.s defines asmFunction and asmVariable as required for use in a
linked application. The assembly file also shows how to call a C function, foo, and how
to access a C defined variable, cVariable.
;
;
;
_asmFunction:
_main:
_asmVariable: .space 2
In the C file, ex1.c, external references to symbols declared in an assembly file are
declared using the standard extern keyword; note that asmFunction, or
_asmFunction in the assembly source, is a void function and is declared
accordingly.
In the assembly file, ex1.s, the symbols _asmFunction, _main and _asmVariable
are made globally visible through the use of the .global assembler directive and can
be accessed by any other source file. The symbol _main is only referenced and not
declared; therefore, the assembler takes this to be an external reference.
The following MPLAB C30 example shows how to call an assembly function with two
parameters. The C function main in call1.c calls the asmFunction in call2.s
with two parameters.
.end
asmFunction();
asmVariable = 0x1234;
.text
.global _asmFunction
mov #0,w0
mov w0,_cVariable
return
.global _begin
call _foo
return
.bss
.global _asmVariable
.align 2
file: ex2.s
MIXING C AND ASSEMBLY
© 2007 Microchip Technology Inc.

Related parts for SW006012