title: MIPS returned value not correct
body: <p>I have this C function:</p>
  
  <pre><code>int bin_img(unsigned char *ptr, int w, int h, unsigned char limiar);
  </code></pre>
  
  <p>On my code I use my function like this:</p>
  
  <pre><code>printf("The value is %d\n",bin_img(dp, width, height, LIMIAR));
  </code></pre>
  
  <p>Imagine the variables are defined like this:</p>
  
  <pre><code>#define LIMIAR 128
  unsigned char *dp;
  int w = 5;
  int h = 0;
  
  dp[] = {74,250,153,28,26}
  </code></pre>
  
  <p>I have to program my bin_img function in MIPS.</p>
  
  <p>Imagine I have this code:</p>
  
  <pre><code>bin_img:
  
      lb  $15,0($4)   
      move    $2,$15
      jr  $31
  </code></pre>
  
  <p>It will print 74 witch is the firs element of my array.
  If I do</p>
  
  <pre><code>bin_img:
  
      lb  $15,1($4)   
      move    $2,$15
      jr  $31
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>bin_img:
  
      lb  $15,2($4)   
      move    $2,$15
      jr  $31
  </code></pre>
  
  <p>It will print some negative numbers and if I do this:</p>
  
  <pre><code>bin_img:
  
      lb  $15,3($4)   
      move    $2,$15
      jr  $31
  </code></pre>
  
  <p>or this</p>
  
  <pre><code>bin_img:
  
      lb  $15,4($4)   
      move    $2,$15
      jr  $31
  </code></pre>
  
  <p>It will print 28 and 26 respectively. Why is it printing negative numbers?</p>
  
  <p>Should'n it print 250 and 153?</p>