LAB1, 2, and 3 – Using Subroutines and Macros
(Part 1, 2, and 3)
The purpose of this lab is to program the MC8051 to add multi bytes
two signed integers. To simplify our laboratory, we will assume three
bytes long (24 bits) signed integers. Each of the three bytes will be
defined in three consecutive code memory bytes using the “DB”
assembler directive. The program will store the answer in three
consecutive data memory bytes starting at Ram address 40H. The
program will also display the answer on P0, P1, and P2 staring with
the LS Byte in P0. Port 3 pin 0 (P3.0) will be set if an overflow takes
place, otherwise it will stay cleared. Three versions of the program
will be implemented starting with all code included in one main
program. The second implementation will employ two subroutines to
make advantage of the repeated code blocks. The final
implementation will utilize two Macros to reduce the size of the
source program and improve its readability.
First, configure your code and data memory. The “MAIN:” program
starts at code memory location 30H. The first integer uses code
memory locations 100H, 101H, and 102H in the Intel MC8051 little
endian format. The second integer uses code memory locations
105H, 106H, and 107H.
Second, configure parallel port 0, port 1, port 2, and P3.0 for output.
Write and debug the code to add the two integers and store the
answer in data memory locations 40H, 41H, and 42H. Update P0, P1,
and P2 to display the same addition result. Flag an overflow
condition on P3.1 by setting it.
Third, rewrite the program utilizing subroutines to make use of the
repeated code blocks. Define the created. Subroutines after the main
program before the program “END” directive.
Fourth, rewrite the program utilizing Macros to make use of the
repeated code blocks. Define the created. Macros before the main
program code. Unlike labels, the assembler will issue an error if
Macros are not defined before they get referenced. Every Macro must
end with “EMAC” directive. The Macro starts by its name followed by
the word “MACRO”. Example of a “SUM” Macro is the following:
Type the name of the Macro at desired locations in your
assembly source program as needed for the assembler to
insert the Macro object code in the final object file.
Fifth, check the three programs for different integers and verify the
overall operations. Make sure to test cases producing an overflow.
Also make use of break points in the Keil debugger to enhance and
speed up the checkout.
Document and submit your final report along with the well
documented list file. Also describe the steps and tools used in
debugging your program.
Describe how to modify / redesign your program to perform the
addition of two multi bytes integers up to 16 bytes long; one stored at
code memory starting address of 100H and the other at 110H. The
length of the two integers is input from port 3 (P3). The answer is
stored at data memory starting at address 40H through 4FH.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more