Instructions:
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.
Classify the following attributes of LC-3b as either a property of its microarchitecture or ISA:
.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 x4000This 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?
MAIN LEA R2,L0
JSRR R2
JSR L1
HALT
;
L0 ADD R0,R0,#5
RET
;
L1 ADD R1,R1,#5
RET
Address | Data |
---|---|
x1005 | x0A |
x1004 | x0B |
x1003 | x0C |
x1002 | x11 |
x1001 | x1A |
x1000 | x0E |
x0FFF | x25 |
x0FFE | xA2 |
Note: OP can be ADD or MUL for the purposes of this problem.
Opcode | 7 6 5 | 4 3 | 2 |
1
0 |
ADD |
0
0 0 |
D R |
A |
S R |
AND |
0
0 1 |
D R | A | S R |
**BR(R) |
0 1 0 | N
Z |
P |
Base Reg |
* LDImm |
0
1 1 |
signed immediate |
||
* LEA |
1 0 0 |
signed offset |
||
LD |
1
0 1 |
D R | X |
B R |
ST |
1 1 0 | S R | X |
Base Reg |
NOT |
1
1 1 |
D R | X |
X
X |