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

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 18RQ
icon
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
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.
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Instruction Format
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
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,