title: How to pass parameters to a procedure in assembly?
body: <p>I have a C program that calls a two procedures from my assembly file, the procedures are defined like this <code>extern int myfunc(int a,int b)</code> and <code>myfunc2(int c,int d)</code> ,now after <code>myfunc</code> call in C, i can access the parameters in assembly like this: <strong>b</strong> is at <code>[BP+6]</code> and <strong>a</strong> is at <code>[BP+4]</code> this is in the SMALL MODEL.
  Now i want to call <code>myfunc2(int c,int d)</code> but from my assembly file while i'm in my <code>myfunc</code>.
  How do i set up the stack for <code>myfunc2</code> and pass it parameters?
  And will it mess up the current stack for <code>myfunc</code> ,if yes how do i deal with that?
  <strong>MY Assembly file:</strong></p>
  
  <pre><code>.MODEL SMALL
  .STACK 100h
  .DATA
  .CODE
  PUBLIC _myfunc
  PUBLIC _myfunc2
  _myfunc PROC NEAR
  .386
  PUSH BP
  MOV BP,SP
  ;here i need to do myfun2(1,2)
  POP BP
  RET
  _myfunc ENDP
  
  _myfunc2 PROC NEAR
  .386
  PUSH BP
  MOV BP,SP
  MOV DX,[BP+6];get d
  MOV AX,[BP+4];get c
  ADD AX,DX;add them up
  ;the return value will be in AX
  POP BP
  RET
  _myfunc2 ENDP
  
  END
  </code></pre>
  
  <p><strong>MY C file:</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt; 
  #include &lt;stdlib.h&gt; 
  
  extern int myfunc(int a,int b);
  extern int myfunc2(int c,int d);
  int main()
  {
      int res;
      res=myfunc(int a,int b);
  }
  </code></pre>