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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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. 

Expert Solution
Step 1

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

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Basics of loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education