mips查找最大值程序:
.data
a: .word 5, 4, 7, 8, 1
N: .word 5
.text
lw $s0, a
la $s1, a
li $t0, 0
lw $s2, N
loop:
bge $t0, $s2, end
lw $t1, ($s1) # t1 = a[i]
bgt $t1, $s0, findMax
j next
findMax:
move $s0, $t1
next:
addi $t0, $t0, 1
addi $s1, $s1, 4
j loop
end:
li $v0, 1
move $a0, $s0
syscall
li $v0, 10
syscall