需要帮助修复以下从Python代码转换而来的MIPS代码,该代码旨在读取给定大小的整数列表并计算列表中的最小元素。我也不能使用li,blez,bnez或move命令,因此,如果有其他方法可以编写这些段,那也将有所帮助。谢谢:)
Python:
size = int(input(”Enter list size : ”))
the list = [0] ∗ size
for i in range(size):
the list[i] = int(input(”Enter element ”+ str(i) + ”: ”))
if size > 0:
min = the list[0]
for i in range(1,size):
item = the list[i]
if min > item:
min = item
print( ”The minimum element in this list is ” + str(min) + ”\n ”)
MIPS:
.data
prompt: .asciiz "\n How many integer numbers? (5 integers, minimum) "
result: .asciiz "The minimum integer is "
.text
.globl main
main:
li $v0, 4
la $a0, prompt
syscall
li $v0, 5
syscall
blez $v0, end
li $t0, 0
loop:
add $t0, $t0, $v0
addi $v0, $v0, -1
bnez $v0, loop
li $v0, 4
la $a0, result
syscall
li $v0, 1
move $a0, $t0
syscall
b main
end:
li $v0, 4
la $a0,
syscall
li $v0, 10
syscall