1

I think I have a fairly basic MIPS question but am still getting my head wrapped around how addressing works in mips.

My question is: What is the address of the register $t0?

I am looking at the following memory allocation diagram from the MIPs "green sheet" enter image description here

I had two ideas:

  1. The register $t0 has a register number of 8 so I'm wondering if it would have an address of 0x0000 0008 and be in the reserved portion of the memory block.
  2. Or would it fall in the Static Data Section and have an address of 0x1000 0008?

I know that MARS and different assemblers might start the addressing differently as described in this related question: How is the la instruction translated in MIPS?

I trying to understand what the "base" address is for register $t0 so I have a better understanding how offsets(base) work. For example what the address of 8($t0) would be

Thanks for the help!

sdub0800
  • 139
  • 1
  • 9
  • I also found this additional question, that is providing some additional insights, I might have an answer to my own question soon. https://stackoverflow.com/questions/57895605/how-does-a-mips-32-linker-convert-lw-and-sw-addresses – sdub0800 Mar 14 '21 at 14:47

1 Answers1

0
feature Registers Memory
count very few vast
speed fast slow
Named yes no
Addressable no yes

There are typically 32 or fewer registers for programmers to use.  On a 32-bit machine we can address 2^32 different bytes of memory.

Registers are fast, while memory is slow, potentially taking dozens of cycles depending on cache features & conditions.

On a load-store machine, registers can be used directly in most instructions (by naming them in the machine code instruction), whereas memory access requires a separate load or store instruction.  Computational instructions on such a machine typically allows naming up to 3 registers (e.g. target, source1, source2).  Memory operands have to be brought into registers for computation (and sometimes moved back to memory).

Register can be named in instructions, but they do not have addresses and cannot be indexed.  On MIPS no register can be found as alias at some address in memory.  It is hard to put even a smallish array (e.g. array of 10) in registers because they have no addresses and cannot be indexed.  Memory has numerical addresses, so we can rely on storing arrays and objects in a predictable pattern of addresses.  (Memory generally doesn't have names, just addresses; however, there are usually special memory locations for working with I/O various devices, and, as you note memory is partitioned into sections that have start (and ending) addresses.)


To be clear, memory-based aliases have been designed into some processors of the past.  The HP/1000 (circa 70s'-80's), for example, had 2 registers (A & B), and they had aliases at memory locations 0 and 1, respectively.  However, this aliasing of CPU registers to memory is generally no longer done on modern processors.


For example what the address of 8($t0) would be

8($t0) refers to the memory address of (the contents of register $t0) + 8.  With proper usage, the program fragment would $t0 would be using $t0 as a pointer, which is some variable that holds a memory address.

Erik Eidt
  • 23,049
  • 2
  • 29
  • 53