.data
prompt: .asciiz "Input a float number: "
result: .asciiz "The square root is: "
half: .double 0.5
e: .double 1e-6
.text
li $v0, 4
la $a0, prompt
syscall
li $v0, 7 #f0 = x0
syscall
ldc1 $f2, half #f2 = 0.5
ldc1 $f4, e #f4 = e
mul.d $f6, $f0, $f2 #f6 = x1
mov.d $f10, $f0 #f10 = n
loop:
sub.d $f8, $f0, $f6
abs.d $f8, $f8
c.le.d $f8, $f4
bc1t exit
mov.d $f0, $f6
div.d $f8, $f10, $f0
add.d $f8, $f8, $f0
mul.d $f6, $f8, $f2
j loop
exit:
li $v0, 4
la $a0, result
syscall
li $v0, 3
mov.d $f12, $f6
syscall
li $v0, 10
syscall