title: MIPS srl by a variable
body: <p>I've done some searching but can't seem to find the answer. Most likely because I'm not really sure how to word it.</p>
  
  <p>if I have the following code</p>
  
  <pre><code>for (i = 0; i &lt; 10; i++) {
      x = y &gt;&gt; i
      ...
  }
  </code></pre>
  
  <p>is there a way to implement the y >> i instruction without a another loop?</p>
  
  <p>I know this doesn't work, but say the value of i was stored in $s1, doing something this</p>
  
  <pre><code>srl $t3, $s5, $s1
  </code></pre>
  
  <p>as opposed to having to setting $t3 to the value of $s5 and then looping through this statement i times</p>
  
  <pre><code>srl $t3, $t3, 1
  </code></pre>
  
  <p>Hopefully that makes sense.</p>
  
  <p>Basically I want y * 2^-i each time through the for loop.</p>
  
  <p>Thanks for any help, or even just some beratement about how this is a dup question and I can read that full of shame and get an answer.</p>