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

For this assignment, you will write an assembly language program to determine th

ID: 644792 • Letter: F

Question

For this assignment, you will write an assembly language program to determine the optimum dimensions of a closed cylindrical can, such as those used for canning food products. "Optimum" means the cheapest can possible. There are three input variables:

The cost of the end material in dollars/cm2.

The cost of the side material in dollars/cm2.

The volume of the can in milliliters.

Given these three input variables, you will determine the dimensions (height and diameter) of the can such that the cost of the can is minimized. NOTE: You must use the same order as given above to input the three values.

You will need to use the floating point macros for this assignment. Be sure to uncomment the initF macro:

Documentation on the macros is available online (link at left) and in the lecture notes. The only integer instruction useful for floating point numbers is move.l. For other instructions, use the macros.

The Formula

Optimization problems such as this is simple if you use calculus. Some of you may not have yet completed Math 150, so the formula for the radius ( you can derive the rest of the values from the radius) is as follows:

You can download my solution to this problem. Also, see the Swokowski calculus text, chapter 3, section 6.

Additional details:

All floating point numbers should be printed with two digits to the right of the decimal point.

You are not required to validate input.

Your program must be named prog2.s.

Your program must assemble with no warnings or errors.

Note: The fpow function. It may take a few seconds to run. This is expected, and does not mean that something is wrong with the program.

Output:

First, your program will print a title line which includes the assignment number, your class account number, and your name. Then your program will prompt the user to enter the three variables one at a time.   For this assignment, you are not required to validate user input.   If the user enters something other than a valid floating point number, then erroneous output is expected.   Finally, your program will print the results. You should print the can cost, diameter, and height, each on a separate line. Example:

Some Useful Formulae:

volume = ? r2h
side surface area = 2 ? r h
end area = ? r2
l ml = 1 cm3
? = 3.14159265358979323846

Some useful floating point contants:

What I have so far:

start: initIO * Initialize (required for I/O)
   setEVT           * Error handling routines
   initF           * For floating point macros only  
lineout       title
lineout       promptEnd
linein       buffer
cvtaf       buffer,D1   * End
lineout       promptSide
linein       buffer
cvtaf       buffer,D2   * Side
lineout    promptVol
linein       buffer
cvtaf       buffer,D3   * Volume
fmul       D1,D3
fmul       00,


              
              
               * Cost=sideCost*(2v/r)+2*endCost*(pi)r^2
               * Hieght=v/(pi)r^2
               * R=(((volume*side_cost)/2*PI*end_cost))^1/3
               * Diameter=2r
break * Terminate execution
*
*----------------------------------------------------------------------
* Storage declarations
TWO: EQU $40000000
PI: EQU $40490FDA
ONE_THIRD: EQU $3EAAAAAB

title: dc.b 'Program #2, mascxxxx, User's Name',0
promptEnd: dc.b 'Enter the vost of the end material per sqaure cm: ',0
promptSide:   dc.b   'Enter the cost of the side matherial per sqaure cm: ',0
promptVol:   dc.b   'Enter the desired volume in milliliters: ',0
buffer:       ds.b   80
cancost:   dc.b   'Can cost: '
diameter:   dc.b   'Diameter: '
height:    dc.b   'Height: '

               * Your storage declarations go
               * HERE
end

Explanation / Answer

start: initIO * Initialize (required for I/O) initF setEVT lineout p1 floatin buffer cvtaf buffer,D5 * END cost lineout p2 floatin buffer cvtaf buffer,D6 * SIDE cost lineout p3 floatin buffer cvtaf buffer,D7 * VOLUME ********************************************************************** ** Calculus Answer ** Formula for the radius of the optimum can: ** radius = (((volume*side_cost)/(2*PI*end_cost))^(1/3) ** numerator, volume*side_cost: move.l D7,D1 * VOLUME fmul D6,D1 * VOLUME*SIDE_COST ** denominator, 2*PI*end_cost move.l D5,D2 * END_COST fmul #TWO,D2 * END_COST * 2.0 fmul #PI,D2 * END_COST * 2.0 * PI ** now take result to 1/3 power fdiv D2,D1 * numerator/denominator move.l #ONE_THIRD,D0 fpow D1,D0 *(numerator/denominator) ^ (1/3) ** Calulus answer done, now calculate diameter, height, cost move.l D0,D1 * D1 has radius fmul #TWO,D0 * D0 has diameter cvtfa diameter,#2 ** calculate height = (volume / PI*r^2) move.l D1,D2 * radius fmul D2,D2 * radius^2 fmul #PI,D2 * radius^2*PI move.l D7,D3 * copy of volume fdiv D2,D3 * vol / PI*radius^2 HEIGHT --> D3 move.l D3,D0 cvtfa height,#2 ** calculate cost = SIDE_COST*SIDE_SURFACE + 2*END_COST*END_SURFACE *** side cost: move.l #PI,D2 fmul #TWO,D2 * 2*PI fmul D1,D2 * 2*PI*radius fmul D3,D2 * 2*PI*radius*height = side surface area fmul D6,D2 * side surface area * SIDE_COST *** end cost: move.l #PI,D0 fmul #TWO,D0 * 2*PI fmul D1,D0 * 2*PI*radius fmul D1,D0 * 2*PI*radius*radius fmul D5,D0 * 2*PI*radius*radius*END_COST fadd D2,D0 cvtfa cost,#2 ** DONE, print the calculus answer lineout ans1 lineout ans2 lineout ans3

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote