.data
message: .asciiz "Hello World"
.text
main:
li $t0, 0 # initialize loop-counter
la $a0, message #load the address of the 1st byte
loop:
lb $t1, ($a0) # load the content of the address stored in $a0
beq $t1, $zero, exit # branch if equal
# exit the program if $t0 == null
addi $t0, $t0, 1 # increment the loop counter
addi $a0, $a0, 1 # go to next byte
j loop
exit:
move $a0, $t0 # prepare to print the integer
li $v0, 1 # integer syscall
syscall
li $v0, 10
syscall
显然,该程序运行良好。
在这方面我有两个问题:
$v0
代替$t1
怎么办?有什么区别?