Question

I writing a MIPS program in mars. I am looping through an array of addresses.

I write this:

addi $t4, $t4, 8

where $t4 contains the base address of my array of addresses, and it gets shifted by 8 each time the loop runs. Then, after the loop is done, I store an address at that location.

My question: am I correct in adding 8? or should i add 1(1 byte=8bits, not sure what number to use when adding to addresses...)

Was it helpful?

Solution

You should be adding the size in bytes of each element of the array. Since an address on MIPS is 32 bits (4 bytes), you should add 4.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top