SW006012 Microchip Technology, SW006012 Datasheet - Page 117

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
8.1
8.2
8.3
© 2007 Microchip Technology Inc.
Chapter 8. Mixing Assembly Language and C Modules
INTRODUCTION
HIGHLIGHTS
MIXING ASSEMBLY LANGUAGE AND C VARIABLES AND FUNCTIONS
This section describes how to use assembly language and C modules together. It gives
examples of using C variables and functions in assembly code and examples of using
assembly language variables and functions in C.
Items discussed in this chapter are:
• Mixing Assembly Language and C Variables and Functions – Separate
• Using Inline Assembly Language – Assembly language instructions may be
The following guidelines indicate how to interface separate assembly language
modules with C modules.
• Follow the register conventions described in Section 4.13 “Register
• Functions not called during interrupt handling must preserve registers W8-W15.
• Interrupt functions must preserve all registers. Unlike a normal function call, an
• Variables or functions declared within a separate assembly file that will be
The following example shows how to use variables and functions in both assembly
language and C regardless of where they were originally defined.
The file ex1.c defines foo and cVariable to be used in the assembly language file.
The C file also shows how to call an assembly function, asmFunction, and how to
access the assembly defined variable, asmVariable.
assembly language modules may be assembled, then linked with compiled C
modules.
embedded directly into the C code. The inline assembler supports both simple
(non-parameterized) assembly language statement, as well as extended
(parameterized) statements, where C variables can be accessed as operands of
an assembler instruction.
Conventions”. In particular, registers W0-W7 are used for parameter passing. An
assembly language function will receive parameters, and should pass arguments
to called functions, in these registers.
That is, the values in these registers must be saved before they are modified and
restored before returning to the calling function. Registers W0-W7 may be used
without restoring their values.
interrupt may occur at any point during the execution of a program. When return-
ing to the normal program, all registers must be as they were before the interrupt
occurred.
referenced by any C source file should be declared as global using the assembler
directive.global. External symbols should be preceded by at least one
underscore. The C function main is named _main in assembly and conversely an
assembly symbol _do_something will be referenced in C as do_something.
Undeclared symbols used in assembly files will be treated as externally defined.
USER’S GUIDE
MPLAB
DS51284F-page 111
®
C30

Related parts for SW006012