Given the code below: loop: slt $t2, $0, $t1 beq $t2, $0, done addi $t1, $t1, -1 addi $s2, $s2, 2 j loop done: Assume $t1 =10, $s2=0 What is in $s2 after executing this loop? No justification no credit. Show your work.
Given the code below:
loop: slt $t2, $0, $t1
beq $t2, $0, done
addi $t1, $t1, -1
addi $s2, $s2, 2
j loop
done:
Assume $t1 =10, $s2=0
What is in $s2 after executing this loop? No justification no credit. Show your work.
The given code is :
loop: slt $t2, $0, $t1
beq $t2, $0, done
addi $t1, $t1, -1
addi $s2, $s2, 2
j loop
done:
We have given , $t1 = 10 , $0 = 0
In the above code we have following instruction
1) slt(Set on Less Than) :- The SLT instruction sets the destination register's content to the value 1 if the first source register's contents are less than the second source register's contents. Otherwise, it is set to the value 0.
It's syntax is:
slt $destination register's addres,$first source register's address,$second source register's address
2) beg :- It is conditinal branch instruction which is use for branching i.e if the condition are true then it will take branch otherwise it will not take branch .
It's syntax is :
beg $first register's address , second register's address , target
Branch to target if $first register's address == second register's address
3) addi : This instruction is to add a immediate data to source register and store it to destination register
It's syntax is :
addi $destination register's addres, $source register's address, Immediate data
4) loop : It is basically a instruction which is used for the excecution of loop
Step by step
Solved in 4 steps with 3 images