Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 4 (12 points) In this problem, you will write a LC3 program that will pe

ID: 3776461 • Letter: P

Question

Problem 4 (12 points) In this problem, you will write a LC3 program that will perform computation on a subset of numbers stored in memory starting atx3200. You can assume that there are exactly 50 numbers stored in memory, starting x3200. Your program should be able to perform the following operations: 1. ADD a subset of numbers 2. OR a subset of numbers 3. COUNT the numbers in the subset which are positive (>0) Your program must implement a subroutine for each of these operations, and use these subroutines to perform the operation. The subroutines should be named as follows: I. ADD SUBSET NUM 2. OR SUBSET NUM 3. COUNT SUBSET POS Your program should read the command, the start index, and the end index of the subset from memory locations starting x3300 (as shown below), and store the result in memory locations starting x3400. The value of the command, and the operation corresponding to it is as follows: Add the numbers in the subset 2 OR the numbers in the subset Count the numbers in the subset 0 4-Stop The command, start index and end index are stored consecutively in memory. An example memory layout is shown below: x3300 1 Command, 1 ADD x3301 5 Start index for ADD x3302 8 End index for ADD

Explanation / Answer

The following program adds the values stored in memory location A,B,C and stores the result in to memory.There are two errors in the code.for each described the error and indicated whether it will be detected at assembly time or at run time.

1. .ORIG x3000

2. ONE LD R0, A

3. ADD R1, R1, R0

4. TWO LD R0, B

5. ADD R1, R1, R0

6.THREE LD R0, C

7. ADD R1, R1, R0

8. ST R1M SUM

9. TRAP x25

10. A .FILL x0001

11. B .FILL x0002

12. C .FILL x0003

13. D .FILL x0004

14. .END

Bug1.(line 3) R1 is not initialized before being used.This bug can only be detected by debugging at run time.

Bug2.(line 8) Actually there are two bugs here.'R1M' is not valid it's a typo.symbol 'SUM' is not defined.These two bugs will be detected at assembly time.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote