title: I am having trouble with this MIPS program
body: <p>My goal is to translate the C code below to MIPS assembly. I feel like I am missing a crucial part in my code. Can someone explain what I am doing wrong and what I need to do to fix the problem please?</p>
  
  <p>Here is the C code:</p>
  
  <pre><code>char str[] = "hello, class";
  int len = 0;
  char *ptr = str;
  while (*ptr &amp;&amp; *ptr != ’s’)
     ++ptr;
  len = ptr - str;
  </code></pre>
  
  <hr>
  
  <p>Here is my code so far:</p>
  
  <pre><code>.data
      myStr: .asciiz "hello, class"
      s: .asciiz "s"
  main:
      la $t0, myStr
      la $t1, s
      lbu $t1, 0($t1)
  
  loop:
      beq $t0, $t1, continue
      addi $t0, $t0, 1
      j loop
  
  continue:
      sub $v0, $t0, $t1
  </code></pre>