Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago