Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Array Continued: Goal for today: Change the array to 5 elements (you need to change the .space parameter to something > 12) You then need
Array Continued:
Goal for today:
Change the array to 5 elements (you need to change the .space parameter to something > 12)
You then need to load up those elements into the array
And then print off all of the elements in the array.
Array hand in:
Code that creates an array of 5 elements, populates it, and then prints off the elements
Arrays Arrays in MIPS could be stored in registers, that severely constraints what the array could do, no more than 32 elements, to the point that using a struct might make more sense in that case. The better option for an array is to declare it in the data' subsection and then it's stored out in main memory. (Because MIPS is a simulator not a native language we are still constrained on array sizes compared to C, but that constraint is on the order of a billion elements). 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 data theArray: .space 12 . space an Intis 4 bytes, so 3 integers is 12 bytes .text #this first bit just puts values into registers # after this we need to copy them to an array addi $80, Szero, 1 addi $31, Szero, 3 addi $82, Szero, 5 #now we need to use sw (store word) to move values into an array iset the index 0 addi $t0, $zero, O Store Values sw $80, theArray($t0) addi $t0,$t0, 4 sw $81, theArray($t0) addi $t0,$t0, 4 SW $82, theArray($t0) sw addi $t0,$t0, 4 #loading data (to print it) lw $t6, theArray($zero) #print it li $v0, 1 addi $a0, $t6,0 syscall #done li $v0, 10 syscall 17 18 19 20 21 22 23 24 25 26 27 Here is a simple program to create and print one element of an array of integers)28 PAStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started