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

For this machine problem, you will be writing a program in the LC-3 machine lang

ID: 3623880 • Letter: F

Question

For this machine problem, you will be writing a program in the LC-3 machine language that reads a 16-bit pattern from memory, analyzes it, and produces two 16-bit outputs, each having the same number of ones and zeros as the original input, but arranged in a particular order: the first with all of the ones in its most significant bits, and the second with all of the ones in its least significant bits. Memory location x4000 will contain the address from which the input should be loaded (i.e., not the input value itself, but the address where you will find it) and your program should store the first output (with the ones stored in the most-significant bits) at x4001 and the second output (with the
ones stored in the least-significant bits) at x4002. Your program must start memory location x3000.

Example 1:
If the relevant parts of the LC3 memory before your program starts look like this:
Memory address Interpretation Value
x4000 Address of Input x5000
x5000 Input 0001 1011 1100 0100 = x1BC4
Then the memory at x4001 and x4002 after your program finishes should look like this:
Memory address Interpretation Value
x4001 Most-Significant Output 1111 1110 0000 0000 = xFE00
x4002 Least-Significant Output 0000 0000 0111 1111 = x007F

Explanation / Answer

1. Initialize registers

.orig x3000

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