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.
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
