You are encouraged to work on the problem set in groups and turn in one problem set for the entire group. Remember to put all your names on the solution sheet. Also remember to put the name of the TA in whose discussion section you would like the problem set turned back to you.
Both of the following programs cause the value x0004 to be stored in location x3000, but they do so at different times. Explain the difference.
.ORIG x3000 .FILL x0004 .END
.ORIG x4000 AND R0, R0, #0 ADD R0, R0, #4 LEA R1, A LDW R1, R1, #0 STW R0, R1, #0 HALT A .FILL x3000 .END
What does the ADD instruction do that the others do not do?
Consider the following LC-3b assembly language program:
.ORIG x3000 AND R5, R5, #0 AND R3, R3, #0 ADD R3, R3, #8 LEA R0, B LDW R1, R0, #1 LDW R1, R1, #0 ADD R2, R1, #0 AGAIN ADD R2, R2, R2 ADD R3, R3, #-1 BRp AGAIN LDW R4, R0, #0 AND R1, R1, R4 NOT R1, R1 ADD R1, R1, #1 ADD R2, R2, R1 BRnp NO ADD R5, R5, #1 NO HALT B .FILL XFF00 A .FILL X4000 .END
.ORIG x4000 MAIN LEA R2,L0 JSRR R2 JSR L1 HALT ; L0 ADD R0,R0,#5 RET ; L1 ADD R1,R1,#5 RETThis program shows two ways to call a subroutine. One requires two instructions: LEA, JSRR. The second requires only one instruction: JSR. Both ways work correctly in this example. Is it ever necessary to use JSRR? If so, in what situation?
Write an LC-3b program that swaps the values in R1 and R2 without using any other registers. Make sure that your program works for any possible values in R1 and R2.
Note: OP can be ADD or MUL for the purposes of this problem.