'Writing a Loop in MIPS I without SLT

I'm given an array that I know the length of that is full of 20 4 byte words (presumably integers). Without using SLT, and instead using BEQ/BNE, I'm to write a loop to sum all of the array elements. I'm also to not use a variable like "i" to iterate through the array, only using byte offsets instead.

I am trying to load the byte offset of the last element + 4, to branch on whether or not the current byte offset equals that (indicating its out of bounds), and additionally load the data of the element and summate it. I'm completely lost on it. This was my attempt at it:

(Base address of array A is already loaded into $s0)

addi $s1, $s1, $zero #sum = 0
lw $t1, 84($s0) #trying to load the byte offset of the last element (a[20] + 4)
sll $t2, $s1, 2 #byte offset of the current element

LOOP: beq $t2, $t1, EXIT #go to exit if they're equal, otherwise execute the rest of the code
#load the element of A into $t4 (no idea how to implement)
add $s1, $s1, $t4 #add it to the sum (sum += current element)
sll $t2, $t2, 2 #increment the byte offset
j LOOP
EXIT : #code not indicated here

Research leads me to instructions I'm not supposed to use (SLT, LB, LA, etc.), as per my assignment. I'm very unsure how to move forward from this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source