SW006012 Microchip Technology, SW006012 Datasheet - Page 119

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.4
© 2007 Microchip Technology Inc.
USING INLINE ASSEMBLY LANGUAGE
EXAMPLE 8-2:
/*
** file: call1.c
*/
extern int asmFunction(int, int);
int x;
void
main(void)
{
}
The assembly-language function sums its two parameters and returns the result.
;
; file: call2.s
;
_asmFunction:
Parameter passing in C is detailed in Section 4.12.2 “Return Value”. In the preceding
example, the two integer arguments are passed in the W0 and W1 registers. The
integer return result is transferred via register W0. More complicated parameter lists
may require different registers and care should be taken in the hand-written assembly
to follow the guidelines.
Within a C function, the asm statement may be used to insert a line of assembly
language code into the assembly language that the compiler generates. Inline
assembly has two forms: simple and extended.
In the simple form, the assembler instruction is written using the syntax:
asm ("instruction");
where instruction is a valid assembly-language construct. If you are writing inline
assembly in ANSI C programs, write __asm__ instead of asm.
In an extended assembler instruction using asm, the operands of the instruction are
specified using C expressions. The extended syntax is:
asm("template" [ : [ "constraint"(output-operand) [ , ... ] ]
You must specify an assembler instruction template, plus an operand constraint
string for each operand. The template specifies the instruction mnemonic, and
optionally placeholders for the operands. The constraint strings specify operand
constraints, for example, that an operand must be in a register (the usual case), or that
an operand must be an immediate value.
Constraint letters and modifiers supported by MPLAB C30 are listed in Table 8-1 and
Table 8-2 respectively.
x = asmFunction(0x100, 0x200);
.end
Mixing Assembly Language and C Modules
.global _asmFunction
add w0,w1,w0
return
Note:
Only a single string can be passed to the simple form of inline
assembly.
]);
]
CALLING AN ASSEMBLY FUNCTION IN C
[ : [ "constraint"(input-operand) [ , ... ] ]
[ "clobber" [ , ... ] ]
DS51284F-page 113

Related parts for SW006012