Here is a MIPS Assembly problem. I can't get my code to get the right answers in this problem. We cannot use instructions like "la" or lw $t0 array. Thank you addi $t0, $zero, 7040 # address of the first element of the array addi $t1, $zero, 10 # number of integers in the array lw $t2, 0($t0) # load the first integer in the array loop: addi $t1, $t1, -1 beq $t1, $zero, done addi $t0, $t0, 4 # increment the memory address by 4 bytes to get to the next integer lw $t3, 0($t0) # load the next integer in the array bgt $t3, $t2, update j loop update: move $t2, $t3 # store the larger integer in $t2 j loop done:
Here is a MIPS Assembly problem. I can't get my code to get the right answers in this problem. We cannot use instructions like "la" or lw $t0 array. Thank you addi $t0, $zero, 7040 # address of the first element of the array addi $t1, $zero, 10 # number of integers in the array lw $t2, 0($t0) # load the first integer in the array loop: addi $t1, $t1, -1 beq $t1, $zero, done addi $t0, $t0, 4 # increment the memory address by 4 bytes to get to the next integer lw $t3, 0($t0) # load the next integer in the array bgt $t3, $t2, update j loop update: move $t2, $t3 # store the larger integer in $t2 j loop done:
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
Related questions
Question
Here is a MIPS Assembly problem. I can't get my code to get the right answers in this problem. We cannot use instructions like "la" or lw $t0 array. Thank you
addi $t0, $zero, 7040 # address of the first element of the array
addi $t1, $zero, 10 # number of integers in the array
lw $t2, 0($t0) # load the first integer in the array
loop:
addi $t1, $t1, -1
beq $t1, $zero, done
addi $t0, $t0, 4 # increment the memory address by 4 bytes to get to the next integer
lw $t3, 0($t0) # load the next integer in the array
bgt $t3, $t2, update
j loop
update:
move $t2, $t3 # store the larger integer in $t2
j loop
done:

Transcribed Image Text:6.8 LAB: Find max in an array
Given an array of a specific number of integers, write a program that finds the largest integer and store the result in register Șt2. Assume
Sto stores the memory location of the first element of the array, and $t1 stores the number of integers in the array.
Ex: If $t0 and $t1 are initialized in the simulator as 4000 and 5, and the content of the given array is:
the result is stored in $t2:
Addresses Data
4000
4004
4008
4012
4016
6
4
8
9
7
Registers Data
$12
9
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps

Knowledge Booster
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.Recommended textbooks for you

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education