When you look at a standard register table (I found several on Google that were identical, I assumed they are standard), there are 31 registers.
This is not exactly correct. There are 32 general-purpose registers on MIPS, counting r0
, as well as a number of special-purpose registers such as pc
, lo
and hi
, and floating-point registers.
So when you specify a value for
X
, does that meanX
is limited to values such that 4*X
< 31? (or more restricted since several registers in the range 0-31 are reserved for system use?), or is that going to be an address in memory, and not a register?
Neither. The value for X
is specified as a constant within the instruction. The encoding looks like:
BNE: 0001 01ss ssst tttt iiii iiii iiii iiii
The encoding for this instruction begins with a 6-bit header (000101
), uses 5 bits for each of the source and destination registers (s
and t
), and uses the remaining 16 bits of the instruction for a signed 16-bit offset (i
). This offset is treated as a count of instructions relative to the next PC - as a result, you can jump up to 64 KB in each direction.
I know that if I use
$t0-$t7
I am using registers 8-15, and$s0-$s7
uses registers 17-23, but where is$R0-$Rk
(for some integer k<32, I assume) located? Is that the same 32 registers I would use for$t0, $s5
, etc? For example, are$R10
, register 10, and$t2
the same thing?
Yes — some MIPS general-purpose registers have multiple names. r10
and "register 10" both refer to the register by its location, whereas t2
refers to it by its conventional use as a Temporary register.