1. Consider the following java code. int x = 5; x++; Give equivalent MIPS ISA. A
ID: 3900801 • Letter: 1
Question
1.
Consider the following java code.
int x = 5;
x++;
Give equivalent MIPS ISA. Assume compiler will keep x in $s0 ($16).
2.
What will be in $8 after executing the following statements?
addi $8, $0, 5
add $8, $8, $8
1. What will be in $8 after execution?
addi $8, $0, 5
sll $8, $8, 2 // shifting $8 left twice (logical shift- assume no sign)
4. What will be in $8 after execution?
Assume $9 contains a valid RAM address.
addi $10, $0, 5
sw $10, 8($9)
addi $9, $9, 8
lw $8, 0($9)
5.
Consider the SPIM code below.
.globl main
.text
main:
ori $t1, $0, 10
ori $t2, $0, 11
add $t3, $t1, $t2
move $t4, $t3
The following image shows a screen shot of QtSPIM page when this program is loaded, and executed in step-by step fashion. Current instruction is highlighted.
What will be the next PC value?
move is not included in MIPS ML. How it is converted?
Register R9 contains a – why?
What will be R12 after next 3 instructions are executed?
Consider the following line. What is 012a5820 stands for?
012a5820 add $11, $9, $10
Explanation / Answer
Q 1)
MIPS Assembly code:
addi $16,$0,5 #addi is adds immediate i.e. $0 is zero adds the value 5 and stores in $16
addi $16,$16,1 #addi adds the value of $16 i.e 5 to the 1 and the value is stored in $16 . it is equal to the incrementation.
Q 2)
first line is similar to the first line in above question i.e
$8 is assigned with the value of 5.
and second line
add $8,$8,$8 #in this the value of $8 is added with the value of $8 i.e., 5+5 =10 is stored in $8
$8 has the value of 'a" i.e., 10.
Q 3)
sll is shifts the logical binary value to the left.
deciamal( 5 )- binary (0000 0101)
in the above line it represent the value will be shifted 2 digits left
i.e., binary(0001 0100) and in decimal value is "20"(converted through binary to deciaml conversion method).
$8 has the decimal value of 20.
Q 5)
PC is program counter
Instruction no. PC value
1 0x00400004
1 0x00400008
1 0x0040000c
1 0x00400010
move is converted int the addu (add unsigned(with no overflow))
move $t4,$t3 is converted into " addu $12,$0,$11"
Register R9 is $t1 in the first instruction $0 and immediate value 10 is OR and result is stored in $t1
where the value of 10 in hexadecimal is "a" therefore register r9 contains value a.
Register R12 is $t4 which is not altered and assigned until the last instruction.
When last instruction is execute value of $t3 is stored to $t4 in hexadecimal(0x15) where in decimal value is 21.
012a5820 is the hexadecimal code to the instruction present
binary value of that is "00000001001010100101100000100000"
000000 first 6 bits are special bits
01001 the value of $9
01010 the value of $10
01011 the value of $11
00000 value is zero
100000 this is the instruction code for add
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.