我刚刚找到了MIPS程序集(在MARS上)连接字符串的解决方案,我在这里报告了代码:
# String concatenate
.text
# Copy first string to result buffer
la $a0, str1
la $a1, result
jal strcopier
nop
# Concatenate second string on result buffer
la $a0, str2
or $a1, $v0, $zero
jal strcopier
nop
j finish
nop
# String copier function
strcopier:
or $t0, $a0, $zero # Source
or $t1, $a1, $zero # Destination
loop:
lb $t2, 0($t0)
beq $t2, $zero, end
addiu $t0, $t0, 1
sb $t2, 0($t1)
addiu $t1, $t1, 1
b loop
nop
end:
or $v0, $t1, $zero # Return last position on result buffer
jr $ra
nop
finish:
j finish
nop
.data
str1:
.asciiz "Hello "
str2:
.asciiz "world"
result:
.space 200
但是我的问题是:如何在两个字符串之间连接一个浮点数?
先谢谢您。