title: MIPS Check if equal to a certain character
body: <p>I am trying to write sprinf in mips. First, I am trying to count how many characters there are.</p>
  
  <pre><code>sprintf:
      addi $sp, $sp, -12
      sw $ra, 8($sp)
      sw $s1, 4($sp)
      sw $s2, 0($sp)
  
  
  
  
          li      $s0, 0          # len = 1
          la      $s1, ($a1)        # s = str
  test:
          lb      $s2, 0($s1)     # c = *s
          beqz    $s2, done       # if c == '\0', branch to "done"
          beq $s2, '5', done
          addi    $s0, $s0, 1     # len = len + 1
          addi    $s1, $s1, 1     # s = s + 1
          j       test
  
  percent:
  
  
  
  
  done:
          li      $v0, 1          # syscall code: print_int
          move    $a0, $s0
          syscall
          li      $v0, 11         # syscall code: print_char
          li      $a0, 10         # pass newline character
          syscall
  
          jr      $ra
  </code></pre>
  
  <p>But there will be a need to check if in the format when there is a %d, or %c ,etc.</p>
  
  <p>How do I check for a certain character like that?
  I saw this for mips ascii 
  <a href="http://galia.fc.uaslp.mx/~luis/arquitectura_files/table.pdf" rel="nofollow">http://galia.fc.uaslp.mx/~luis/arquitectura_files/table.pdf</a></p>
  
  <p>but what would the beq look like?</p>