07.04.2013 Views

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

16-Bit C <strong>Compiler</strong> User’s Guide<br />

3.10 NOTABLE SYMBOLS<br />

z = Add(x,y);<br />

return 0;<br />

}<br />

File 2<br />

/* add.c */<br />

#include <br />

unsigned int<br />

Add(unsigned int a, unsigned int b)<br />

{<br />

return(a+b);<br />

}<br />

Compile both files by typing the following at a DOS prompt:<br />

C:\> pic30-gcc -o ex1.o ex1.c add.c<br />

This comm<strong>and</strong> compiles the modules ex1.c <strong>and</strong> add.c. The compiled modules are<br />

linked with the compiler libraries <strong>and</strong> the executable file ex1.o is created.<br />

The 16-bit linker defines several symbols that may be used in your C code development.<br />

Please see the <strong>MPLAB</strong> Assembler, Linker <strong>and</strong> Utilities <strong>for</strong> <strong>PIC24</strong> <strong>MCUs</strong> <strong>and</strong><br />

<strong>dsPIC</strong> ® <strong>DSCs</strong> User’s Guide (DS51317) <strong>for</strong> more in<strong>for</strong>mation.<br />

A useful address symbol, _PROGRAM_END, is defined in program memory to mark the<br />

highest address used by a CODE or PSV section. It should be referenced with the<br />

address operator (&) in a built-in function call that accepts the address of an object in<br />

program memory. This symbol can be used by applications as an end point <strong>for</strong> checksum<br />

calculations.<br />

For example:<br />

__builtin_tblpage(&_PROGRAM_END)<br />

__builtin_tbloffset(&_PROGRAM_END)<br />

_prog_addressT big_addr;<br />

_init_prog_address(big_addr, _PROGRAM_END)<br />

DS51284H-page 62 © 2008 <strong>Microchip</strong> Technology Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!