string_insert:
addi $sp, $sp, -200
sw $a0, 0($sp)
#insertion point
add $t0, $a0, $a2
lb $t2, ($a1)
loop:
beq $t2, $zero, end # If the character is null, exit the loop
sb $t2, ($t0) # Store the current character at the insertion point
addi $t0, $t0, 1 # Increment the insertion point
addi $a1, $a1, 1 # Move to the next character of the second string
lb $t2, ($a1) # Load the next character of the second string
j loop
# End of loop
end:
sb $zero, ($t0)
lw $a0, 0($sp)
addi $sp, $sp, 200
li $v0, 4
move $a0, $a0
syscall
jr $ra
$a0 包含 hello,将其存储到堆栈后,我将其更改为 heabc。但是在取回它之后我没有打招呼。