Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2D Arrays in MIPS -Derive the equation that finds the correct array index. -To find the correct memory address from the equation you just derived,

2D Arrays in MIPS
-Derive the equation that finds the correct array index.
-To find the correct memory address from the equation you just derived, you need to multiply by the DATA_SIZE (thats how big each word is, 1 for chars, 4 for ints/floats, 8 for doubles)
Make a simple program work to sum up the diagonals of a matrix.
Note that the loop works on a variable called size which is toward the top.
Modify your program to work on a 3x3 array and show that it works.
image text in transcribed
the next two lines define an array (mdArray as a 2x2 multidimensional array) rray: word 2,5 .word 3,7 izeword 2 #dimension of the array (2x2 in this case, note this is only for are matrices) number of bytes per element, 4 for ints, 1 for chars , 8 for DATA SIZE 4 bles ext in: sao, mdAr ray # base address $al, size # size I sumDiagonal #sum of diagonals, in our starting example, this is 9. ve $a0, $v0 # this is because sumDiagonal will return it's last value in $v0 $v0, 1 scall nd done $v0, 10 scall iagonal: $v0,0 #sum =0 $t0, 0 #t0 as the index sunLoop: #The next 4 lines are the bit you need to derive and fill in yourself add add lw $t2, (St1) #getting element add $v0 , $v0 , $t2 # sum = sum + mdArray[1][i] blt $to , Sal, sumLoop #if i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions