title: Access register who's number is stored in another register
body: <p>I am working on a project for one of my classes which involves translating C code into MIPS assembly. I am having trouble translating this code:</p>
  
  <pre><code>r[extract(ir,15,11)] = aluout;
  </code></pre>
  
  <p>Basically, r[] is an array which represents the registers in C. As you can see, it determines which register to access based on the result from the <code>extract</code> function. Is there anything like this in MIPS? The only way I can think to do it is to take the value that I will get back from the extract subroutine and check it against all register numbers. The C representation of this would look like:</p>
  
  <pre><code>regNum = extract(ir, 15, 11);
  if (regNum == 1) {
      r[1] = aluout;
  } else if (regNum == 2) {
      r[2] = aluout;
  } else if (regNum == 3) {
      r[3] = aluout;
  } ...
  </code></pre>
  
  <p>Any ideas? Is this the only way to go about it?</p>