Professional Documents
Culture Documents
A- Preparing
1
Microlab File 1 – by Joseph Massoud
2
Microlab File 1 – by Joseph Massoud
6- Save as name.asm:
Press “Save as” and go to microlab folder;
Write: lab1.asm in the file name (the extension .asm is obligatory).
Press “save”
3
Microlab File 1 – by Joseph Massoud
4
Microlab File 1 – by Joseph Massoud
5
Microlab File 1 – by Joseph Massoud
6
Microlab File 1 – by Joseph Massoud
D- Compiling ( Build)
7
Microlab File 1 – by Joseph Massoud
12- You can at anytime change the size of the instructions (for a clearer vision); the
size comes 8 by default; We recommend to make it 12 using : “edit”/”properties
8
Microlab File 1 – by Joseph Massoud
F- Additional processes:
Let us assume we have some syntax (typing) errors in our program. This will
result in build failed instead of build succeeded.
We will assume the following errors in our program ( create these errors on
your code)
Error1:
BSF STATUS, RPO instead of BSF STATUS, RP0 (using letter O instead
digit 0 )
Error 2:
MOVWF PORT D instead of MOVWF PORTD (using a space between
PORT and D)
9
Microlab File 1 – by Joseph Massoud
After we press on the first error line the system goes to main page and points to
the line of error:
10
Microlab File 1 – by Joseph Massoud
We correct the first error (replacing RPO by RP0) , press “Quickbuild” again, and
we obtain:
We repeat the same process for the next error (double clicking the second line of
error) :
11
Microlab File 1 – by Joseph Massoud
We correct the error (PORTD as one word) and press “Quickbuild” again.
12
Microlab File 1 – by Joseph Massoud
To close MPLAB we press the red X on the top right. (Note: if we are asked to
save we choose yes).
“File” / “open”
13
Microlab File 1 – by Joseph Massoud
14
Microlab File 1 – by Joseph Massoud
15
Microlab File 1 – by Joseph Massoud
The figure below represents memory organization of the PIC (register file map)
Datasheet page 15
16
Microlab File 1 – by Joseph Massoud
Datasheet page 19
17
Microlab File 1 – by Joseph Massoud
18
Microlab File 1 – by Joseph Massoud
19
Microlab File 1 – by Joseph Massoud
20
Microlab File 1 – by Joseph Massoud
21
Microlab File 1 – by Joseph Massoud
22
Microlab File 1 – by Joseph Massoud
23
Microlab File 1 – by Joseph Massoud
Hint: in question (d )we use instruction SUBLW which executes L - W ( not W- L).
So this instruction handles numbers oppositely; Therefore we should load first the
number 2 to W and then write sublw with 9, in order to have 9-2
END of file 1
24