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)
它會直接保存後。但是有多種輸出,所以我如何以一般方式來做到這一點?