Specifications
mikroElektronika | Free Online Book | PIC Microcontrollers | Appendix A: Programming a Microcontroller
Main ; Main program
call Add16 ; Call subroutine Add16
Loop goto Loop ; Remain here
Add16 ; Subroutine to add two 16-bit numbers
clrf RESH ; RESH=0
movf ARG1L,w ; w=ARG1L
addwf ARG2L,w ; w=w+ARG2L
movwf RESL ; RESL=w
btfsc STATUS,C ; Is the result greater than 255?
incf RESH,f ; If greater, increment RESH by one
movf ARG1H,w ; w=ARG1H
addwf ARG2H,w ; w=w+ARG2
addwf RESH,f ; RESH=w
return ; Return from subroutine
end ; End of program
In Short
The main difference between macros and subroutines is that macro is after compiling replaced by its code (enables the
programmer to type less). It may also have arguments while subroutine uses less memory, but does not have arguments.
MPLAB
MPLAB is a Windows program package which enables easy program writing as well as easy program development. It is best
to describe it as development environment for a standard program language designed for PC programming. MPLAB
technically simplifies some operations consisting of a lot of parameters, which, until the IDE environment* appeared, were
executed from the command line. However, tastes are different and there are some programmers who prefer standard
editors and command line compilers. Every program written in MPLAB is clear, but there are also help documentation- just
in case.
INSTALLING MPLAB
MPLAB consists of several parts:
● The program which sorts data files of the same project into one group (Project Manager);
● program for text generating and processing (Text Editor); and
● simulator used to simulate the operation of a program loaded into the microcontroller.
Besides, there are also built in programmers such as PICStart Plus and ICD (In Circuit Debugger) that can be used to
program software into PIC microcontroller device. Since not being the subject of this book, they are mentioned as options
only.
In order to start MPLAB, your PC should contain:
● PC compatible computer belonging to class 486 or better;
● Any Windows operating system;
● VGA graphic card;
● 8MB memory (32MB recommended);
● 200MB available hard disc; and
● A mouse.
MPLAB installation comes first. Data files from MPLAB CD should be copied to a hard disc. The process of installation is
similar to almost all other Windows program installations. First of all a welcome window appears, then options to select
and at last installation itself. A message notifying that the program is successfully installed and ready for use appears. Are
you ready?
Steps to follow prior the installation:
1. Start Microsoft Windows;
2. Insert the CD into CD ROM;
3. Click START and select option RUN;
4. Click BROWSE and select CD ROM drive; and
5. Find folder MPLAB on CD ROM.
Everything is ready now to start installation. The following pictures describe the installation steps.
http://www.mikroe.com/en/books/picmcubook/appa/ (10 of 21)5/3/2009 11:35:35 AM