I'm not entirely sure where to turn to so I thought I'd give here a go. I was wondering if any of you could help me out with this MIPS code I've designed, yet will not give me the results I'm aiming for. The purpose is to essentially utilize a given input, denoted x, and then provide a specific amount of iterations, denoted n, where each iteration calculates the approximation to the square root using Newton's square root approximation. So far this is my code below. I have the feeling that the register values, namely the ones outside of my loop label are not reaching to the inside because I'm utilizing my jal instruction incorrectly. I apologize in advance for the messy use of random registers. Any help or tips would be very appreciated!
.data
prompt: .asciiz "Enter a floating point value for x: "
prompt1: .asciiz "\nPlease enter the number of iterations, n: "
prompt2: .asciiz "\nx approximated is: "
.text
li $v0, 4 #Asks for input x
la $a0, prompt
syscall
li $v0, 6 #User inputs x as float
syscall
mov.s $f0, $f3 #X stored into f3
li $v0, 4 #Asks for # of iterations
la $a0, prompt1
syscall
li $v0, 5 #Gathers iterations n
syscall
move $s6, $v0 #Saves n iterations to $s6
mtc1 $s6, $f1 #Register $f1 holds the iterative values of n
cvt.s.w $f27, $f1 #Register 27 now holds float-point transferred value of integer entered previously
syscall
div.s $f25, $f30, $f30 #Creates $f25 = 1
add.s $f25, $f25, $f25 #Creates $f25 = 2
li $t5, 0 #Initializes $t5 = 0
jal loop
loop:
addi $t5, $t5, 1
mov.s $f3, $f5 #F5 holds register contents of f27, thus f3 is input x
div.s $f5, $f5, $f27 #F5 holds f5/f27, thus f5 is now x/n
add.s $f5, $f27, $f5 #F5 holds f27 + new f5 => n + x/n
div.s $f5, $f5, $f25 #F5 holds f27/f25 => (n + x/n)/2
li $v0, 4 #Loads v0=4 to print prompt2
la $a0, prompt2
syscall
li $v0, 2 #Loads v0 = 2 to print the float approximation
mov.s $f12, $f5
syscall
beq $t5, $s6, done
jr $ra
done: