title: Calculating an expression in assembly code
body: <p>I have written an assembly code for calculating area mentioned in the following formula <br>
  <a href="https://i.stack.imgur.com/L9XdP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L9XdP.jpg" alt="enter image description here" /></a></p>
  <p>I feel I have overcomplicated the code. Need suggestions if the same could be done in a simpler way.
  I am calculating sqrt of 5 than mul by 2. Each thing is done in a separate line. <Br>
  Is there a way to do it one line or shorter way</p>
  <pre><code>INCLUDE Irvine32.inc
  
  
  .data
  testString BYTE &quot;test&quot;,0
  
  invalidValueString BYTE &quot;invalid value entered for length of edge!&quot;,0
  enterEdgeLength BYTE &quot;Enter the length of the edge e : &quot;,0
  areaString BYTE &quot;Area : &quot;,0
  volumeString BYTE &quot;Volume : &quot;,0
  radiusString  BYTE &quot;Midsphere Radius : &quot;,0
  edgeLength real4 ?
  five real4 5.0
  four real4 4.0
  two real4 2.0
  six real4 6.0
  three real4 3.0
  fortySeven real4 47.0
  ninetyNine  real4 99.0
  twelve real4 12.0
  
  
  .code
  
  call crlf
  
  start:
  mov edx, offset enterEdgeLength
  call writestring
  call readfloat            ; reads the edge length into ST(0)
  fstp edgeLength           ; edgeLength variable will contain the length entered
  cmp edgeLength, 0         ; comparing with 0 
  jl negativeValue          ; if it's less than 0 print error msg and loop to start
  cmp edgeLength, 0
  je stop                   ; if length entered is 0 exit the program
  jmp properValue
  
  negativeValue: 
       mov edx, offset invalidValueString   
       call writestring
       call crlf
       jmp start
  properValue:                   ; call each method one by one to calculate
      call area                  ; area, volume and radius
      call volume 
      call radius
      call crlf
      fstp ST(0)                 ; clear the stack before looping again
      jmp start
      stop:
      exit
  
  area proc
  finit                     
  fld five                ; calculating the constant that is to be multiplied
  fsqrt                   ; with edgelength squared
  fmul two
  fld five
  fadd
  fsqrt
  fmul six
  fld three
  fsqrt
  fadd
  fmul five
                          ; the constant expression is in ST(0)
  fmul edgeLength              
  fmul edgeLength         ; multiply the edgelength squared to ST(0) to get area
  
  call crlf
  mov edx, offset areaString
  call writestring
  call writefloat
  fstp ST(0)
  area endp
  </code></pre>