SW500010 Microchip Technology, SW500010 Datasheet - Page 101

HI-TECH C PRO FOR PIC10/12/16

SW500010

Manufacturer Part Number
SW500010
Description
HI-TECH C PRO FOR PIC10/12/16
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC10/12/16r
Datasheets

Specifications of SW500010

Supported Families
PIC10, PIC12, PIC16
Core Architecture
PIC
Software Edition
Professional
Kit Contents
Software And Docs
Mcu Supported Families
PIC10/12/16
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC10, PIC12, PIC14, PIC16, PIC16E
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
019P
778-1006
778-1006
C Language Features
A mapping is performed on the names of all C functions and non-static global variables. See
Section
callable from C code. Both the values are passed in as arguments when the routine is called from the
C code. The assembly routine should return the result of the addition as a 16-bit quantity.
As we do not need to have this assembly routine linked at any particular location, we can use this
psect so the code is bundled with other executable code and stored somewhere in the program space.
This way we do not need to use any additional linker options. So we use an ordinary looking psect
that you would see in assembly code produced by the compiler. The psect’s name is text0, will be
linked in the CODE class, which will reside in a memory space that has 2 bytes per addressable
location:
_add as this then maps to the C identifier add since the compiler prepends an underscore to all C
identifiers when it creates assembly labels. If the name add was chosen for the assembler routine
the it could never be called from C code. The name of the assembly routine is the label that we will
associate with the assembly code:
sembly routine, we can determine the signature value. We add a assembler directive to make this
signature value known:
parameter area by the calling function, and the result should be placed in btemp.
An assembly routine is required which can add two 16-bit values together. The routine must be
Most compiler-generated executable code is placed in a psect called textn (see Section 3.8.1).
PSECT text0,local,class=CODE,delta=2
Now we would like to call this routine add. However in assembly we must choose the name
_add:
We need to be able to call this from other modules, some make this label globally accessible:
GLOBAL _add
By compiling a dummy C function with a similar prototype to how we will be calling this as-
SIGNAT _add,8298
When writing the function, you can find that the parameters will be loaded into the function’s
ensure any symbol used to hold arguments to the routine is globally accessible
ensure any symbol used to hold a return value is globally accessible
optionally, use a signature value to enable type checking when the function is called
write the routine ensuring arguments are read from the correct location, the return value is
loaded to the correct storage location before returning
ensure any local variables required by the routine have space reserved by the appropriate
directive
3.10.3.1
for a complete description of mappings between C and assembly identifiers.
Mixing C and Assembler Code
101

Related parts for SW500010