COMPUTER ORGANIZATION+DESIGN >I<
5th Edition
ISBN: 9781541868397
Author: Patterson
Publisher: ZYBOOKS (CC)
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 2, Problem 2.28E
Explanation of Solution
MIPS instruction:
The corresponding MIPS instruction for the given C code is as follows:
#set i = 0
add $t0, $0, $0
#check i < a
Loop1: slt $t2, $t0, $s0
#if "$t2=0" go to "Exit"
beq $t2, $0, Exit
#set j = 0
add $t1, $0, $0
#check j < b
Loop2: slt $t2, $t1, $s1
#if "$t2=0" go to "Loop3"
beq $t2, $0, Loop3
#add the variable "i" and "j"
add $t2, $t0, $t1
#multiply the "j" with 4
sll $t4, $t1, 4
#storing the "&D[4 * j]" to the "$t3"
add $t3, $t4, $s2
#store the addition of "i" and "j" to the "D[4 * j] "
sw $t2, 0($t3)
#add "1" to the variable "j"
addi $t1, $t1, 1
#jump to the loop2
j Loop2
#add "1" to the variable "i"
Loop3: addi $t0, $t0, 1
#jump to the loop1
j Loop1
Exit:
Explanation:
- Initially set the register “$t0” as 0. The “Loop1” will check “i” less than “a”, if the condition is true then it will again check the register “$t2” is equal to 0, here the condition is true it will exit the loop otherwise set the “j” value as 0.
- The “Loop2” will check “j” less than “b”, if the condition is true then it will again check the register “$t2” is equal to 0, here the condition is true it will go to the “Loop3” otherwise add the variables “i” and “j”...
Expert Solution & Answer
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 2 Solutions
COMPUTER ORGANIZATION+DESIGN >I<
Ch. 2 - Prob. 2.1ECh. 2 - Prob. 2.2ECh. 2 - Prob. 2.3ECh. 2 - Prob. 2.4ECh. 2 - Prob. 2.5ECh. 2 - Prob. 2.6.1ECh. 2 - Prob. 2.6.2ECh. 2 - Prob. 2.7ECh. 2 - Prob. 2.8ECh. 2 - Prob. 2.9E
Ch. 2 - Prob. 2.10ECh. 2 - Prob. 2.11ECh. 2 - Prob. 2.12.1ECh. 2 - Prob. 2.12.2ECh. 2 - Prob. 2.12.3ECh. 2 - Prob. 2.12.4ECh. 2 - Prob. 2.12.5ECh. 2 - Prob. 2.12.6ECh. 2 - Prob. 2.13.1ECh. 2 - Prob. 2.13.2ECh. 2 - Prob. 2.13.3ECh. 2 - Prob. 2.14ECh. 2 - Prob. 2.15ECh. 2 - Prob. 2.16ECh. 2 - Prob. 2.17ECh. 2 - Prob. 2.18.1ECh. 2 - Prob. 2.18.2ECh. 2 - Prob. 2.18.3ECh. 2 - Prob. 2.19.1ECh. 2 - Prob. 2.19.2ECh. 2 - Prob. 2.19.3ECh. 2 - Prob. 2.20ECh. 2 - Prob. 2.21ECh. 2 - Prob. 2.22ECh. 2 - Prob. 2.23ECh. 2 - Prob. 2.24ECh. 2 - Prob. 2.25.1ECh. 2 - Prob. 2.25.2ECh. 2 - Prob. 2.26.1ECh. 2 - Prob. 2.26.2ECh. 2 - Prob. 2.26.3ECh. 2 - Prob. 2.27ECh. 2 - Prob. 2.28ECh. 2 - Prob. 2.29ECh. 2 - Prob. 2.30ECh. 2 - Prob. 2.31ECh. 2 - Prob. 2.32ECh. 2 - Prob. 2.33ECh. 2 - Prob. 2.34ECh. 2 - Prob. 2.35ECh. 2 - Prob. 2.36ECh. 2 - Prob. 2.37ECh. 2 - Prob. 2.38ECh. 2 - Prob. 2.39ECh. 2 - Prob. 2.40ECh. 2 - Prob. 2.41ECh. 2 - Prob. 2.42ECh. 2 - Prob. 2.43ECh. 2 - Prob. 2.44ECh. 2 - Prob. 2.45ECh. 2 - Prob. 2.46.1ECh. 2 - Prob. 2.46.2ECh. 2 - Prob. 2.47.1ECh. 2 - Prob. 2.47.2ECh. 2 - Prob. 2.47.3E
Knowledge Booster
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY