1. Write an LC-3 assembly language program that counts the number of 1s in the v
ID: 3785171 • Letter: 1
Question
1. Write an LC-3 assembly language program that counts the number of 1s in the value stored in R0 and stores the result in R1. For example, if R0 contains 0001001101110000, then R1 should store the value 6.
2. The following program adds the values stored in memory locations A, B and C, and stores the result into memory. There are two errors in the code. For each, describe the error and indicate whether it will be detected at assembly time or 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 R1, SUM
9. HALT
10. A .FILL x0001
11. B .FILL x0002
12. C .FILL x0003
13. D .FILL x0004
14. .END
Explanation / Answer
A, B, C are stored result in R1. It's conflicted when sum
There is no code for sum : assembly time error
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.