title: Is this MIPS strlen correctly converted from the corresponding C loop?
body: <p>I have a simple question for a Comp Sci class I'm taking where my task is to convert a function into MIPS assembly language. I believe I have a correct answer but I want to verify it.</p>
  
  <p>This is the C function</p>
  
  <pre><code>int strlen(char *s) {
       int len;
  
       len=0;
       while(*s != '\0') {
            len++;
            s++;
       }
       return len;
  }
  </code></pre>
  
  <p>Thanks!</p>
  
  <pre><code>strlen: 
      add $v0, $zero, $zero     # len = 0
  loop:                          # do{
      lbu $t0, 0($a0)               # tmp0 = load *s
      addi $a0, $a0, 1              # s++
      addi $v0, $v0, 1              # len++
      bne $t0, $zero, loop         # }while(tmp0 != 0)
  s_end:
      addi $v0, $v0, -1        # undo counting of the terminating 0
      j $ra 
  </code></pre>