Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

Steps

  1. 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.

  1. 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.

.

  1. 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.

  1. 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:

SUM MACRO

------- -----------

------- -----------

EMAC

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.

  1. 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.

  1. Document and submit your final report along with the well documented list file. Also describe the steps and tools used in debugging your program.

  1. 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

Here the first integer uses code memory location 100H, 101H and 102H, let the value will be held in R1,R2 and R3. R1 for lower bytes, R3 for the higher bytes.

Similarly, the second integer uses 105H, 106H and 107H. Let the lower 8bits will stored in R4 and next 8bits in R5 and upper byte in R6.

Now first of all the data at address location should moved to respective registers,

main:

MOV R1,[100] ; move value at address 100 to R1

MOV R2,[101] ; move value at address 101 to R2

MOV R3,[102] ; move value at address 102 to R3

MOV R4,[105] ; move value at address 105 to R4

MOV R5,[106] ; move value at address 106 to R5

MOV R6,[107] ; move value at address 107 to R6

;Now, Step 1:Add lower bytes R1 and R4 and leave the answer in P0

mov A,R1 ;move lower byte to the accumulator

add A,R4 ;add second lower byte to the accumulator

mov R7,A ;move answer to the lower byte of result

;Step 2:Add next bytes R2 and R5 and leave the answer in P1 and add carry from step 1

mov A,R2 ;move next byte to the accumulator

add A,R5 ;add second 8 bits to the accumulator

mov P1,A ;move answer to the next 8 bits of result

;Step 3:Add next bytes R3 and R6 and leave the answer in P2 and add carry from step 2

mov A,R3 ;move high byte to the accumulator

add A,R6 ;add second high bytes to the accumulator

mov P2,A ;move answer to the high bytes of result

step 4: Put any carry from step 3 in final R9

MOV A,#00h ;By default, the highest byte will be zero. ADDC A,#00h ;Add zero, plus carry from step 2. MOV R9,A ;move answer to R9 To perform two multi bytes integer upto 16 bytes

steps involved in this are:

Add the low bytes R1 and R3, leave the answer in R5. Add the high bytes R2 and R4, adding any carry from step 1, and leave the answer in R6. Put any carry from step 2 in the final byte, R7. ;Load the first value into R1 and R2 MOV R1,lowbyte of 1st integer stored in P3 MOV R2,highbyte of 1st integer stored in p3

;Load the second value into R3 and R4 MOV R3,lowbyte of 2nd integer stored in P3 MOV R4,highbyte of 2nd integer stored in P3

;Call the 16-bit addition routine LCALL sum16 sum16: ;Step 1 of the process MOV A,R1 ;Move the low-byte into the accumulator ADD A,R3 ;Add the second low-byte to the accumulator MOV R5,A ;Move the answer to the low-byte of the result

;Step 2 of the process MOV A,R2 ;Move the high-byte into the accumulator ADDC A,R4 ;Add the second high-byte to the accumulator, plus carry. MOV R6,A ;Move the answer to the high-byte of the result

;Step 3 of the process MOV A,#00h ;By default, the highest byte will be zero. ADDC A,#00h ;Add zero, plus carry from step 2. MOV MOV R7,A ;Move the answer to the highest byte of the result

Do the missing steps please

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

Q: Is your system characteristic of the Israeli workplace?

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago