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.
![](/static/compass_v2/shared-icons/check-mark.png)
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
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)