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

what is the correct program in binary form? Write a simple LC-3 program to perfo

ID: 673191 • Letter: W

Question

what is the correct program in binary form?

Write a simple LC-3 program to perform the following operations. Store your Machine Language program originate at x3000.

You can set the value of memory location x3100 before you run your program on the LC-3 simulator. On UNIX machines (Sun, Linux) you can do this by using the "Set Values" option on the menubar and selecting the "Set Register or Memory" option. On Windows machines, you can click on "Simulate" in menubar and select "Set Value". Instead, you can just press F4 and the "Set Value" dialog box will pop up. Do not overwrite the original value in x3100 in any following steps unless otherwise mentioned.

First, determine if the content of memory location x3100 is even or odd Store x0001 in memory location x3101 if it is odd, or x0000 if it is even.

Next, count the number of 1s in memory location x3100 and store the count in x3102.

Notes and Suggestions:

The first line of your programs must specify the memory address of the first instruction of your program. LC-3 simulator will place your program starting at that address. For this assignment, you should place your program starting at x3000 (the first line of your program should contain the bit pattern 0011000000000000).

Explanation / Answer

Hi,

Below is the solution to your question:

Values of X and Y are loaded into registers R1 and R3

1.ORIG x3000 ;This is the address where the program actually begins

2.LEA R2 , xFF ; R2 x3000 + x1 + xFF (= x3100 )

3.LDR R1 , R2 , x0 ; R1 MEM[ x3100 ]

4.LDR R3 , R2 , x1 ; R3 MEM[ x3100 + x1 ]. . .

5.AND R4 , R4 , x0 ; Clear R4

6.ADD R4 , R4 , x5 ; R4 5

7.STR R4 , R2 , x1 ; MEM[ x3100 + x1 ] R4

AND R2 , R1 , x0001 //Determining whether a number is odd or even

Example Run with the values given above:

Address Decimal Hex Binary Contents

  x3100 9 0009 0000 0000 0000 1001 X

x3101 -13 FFF3 1111 1111 1111 0011 Y

     x3102 -4 FFFC 1111 1111 1111 1100 X +Y

x3103 1 0001 0000 0000 0000 0001 X AND Y

x3104 -5 FFFB 1111 1111 1111 1011 X OR Y

x3105 65526 FFF6 1111 1111 1111 0110 NOT(X)

x3106 12 000C 0000 0000 0000 1100 NOT(Y)

x3107 12 000C 0000 0000 0000 1100 X +3

x3108 -16 FFF0 1111 1111 1111 0000 Y 3

x3108 1 0001 0000 0000 0000 0001 z   

Hope that answers your question.HAPPY ANSWERING!!!!!