Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:45:17+00:00 2026-06-14T11:45:17+00:00

So i am working on an assembly language program to determine the optimum dimensions

  • 0

So i am working on an assembly language program to determine the optimum dimensions of a closed cylindrical can, such as those used for canning food products. There are three input variables, which i have already created the calculus portion in assembly language code:

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, i have determined the dimensions (height and diameter) of the can such that the cost of the can is minimized. Again i have came up with the calculus portion to solving this program but curious as to what a brute force would look like using a do or while loop. How would one go about doing to create a brute force that generates pretty much the same output as the calculus answer, for example:

Enter the cost of end material per square cm: 
.001
Enter the cost of the side material per square cm: 
.003
Enter the desired volume in milliliters: 
100

Calculus Answer:

Can cost:  0.24
Diameter:  7.25
Height:    2.41  

Brute Force Answer:

Can cost:  0.24
Diameter:  7.25
Height:    2.41

The calculus portion that i have come up with resulting in a calculus answer output is:

********** CONSTANTS **********
TWO:           EQU    $40000000        
PI:            EQU    $40490FDA
ONE_THIRD:     EQU    $3EAAAAAb
START_R:       EQU    $3C23D70A
*******************************

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

How might it be if one wanted to create a brute force for this program using a ‘do’ or ‘while’ loop like below. Can someone help me.

radius = 0.01
lastCost = Calculate

do:
    radius = radius+0.01
    newCost = Calculate
    if(newCost  lastCost)
        goto print
    lastCost = newCost
    goto loop
print lastcost

just curious as to what a brute force method might look like for this, im pretty sure it is basically the same code but just adding a couple of lines of code. I just want to know where might i add those lines of code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:45:20+00:00Added an answer on June 14, 2026 at 11:45 am

    Well if I understand you correctly you only have to calculate ALL combinations of height and width and take the lowest cost.the problem here is to find an interval which will include the best answer, but also a stepsize which is feasible for you current problem (otherwise you will have too many possibilities)
    You also need to set the side condition with height*width²*pi = fixed volumina because if the volumina is smaller (which could happen from some combinations) then the cost would also be smaller

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a program in assembly and it isn't working, so I'd like
I've inherited a 10K-line program written in 8051 assembly language that requires some changes.
I'm trying my hand at working with threads at an assembly language level. I'd
I am working through Kip Irvine's "Assembly Language for x86 Processors, sixth edition" and
I am currently working on a Natural Language processing program in which I am
I have new problem. I'm working with strings in assembly language and I want
I finished reading PC Assembly Language and I was working on an implementation of
I am working on a language translation program where I get information from offline.
I'm working on my first 'real' F# assembly, and trying to do things right.
I am new to PowerPC assembly. I am working with an MPC8245 (yes, old

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.