Question: C code into MIPS. For my project, i am performing Numerical integration on the following formula for the interval 10 to 100 I am given

C code into MIPS.

For my project, i am performing Numerical integration on the following formula for the interval 10 to 100

C code into MIPS. For my project, i am performing Numerical integration

I am given this C code that is suppouse to calculate that formual

on the following formula for the interval 10 to 100 I am

my code below gives me an answer of 26,3402.8398624403 when it should be producing a number closer to 33,3045.

# outline for numerical integration for x*x*2+x from 0 to 10

# outline for numerical integration for x*x*2+x from 0 to 10

.data

from: .double 10.0

to: .double 100.0

n: .double 20.0

one: .double 1.0

two: .double 2.0

zero: .double 0.0

.text

main:

#Loading the coprocessors with labels

ldc1 $f10, n

ldc1 $f12, zero

ldc1 $f4, to

ldc1 $f6, from

#Calculating 'h':

#Subtracting 'from' from 'to' and storing in 'h'

sub.d $f8, $f4, $f6

#Dividing 'n' from 'h' and storing in 'h'

div.d $f8, $f8, $f10

#Calculating 'x':

#Add 'from' and 'sum' and store in 'x'

add.d $f16, $f6, $f12

#Loop

loop:

add.d $f18, $f4, $f8

ldc1 $f10, two

#calculate (h)/2

div.d $f6,$f8,$f10

#calculate (x+h)

add.d $f6, $f16, $f6

#calculate sum+=$f8

add.d $f12, $f12,$f6

#calculate x/2

div.d $f18, $f18, $f10

#calculate x *x

mul.d $f6, $f18, $f18

add.d $f12,$f12,$f6

#calculate 1/x

ldc1 $f10, one

div.d $f6, $f10, $f18

add.d $f12, $f12, $f6

#Calculate (to-h)

# sub.d $f10, $f4, $f8

#counter x+=h

add.d $f16, $f16, $f8

#$f16

c.lt.d $f4, $f16

bc1t out

j loop

out:

li $v0, 3

mul.d $f12, $f12, $f8

syscall

li $v0,10

syscall

100 J10 100 J10

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!