159k views
2 votes
Write instructions to add two unsigned data bytes, BYTE1 and BYTE2. Begin by clearing three register locations in common GPR memory named ERR_FLAG, LARGE1 and SMALL1. Set all bits to one in the ERR_FLAG register if the sum exceeds the range for an 8 -bit number. If the number is within range for an 8 bit number, store the sum in LARGE1 register if the answer is ≥ 128 and store the sum in SMALL1 if the answer is <128. This program can be executed using the simulator only. Before writing any code, design the program using a flow chart. Include this in the procedure / design section of the lab report. Test your program by trying different values for BYTE1 and BYTE2 to test all three conditions (large answer, small answer, and error condition). Show that all conditions have been tested in your lab report.

User JonatanE
by
7.8k points

1 Answer

4 votes

Final answer:

A program is to be designed to add two unsigned bytes and store the result in specialized registers or set an error flag, depending on the value of the sum. The design involves clearing registers, performing the addition, checking for range, and categorizing the sum.

Step-by-step explanation:

The question involves designing an assembly language program that adds two unsigned data bytes and processes the result according to specified conditions. The program should start with clearing three registers: ERR_FLAG, LARGE1, and SMALL1. Conditions are checked after addition to determine whether the sum exceeds the 8-bit range and to categorize the sum as large (≥ 128) or small (< 128) and store it in the appropriate register.

Procedure/Design

  1. Clear ERR_FLAG, LARGE1, and SMALL1 by setting them to zero.
  2. Add BYTE1 and BYTE2
  3. If the sum is greater than 255, set ERR_FLAG to indicate an error (all bits to one).
  4. Otherwise, check if the sum is greater than or equal to 128. If so, store in LARGE1; if not, store in SMALL1.

Testing Program

Three test cases will be carried out to ensure the program works for all possible outcomes: when the sum is a large number, a small number, and when an error condition (overflow) occurs. The results will be documented in the lab report.

User Eric Gazoni
by
7.7k points