User`s guide
MPLAB
®
IDE User’s Guide
DS51519B-page 16 © 2006 Microchip Technology Inc.
1.4 LANGUAGE TOOLS
Language tools are programs such as cross-assemblers and cross-compilers. Most
people are familiar with language tools that run on a PC such as Visual Basic or C com-
pilers. When using language tools for embedded systems, a “cross-assembler” or
“cross-compiler” is used. These tools differ from typical compilers in that they run on a
PC but produce code to run on another microprocessor, hence they “cross-compile”
code for a microcontroller that uses an entirely different set of instructions from the PC.
The language tools also produce a debug file that MPLAB IDE uses to correlate the
machine instructions and memory locations with the source code. This bit of integration
allows the MPLAB IDE editor to set breakpoints, allows watch windows to view variable
contents, and lets you single step through the source code, watching the application
execute.
Embedded system language tools also differ somewhat for compilers that run and exe-
cute on a PC because they must be very space conscious. The smaller the code pro-
duced, the better, because that allows the smallest possible memory for the target,
which reduces cost. This means that techniques to optimize and enhance the code
using machine specific knowledge are desirable. The size of programs for PCs typically
extends into the megabytes for moderately complex programs. The size of simple
embedded systems programs may be as small as a thousand bytes or less. A medium
size embedded system might need 32K or 64K of code for relatively complex functions.
Some embedded systems use megabytes of storage for large tables, user text
messages or data logging.
FIGURE 1-7: A COMPILER CONVERTS SOURCE CODE INTO MACHINE
INSTRUCTIONS
int main (void)
{
counter = 1;
TRISB =0;
while (input1 = 0)
{
PORTB = count;
counter++;
}
}
COMPILER
01101111
10001000
11001101
10100001
00110011
01011101
00110001
11100101