Problem 4 In this problem, you will write LC-3 assembly code to calculate some s
ID: 3817447 • Letter: P
Question
Problem 4
In this problem, you will write LC-3 assembly code to calculate some statistics about the
performance of 30 students in a class, based on their scores for an exam.
Assume that the scores of the 30 students are present in contiguous memory locations,
starting at 0x4000.
For each of the following, your program must implement subroutines. Failure to do so will
result in deduction of points even if you get the correct results.
1) Implement a subroutine MAX_SCORES to find the highest score obtained by a
student and store this value in the memory location 0x5000.
2) Implement a subroutine MIN_SCORES to find the lowest score obtained by a student
and store this value in the memory location 0x5001.
3) Implement a subroutine AVG_SCORES to calculate the average score of the class
and store this value in memory location 0x5002. If the average score is a fraction,
round it off to the next higher integer. For example, if the average turns out to be
30.22, the average should be rounded off to 31.
4) Implement a subroutine BELOW_AVG to calculate the number of students who have
scored below the class average (which has been rounded off), and store this value in
memory location 0x5003.
Your code should start at memory location 0x3000. You can assume there is no overflow
of integers at any step.
Explanation / Answer
INCR LD R0, i ; get i
ADD R0, R0, #1; increment it
ST R0, i; save the new value
BR TEST; go back and test again
END; code after loop completes
STI R0, MAX_SCORES_0x5000; Store the value of R0 into mem[0x5000]
answer of 2):
INCR LD R0, i ; get i
ADD R0, R0, #1; increment it
ST R0, i; save the new value
BR TEST; go back and test again
END; code after loop completes
STI R0, MIN_SCORES_0x5001; Store the value of R0 into mem[0x5001]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.