.data
accuracy: .double 0.000001
starting: .double 1.0
DivideByTwo: .double 2.0
Zero: .double 0.0
.text
main:
l.d $f2,starting # load starting end point
l.d $f8,accuracy # load the accuracy constant into $f8:$f9
l.d $f16,DivideByTwo
li $v0, 7 # service 7 is read double it stores the read double in $f0:$f1
syscall #execute syscall
mov.d $f10,$f0 #save original value
nop
#check if input is less then zero and end if true
l.d $f4,Zero
c.lt.d $f0,$f4
bc1f whileLoop
j EndMe
whileLoop:
sub.d $f6,$f0,$f2 #subtract the input double eg $f0:$f1 - $f2:$f3 or input - y
c.lt.d $f8,$f6 # 0.000001 < (input-y)
nop
bc1f EndLoop #if true then end the loop
nop
add.d $f0,$f0,$f2 # x = (x + y)
div.d $f0,$f0,$f16 # x = x/2
div.d $f2,$f10,$f0 # y= orginal/x
jal PrintArea #print x and y
nop
b whileLoop #branch back to top of while loop
EndLoop:
jal PrintArea
nop
li $v0,10 #exit syscall
syscall
j EndMe
PrintArea:
li $a0,0xA0 # load new line char into $a0
li $v0,3
mov.d $f12,$f0 #print x
syscall
li $v0,11 #print new line char
syscall
mov.d $f12,$f2 #print y
syscall
li $v0,11 #print new line char
syscall
jr $ra
EndMe:
Hi, jfmherokiller! I just resteemed your post!
I can also re-steem and upvote some of your other posts
Curious? Check out @resteembot's' introduction post
PS: If your reputation is lower than 30 re-blogging with @resteembot only costs 0.001 SBD
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit