title: Using a random number generator in MIPS?
body: <p>So I was reading a few threads on this site and I found one on how to make one..
  But I can't really find a link that explains more about how to code it..
  My textbook for the course didn't provide any information about RNG at all so no help there.</p>
  
  <p>The code was </p>
  
  <pre><code>li $a1, 4
  li $v0, 42
  add $a0, $a0, 1
  </code></pre>
  
  <p>is this correct for asking for a range between 1-3?
  I tried outputting what random number it was but it gave me the same number constantly.</p>
  
  <pre><code>#sw $a0, 0($s0)
  li $a1, 4
  li $v0, 42
  add $a0, $a0, 1
  #syscall
  
  li $v0, 4
  la $a0, Checking
  syscall
  
  li $v0, 1
  move $t0, $a0
  syscall
  </code></pre>
  
  <p>I saw the <code>sw $a0, 0($s0)</code> but I'm not sure what that does  -- is it needed to output?  (I took it out because after I pushed a key to go to the RNG, it said the program crashed)
  I keep getting the output of 268501267  which I'm not sure what that means 
  edit:  now it started giving me 268500992 all the time</p>
  
  <p>Can anyone help explain this a little more in depth?</p>
  
  <p>Logically speaking -- I understand the where the 42 comes from and why I need to add +1  (This is so I won't get the value of 0)</p>
  
  <p>From there, I have no clue on why the code won't output a number in the range I gave.</p>