You are on page 1of 5

ECE 120L

Name: Raymundo Aguilera

Date: February 13, 2013

Lab Experiment:2

Grade:_________________

Statement of Objectives
This lab is designed to get us acquainted with the assembly language syntax by making
us perform certain logic and mathematical operations. By performing these operations, it gets us
acquainted of how to operate the MPLab software and how the software should look while
performing operations.

Theory
The syntax that must be known in this lab is as follows:
MOVLW- this command moves the literal that is given into the working register. The working register is
pretty much a buffer because the working register is always changing.
SUBLW- this command subtracts what is in the working register by the literal that is given. The flags that
could be affected by this command are the Z, C, and DC flags.
ADDLW- this command adds what is in the working register with the literal given. The flags that could be
affected by this command are the Z, C, and DC flags.
ANDLW- this command does logic AND to the literal that is given and the value in the working register.
The only flag that could be affected by this command is the Z flag.
IORLW- this command does logic OR to the literal that is given and the value in the working register. The
only flag that could be affected by this command is the Z flag.
XORLW- this command does logic XOR to the literal that is given and the value in the working register.
The only flag that could be affected by this command is the Z flag.
MOVWF- this command moves what is in the working register to the file address that is given.

MOVF this command moves the file into the register that is specified.

Lab Equipment
-Laptop
-Mplab v8.89 software

Experimental Procedure
The first thing that was needed to be done was to do all the problems by hand. By doing
the problems by hand we are able to have some values that we hope to acquire once our program
is running. Also, by doing the problems by hand we are able to calculate C, DC, Z flags. This is
important because by knowing the C, DC, Z values we are able to have expected values for our
status register.
Then, we load up the header file and sample file from last weeks lab into our new project.
The header file stays the same. The sample file acts as a template for our new program. After we
created a new project in Mplab, we were ready to start coding. Each operation was performed
with 5 lines. All were similar in concept but had different literals and different addresses.

The first line puts a literal in the working register. This literal can either be used for an
address or for an operation. For this lab, the literal was used in an operation. The second line

subtracts the working register value with the literal given in the second line. At this point, the
result of the subtraction is in the working register. The third line moves the result, which is in the
working register, to a specified file address. The fourth line moves what is in the status register
into the working register. We are interested in the status register because the status register keeps
track of the Z,C, and DC flag bits. The fifth line moves what is in the working register to a file
address.
The same procedure was followed for all 8 operations. The only thing that varied in each
operation was the literal values, address locations, and math/logic command.
The last step, once the program was written, was to run the program and to simulate the
file register. In this step is where you confirm your expected values with the values obtained.

Experimental Results

The results obtained were exactly the results that were expected. These results confirmed
that I did my operations correctly by hand and that my code had no syntax errors. This lab was a
success.

Conclusion
I came into this lab with minimal knowledge of assembly language. I had no idea what
most of the terms meant and I did not know the procedure to complete my program. I did not
know what a status register did. I did not know what the commands meant. After this lab,
however, I can explain to you how the status register and working register work. I can also
explain to you how perform an operation in assembly language. I was lost and I did not
understand much of the assembly language and the syntax. After this lab, I have a better
understating of assembly language, its syntax, and its registers.

You might also like