Null-terminating a string in MIPS?
问题 I'm writing strncpy in MIPS, but I'm having trouble null-terminating the string. If i do not null-terminate it myself, the string goes on and on. I have tried sb $__ 0($0) but that does not seem to work... $a0 = pointer to destination array $a1 = source string $a2 = number of characters to copy strncpy: add $t1 $zero $zero #counter beq $a2 $0 done # if num chars to copy is 0, return. j cpyLoop cpyLoop: beq $t1 $a2 done # if counter == num to copy, end lb $t2 0($a1) # load the character beq