gpt4 book ai didi

arrays - 如何在 MIPS 中初始化数组?

转载 作者:行者123 更新时间:2023-12-02 03:29:37 25 4
gpt4 key购买 nike

在我的previous question ,我询问了如何将 MAX_ARRAY() 函数转换为 MIPS。我已经完成了那个任务。现在,我希望在程序中初始化一个数组。我怎样才能实现这个目标?

       addi  $t1,$zero, 0   # initialize index i to 0
loop: add $t1,$t1,1 # increment index i by 1
beq $t1,$s2,done # if all elements examined, quit
add $t2,$t1,$t1 # compute 2i in $t2
add $t2,$t2,$t2 # compute 4i in $t2
add $t2,$t2,$s1 # form address of A[i] in $t2
lw $t3,0($t2) # load value of A[i] into $t3
slt $t4,$t0,$t3 # maximum < A[i]?
beq $t4,$zero,loop # if not, repeat with no change
addi $t0,$t3,0 # if so, A[i] is the new maximum
j loop # change completed; now repeat
done:

最佳答案

http://pages.cs.wisc.edu/~cs354-2/onyourown/arrays.html希望这对您有帮助...无法找到更合适的答案

关于arrays - 如何在 MIPS 中初始化数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7543929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com