Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I\'m currently programming in MIPS right now, and I\'m stuck on a part of

ID: 3887994 • Letter: H

Question

Hello, I'm currently programming in MIPS right now, and I'm stuck on a part of my project:

i have a 2d array that is:

block_arr:
   .byte 1, 2, 3, 4, 2, 3, 4, 1, 3, 4, 1, 2, 4, 1, 2, 3

and I am trying to make a function that is called "get_block_address". It should:

Take the column number in a0

Take the row number in a1

Calculate the correct address in block_arr (using the calculation you figured out above), and put that address in v0

It should not use lw. It should return the address of the given array slot.

I'm very stuck. Thanks very much for any help.

Explanation / Answer

block_arr: .byte 1, 2, 3, 4, 2, 3, 4, 1, 3, 4, 1, 2, 4, 1, 2, 3

get_block_address:
       la $t1, byte   
       li $a0, 4
       add $a0, $a0, $a0
       add $a0, $a0, $a0
       add $t3, $a0, $t1
       lw $v0, 0($t3)   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote