Skip to content

Instantly share code, notes, and snippets.

@hc5
Created February 24, 2012 22:06
Show Gist options
  • Select an option

  • Save hc5/1904090 to your computer and use it in GitHub Desktop.

Select an option

Save hc5/1904090 to your computer and use it in GitHub Desktop.
# $a0 = address of string
# $v0 = length of it
strlen:
addi $t1, $a0, 0
loop:
lb $t0, 0($a0)
addi $a0, $a0, 1
bne $t0, $zero, loop
sub $v0, $a0, $t1
addi $v0, $v0, -1 # -1 because \0 is counted
jr $ra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment