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

Surface Area Of A Sphere The surface area of a sphere is equal to: where r is th

ID: 3856033 • Letter: S

Question

Surface Area Of A Sphere
The surface area of a sphere is equal to:

where r is the radius of the sphere.

Write an HLA Assembly language program that computes the surface area based on a radius. A sample program dialogue is shown below. However you decide to do it, your main program should include calling a procedure or function (atleast one...) to solve this problem.

Lemme calculate the surface area of a sphere!
Gimme r: 2.15
Surface Area = 58.0880


Lemme calculate the surface area of a sphere!
Gimme r: 3.9
Surface Area = 191.1345

Surface Area-42

Explanation / Answer

program surfaceArea;

#include( "stdlib.hhf" );

static

radius : real32;

procedure computeSurfaceArea(r : real32); @nodisplay; @noframe;

static

    returnAddress : dword;

    z : real32;

begin computeSurfaceArea;

pop(returnAddress);

pop(r);

push(returnAddress);

finit();

fld( r );

fld( st0 );

fmul();

fldpi();

fld(4.0);        

fmul();

fmul();

fstp( z );

stdout.putr32(z, 4, 10);

ret();

end computeSurfaceArea;

begin surfaceArea;

stdout.put("Lemme calculate the surface area of a sphere!", nl);

stdout.put("Gimme r: ");

stdin.get(radius);

stdout.put("Surface area is: ", nl);

call computeSurfaceArea;

end surfaceArea;