Reputation: 1
We are given a project in which we have to find the min, max, and median of entered floating point numbers in MIPS. I'm currently trying to sort the numbers in ascending order but am not having much luck. I'm stuck on an error that says address out of range. Here is my code, can anyone help?
.data
arr: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0
end: .float 0.0
low: .float 0
pro: .asciiz "This Program will show the max, min,\nand median of the entered values.\nType 0.0 to end the program."
pro1: .asciiz "\nEnter a floating point value.\n"
.text
li $v0, 4
la $a0, pro
syscall
index:
li $s0, 0
li $t0, 0
lwc1 $f11, end
main:
li $v0, 4
la $a0, pro1
syscall
li $v0, 6
syscall
la $s0, arr
sw $v0, arr
add $s0, $s0, 4
c.eq.s $f0, $f11
loop1:
swc1 $f0, arr($s0)
addi $s0, $s0, 4
swc1 $f1, arr($s0)
c.lt.s $f0, $f1
bc1t min
j main
min:
swc1 $f0, low
j main
li $v0, 2
syscall
exit:
lwc1 $f12, low
li $v0, 2
syscall
li $v0, 10
syscall
Upvotes: 0
Views: 1080
Reputation: 49893
You are loading the address of arr
into $s0
, but then using $s0
as an offset from arr
(arr($s0)
). If $s0
has the address of the data you want, just use ($s0)
.
Upvotes: 1