Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please do not copy and paste from previous answers as they are incorrect and do

ID: 3918988 • Letter: P

Question

Please do not copy and paste from previous answers as they are incorrect and do not work.

For a pyramid, a cone or a cylinder, their volumes can be computed from the parameters b, r and h, as shown below:

Volume = pi * r * r * h

Write an HLA Assembly language program that computes and then prints the volume of a pyramid, cone and cylinder based on a radius r, a length b and a height h by writing a function with the following signature:

A sample program dialogue is shown below.

Lemme calculate the volumes of various things!
Gimme r: 1.0
Gimme b: 1.0
Gimme h: 1.0
Volume of a pyramid = 0.33333
Volume of a cone = 1.04719
Volume of a cylinder = 3.14159

Lemme calculate the volumes of various things!
Gimme r: 1.0
Gimme b: 1.0
Gimme h: 3.0
Volume of a pyramid = 1.00000
Volume of a cone = 3.14159
Volume of a cylinder = 9.42477

Lemme calculate the volumes of various things!
Gimme r: 2.0
Gimme b: 1.0
Gimme h: 3.0
Volume of a pyramid = 1.00000
Volume of a cone = 12.5663
Volume of a cylinder = 37.6991

Pyramid Cone Cylinder Volume = 1 / 3 * b * h Volume = 1/ 3 * pi * r * r h

Volume = pi * r * r * h

Explanation / Answer

volumeFinder(double, double, double):

addiu $sp,$sp,-40

sw $fp,36($sp)

move $fp,$sp

swc1 $f12,44($fp)

swc1 $f13,40($fp)

swc1 $f14,52($fp)

swc1 $f15,48($fp)

lwc1 $f0,52($fp)

nop

lwc1 $f1,48($fp)

mtc1 $0,$f2

nop

mtc1 $0,$f3

nop

mul.d $f2,$f0,$f2

lwc1 $f0,60($fp)

nop

lwc1 $f1,56($fp)

nop

mul.d $f0,$f2,$f0

swc1 $f0,12($fp)

swc1 $f1,8($fp)

lwc1 $f0,44($fp)

nop

lwc1 $f1,40($fp)

mtc1 $0,$f2

nop

mtc1 $0,$f3

nop

mul.d $f2,$f0,$f2

lwc1 $f0,44($fp)

nop

lwc1 $f1,40($fp)

nop

mul.d $f2,$f2,$f0

lwc1 $f0,60($fp)

nop

lwc1 $f1,56($fp)

nop

mul.d $f0,$f2,$f0

swc1 $f0,20($fp)

swc1 $f1,16($fp)

lwc1 $f2,44($fp)

nop

lwc1 $f3,40($fp)

lui $2,%hi($LC0)

lwc1 $f0,%lo($LC0+4)($2)

nop

lwc1 $f1,%lo($LC0)($2)

nop

mul.d $f2,$f2,$f0

lwc1 $f0,44($fp)

nop

lwc1 $f1,40($fp)

nop

mul.d $f2,$f2,$f0

lwc1 $f0,60($fp)

nop

lwc1 $f1,56($fp)

nop

mul.d $f0,$f2,$f0

swc1 $f0,28($fp)

swc1 $f1,24($fp)

nop

move $sp,$fp

lw $fp,36($sp)

addiu $sp,$sp,40

j $31

nop

$LC0:

.word 1074340347

.word 1413754136