strcpy: addi $sp, $sp, -4 # adjust stack for 1 more item sw $s0, 0($sp) # save $s0 add $s0, $zero, $zero # i = 0 L1: add $t1, $s0, $a1 # address of y[i] in $t1 lb $t2, 0($t1) # t2 = y[i] add $t3, $s0, $a0 # address of x[i] in $t3 sb $t2, 0($t3) # x[i] = y[i] beq $t2, $zero, L2 # if y[i]==0, go to L2 addi $s0, $s0, 1 # i= i+1 j L1 # go to L1 L2: lw $s0, 0($sp) # y[i] ==0; end of string, restore old $s0 addi $sp, $sp, 4 # pop 1 word off stack jr $ra # return
沒有留言:
張貼留言