0
votes

I'm struggling to find a good site that explains MIPS and how it works.

The code I am trying to understand is:

SW 7000(R0),R1

I know SW means save word and that it is saving the value of R1 to memory address 7000. What is the point of (R0)? What does it do?

Is there a good resource for problems I run into similar to this?

Thanks!

2
there's no register named "R0" or "R1" in MIPS. The correct name is $name, such as $0, $7, $a0, $s1phuclv

2 Answers

5
votes

Here R0 is a register. Placing it in brackets is indicating that you are using indirect addressing (ie: like a pointer) : not storing in R0, but in the address stored in R0.

The 7000 indicates an offset. In this case you would have the address stored in R0 + 7000.

2
votes

Looks like it should be

SW R1, 7000(R0)

where R1 and R0 are any MIPS registers.

It would read as store the contents of register R1 into effective memory address 7000+R0. E.g. if R1 contains value 10 and R0 contains value 1192, then it would store a word (32 bits) with value 10 into memory address 8192.