PIC is the name for the Microchip microcontroller (MCU) family, consisting of a microprocessor, I/O ports, timer(s) and other internal, integrated hardware. The main advantages of using the PIC are low external part count, a wide range of chip sizes (now from 5-pin up!) available, nice choice of compilers (assembly, C, BASIC, etc.) good wealth of example/tutorial source code and easy programming. Once bought, the PIC's program memory is empty, and needs to be programmed with code (usually HEX files) to be usable in a circuit.
Q: What can I do with the assembly source code for the PIC microcontroller?
A: First, you need a compiler, which takes the source
code in the form of asm (assembly), inc (include), and lkr (linker script)
files. You can compile microchip assembly files with gputils or mpasm,
part of MPLAB.
(Gputils are command line utilities, mplab is a graphical development
environment)
The compiler will output a hex file, suitable for programming into
the device. You need a programmer device for that. It is an interface
between the computer and the microcontroller. I recommend using the
Pickit 2
or 3 this purpose.
Please read the pcbheaven pic
pages to get started with compiling code and programming the PIC
microcontrollers.
Q: How do I compile a HEX file from multiple source files (linked project or relocatable code) ?
A: Start MPLAB-X, and select file/new project.
Select "Microchip Embedded" in Categories and "Standalone Project" in
Projects. Click next, select the target microcontroller you see in the
circuit diagram (for example, PIC16F628). Click next, ignore Select
Header, and click next again. Select "Simulator" in "Hardware Tools" as
Tool. Click next, and select "mpasm (version) for Compiler. Click next
and enter a project name. Click Finish. Select Window/Projects. In the
projects window, use the actual project, and ignore others (if there
are any). Right-click "Linker files", select "Add existing item" and
add the linker script (*.lkr) to the project. In the projects window, right-click "Source files",
select "Add existing item" and add all assembly (*.asm) files to the
project. Right-click the actual project name and select "Build". You
will see the compilation output in the "Output window".
Q: Where is all this assembly language documented?
A:You can find the PIC microcontroller instruction set documentation in the microcontroller datasheets at microchip.com. The PIC12, PIC16, PIC18, PIC24, PIC32 families of microcontrollers have different instruction sets. In addition, the general syntax of the code (labels, variables, macros, etc.) is described in the mpasm documentation.