2
输入后这是我的代码:保存输出数据段
.data
.ascii "r", "o", "r", "y", "\n"
key: .word 2
.text
.globl main
main: la $t0, string
move $t5, $t0 # preserve original data
la $t1, key # load cypher into t1 reg
lw $a1, 0($t1) # key loaded into a1 reg
Loop: lb $a0, 0($t5) # ith element of array loaded into a0
beq $a0, 10, exit_all # if ith character is \n, get out of loop
jal sub1 # otherwise, call sub
addi $t5, $t5, # increment index of array
j Loop
exit_all: syscall
sub1:
some code
move $v0, $t0 # what i want to return to main
jr $ra # exit iteration
我有在它的子例程循环。每次'jr $ ra'命令将流程返回到我的主函数时,sub返回(在$ v0 reg中)我想要保存的输出。我需要在输入数据段后直接保存这些输出。我该怎么做呢?如果它只是一个输出,我可以说:
sb $v0, 4($t1)
它会直接保存后。但是有多种输出,所以我如何以一般方式来做到这一点?