title: Pushing 3 inputs in stack, assembly language
body: <p>I am trying to calculate the result with three inputs but I have been getting error. I guess something is wrong with push and pop instructions. I have posted the picture of error.
  Any help is highly appreciated.
  I am using Visual Studio 2015.</p>
  <p>I am trying to calculate the result with three inputs but I have been getting error. I guess something is wrong with push and pop instructions. I have posted the picture of error.
  Any help is highly appreciated.
  I am using Visual Studio 2015.</p>
  <p>UPDATED: This problem has been solved by replacing [add esp, 8] with [add esp, 12]</p>
  <pre><code>.586
  .MODEL FLAT
  INCLUDE io.h
  .STACK 4096
  
  .DATA
  number1 DWORD ?
  number2 DWORD ?
  number3 DWORD ? 
  prompt1 BYTE &quot;Enter first number, x&quot;, 0 
  prompt2 BYTE    &quot;Enter second number, y&quot;, 0 
  prompt3 BYTE       &quot;Enter second number, z&quot;, 0 
  string  BYTE    40 DUP(? ) 
  resultLbl BYTE    &quot;result&quot;, 0 
  sum     BYTE    11 DUP(? ), 0
  
     .CODE    
    _MainProc PROC 
     input   prompt1, string, 40 
     atod    string 
     mov     number1, eax
  
     input   prompt2, string, 40 
     atod    string 
     mov     number2, eax
  
     input   prompt3, string, 40 
     atod    string
     mov     number3, eax
  
     push number3 
     push number2 
     push number1
  
     call fctn1 
     
     add esp, 8
     dtoa    sum, eax 
     output  resultLbl, sum
     mov     eax, 0 
     ret    
     _MainProc ENDP
  
  
  
  
     fctn1 PROC 
     push ebp 
     mov ebp, esp 
  
     push ebx
  
     mov eax, [ebp + 8] 
     imul eax, 3 
     mov ebx, [ebp+12]
     imul ebx, 7 
     add eax, ebx 
     mov ecx, [ebp+16]
     imul ecx, 2 
     add eax, ecx
  
     pop ebx 
     pop ebp
     ret
     fctn1 ENDP
  
     END
  </code></pre>
  <p><a href="https://i.stack.imgur.com/oIWz5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oIWz5.png" alt="enter image description here" /></a></p>