MIPS using the MARS simulator. This is the code I have so far. Can someone help explain how to know how to store the input for the index input into the desired index and
MIPS using the MARS simulator. This is the code I have so far. Can someone help explain how to know how to store the input for the index input into the desired index and
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
Topic Video
Question
I am writing in MIPS using the MARS simulator. This is the code I have so far. Can someone help explain how to know how to store the input for the index input into the desired index and then how to print each index?
![.data
arr:
space 16
#This is 16 bytes, or 4 words
messg1: .asciiz "Please enter a number!:
colon:
asciiz ": "
endline:.asciiz "\n"
messg2: .asciiz "Which element of the array would you like this to be?: "
.text
main:
#print first propmpt to user
$a0, messg1
$v0, $zero, 4
la
la is Load Address
#Set up my message as an argument
#Specify system call 4 to print
#make the system call
addi
syscall
#this will read my first integer
$v0, $zero, 5
addi
#set up syscall to read number in from command line
syscall
add $t0, $v0, $zero
#move number that was just entered into register $t0
#print 2nd prompt to user
$a0, messg2
$v0, $zero, 4
#Set up my 2nd message as an argument - la is Load Address
#Specify system call 4 to print
#make the system call
la
addi
syscall
Line: 4 Column: 40
Show Line Numbers](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd104ea5e-59f4-47a3-a0d3-8c9f1ad3b57c%2F83f1b7ed-397c-43db-9e29-80bf0530abee%2Faxlzy1q_processed.png&w=3840&q=75)
Transcribed Image Text:.data
arr:
space 16
#This is 16 bytes, or 4 words
messg1: .asciiz "Please enter a number!:
colon:
asciiz ": "
endline:.asciiz "\n"
messg2: .asciiz "Which element of the array would you like this to be?: "
.text
main:
#print first propmpt to user
$a0, messg1
$v0, $zero, 4
la
la is Load Address
#Set up my message as an argument
#Specify system call 4 to print
#make the system call
addi
syscall
#this will read my first integer
$v0, $zero, 5
addi
#set up syscall to read number in from command line
syscall
add $t0, $v0, $zero
#move number that was just entered into register $t0
#print 2nd prompt to user
$a0, messg2
$v0, $zero, 4
#Set up my 2nd message as an argument - la is Load Address
#Specify system call 4 to print
#make the system call
la
addi
syscall
Line: 4 Column: 40
Show Line Numbers
![Read two input values from the keyboard:
a number to enter in the array
the index of the array where you should store it.
Print out each index of the array, and its contents. This will look like:
Please enter a number 6
Which element of the array would you like this to be? 1
0: 0
1: 6
2: 0
3: 0
Please enter a number 3
Which element of the array would you like this to be? 0
0: 3
1: 0
2: 0
3: 0
You can assume the user will not input any indexes outside of the bounds of the array. You are required to store the user's value in memory at the specified position, and to load every value in the array from
memory into a register to print it out.
Note that you will need to translate between indices, which are word addresses, and values in memory, which are byte addresses.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd104ea5e-59f4-47a3-a0d3-8c9f1ad3b57c%2F83f1b7ed-397c-43db-9e29-80bf0530abee%2Fv2elfa8_processed.png&w=3840&q=75)
Transcribed Image Text:Read two input values from the keyboard:
a number to enter in the array
the index of the array where you should store it.
Print out each index of the array, and its contents. This will look like:
Please enter a number 6
Which element of the array would you like this to be? 1
0: 0
1: 6
2: 0
3: 0
Please enter a number 3
Which element of the array would you like this to be? 0
0: 3
1: 0
2: 0
3: 0
You can assume the user will not input any indexes outside of the bounds of the array. You are required to store the user's value in memory at the specified position, and to load every value in the array from
memory into a register to print it out.
Note that you will need to translate between indices, which are word addresses, and values in memory, which are byte addresses.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
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 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
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](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education