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.
.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?
.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?
Note: OP can be ADD or MUL for the purposes of this problem.
.ORIG x4000 AND R1, R1, #0 ADD R1, R1, #5 LSHF R1, R1, #12 LDW R2, R1, #0 RSHFL R3, R2, #8 LSHF R4, R2, #8 ADD R2, R3, R4 STW R2, R1, #1 HALT
.ORIG x4000 AND R1, R1, #0 ADD R1, R1, #5 LSHF R1, R1, #12 LDB R2, R1, #0 STB R2, R1, #3 LDB R2, R1, #1 STB R2, R1, #2 HALT