string length for mips assembly

前端 未结 1 1700
走了就别回头了
走了就别回头了 2021-01-06 13:12

Whenever I run the following code:

#counts length of a string

.data
 .data
string: .asciiz \"Hello\"

printedMessage: .asciiz \"The length of the string: \"         


        
相关标签:
1条回答
  • 2021-01-06 14:05

    Not entirely sure what you mean by fix print out, but one problem is that your count register in the strlen function is $t0 while your second syscall in print: is called with argument $t1

    Changing that $t1 to $t0 and running it gives output 5.

    0 讨论(0)
提交回复
热议问题