Professional Documents
Culture Documents
Assignment Week8 PDF
Assignment Week8 PDF
3. For the register values R2=35 and R6=52, after execution of the
instruction “SLT R12,R2,R6”, the contents of R12 will be ………
Correct answer is: 1
The SLT instruction will set the value of register R12 to 1 if R2 < R6, and
will set it to 0 otherwise. In this example, since R2 < R6, R12 will become
1.
4. For the instruction encoding as discussed in the lectures, what will be the
hexadecimal machine code for the instruction “SUBI R21,R17,365”?
a. 32’h2e41003d
b. 32’h2e35016d
c. 32’h2e35017a
d. None of the above
Correct answer is (b).
For the I-type instruction, the various fields of the instruction will be:
001011 10001 10101 0000 0001 0110 1101
(recall that 365 is 016d in hex)
5. For the following code segment, what will be the hexadecimal machine
code for the BEQZ instruction, assuming the instruction encoding as
discussed in the lectures?
Loop: ADD R2,R5,R10
SUI R11,R2,25
MUL R3,R2,R1
ADDI R7,R0,12
BEQZ R11,Loop
a. 32’h39600005
b. 32’f3960fff9
c. 32’h3960fffb
d. None of the above
Correct answer is (c).
It may be noted that when the BEQZ instruction is executed, PC points to
the next instruction. So the target of the branch will be -5. In 16-bit 2’s
complement, -5 is 1111 1111 1111 1011 (i.e. fffd in hex).
Here, the various fields of the instruction will be:
001110 01011 00000 1111 1111 1111 1011