



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Zhang; Class: COMPUTER ORG I; Subject: COMPUTER DESIGN/ARCHITECTURE; University: Florida State University; Term: Unknown 1989;
Typology: Assignments
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Enter a value for x (or 999 to exit): - Our approximation for e^-1.00000000 is 0. Enter a value for x (or 999 to exit): 80 Our approximation for e^80.00000000 is
Enter a value for x (or 999 to exit): 999 Come back soon!
.text .globl main main: li.s $f0, 361. mfc1 $a0, $f jal calsqrt done: mtc1 $v0, $f li $v0, syscall eixt: li $v0, syscall
calsqrt: addi $sp, $sp, - swc1 $f0, 20($sp) swc1 $f1, 16($sp) swc1 $f2, 12($sp) swc1 $f3, 8($sp) swc1 $f20, 4($sp) swc1 $f21, 0($sp) mtc1 $a0, $f0 # $f0 gets n li.s $f20, 2.0 # $f20 storing constant 2 for dividing li.s $f21, 0.001 # $f21 storing constant 0.001 for exit comparision div.s $f1, $f0, $f20 # $f1 gets n/ calsqrtloop: div.s $f2, $f0, $f1 # $f2 gets n/x add.s $f2, $f2, $f1 # $f2 gets n/x + x div.s $f2, $f2, $f20 # $f2 gets x'=(n/x + x)/ sub.s $f3, $f2, $f1 # $f3 gets x'-x abs.s $f3, $f3 # $f3 gets |x'-x| c.lt.s $f3, $f21 # set the flag if |x'-x| < 0. bc1t calsqrtdone mov.s $f1, $f j calsqrtloop calsqrtdone: mfc1 $v0, $f lwc1 $f0, 20($sp) lwc1 $f1, 16($sp) lwc1 $f2, 12($sp) lwc1 $f3, 8($sp) lwc1 $f20, 4($sp) lwc1 $f21, 0($sp) addi $sp, $sp, 24 jr $ra .data msg_done: .asciiz "done\n"