代写C代码 代做C程序 C辅导 C家教

远程写代码 Debug 讲解答疑 不是中介,本人直接写

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

 .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
 

相关推荐