title: MASM: How to pass value by reference
body: <p>I am trying to pass 2 variables to a procedure, add them together, and return and print the result. I am using the Stack Frame. I am not getting the right result, rather a large incorrect number. Thank you. </p>
  
  <pre><code>        INCLUDE PCMAC.INC
  
  
  .MODEL SMALL
  .586
  .STACK 100h
  .DATA
  sum DWORD ?
  
  .CODE
          EXTRN  GetDec :NEAR, PutDDec : NEAR, PutHex : NEAR
  Main PROC
          _Begin
          push 10
          push 20
  
          call Test12
  
          ; Print result
          call PutDDec
  
          _Exit
  Main ENDP
  Test12 PROC
      push ebp
      mov ebp, esp
  
      mov eax, [ebp+12] ;
      add eax, [ebp+8] ;
  
      pop ebp
      ret 8
  Test12 ENDP
  End Main
  </code></pre>