title: Stack in NASM assembly
body: <p>I'm trying to convert this piece c code into 64 bit nasm</p>
  
  <pre><code>int gcd ( int a, int b )
  {
    int c;
    while ( a != 0 ) {
       c = a; 
       a = b%a;  
       b = c;
    }
    return b;
  }
  </code></pre>
  
  <p>but i'm not sure where my mistake is, i thought maybe there's something about stack in assembly that i'm not aware of
  this is what i did</p>
  
  <p>calling</p>
  
  <pre><code>push word[max]
  push word[min]
  call gcf
  pop word[num1_ones]
  </code></pre>
  
  <p>stack function</p>
  
  <pre><code>gcf:
      mov ebp, esp
  while:
      cmp word[ebp+4], 0
      je return
  
      mov dx, 0
      mov ax, word[ebp+6]
      mov bx, word[ebp+4]
      div bx                                  
  
      mov word[ebp+4], dx         
      mov word[ebp+6], bx         
  
      jmp while
  
  return:
      ret 2
  </code></pre>
  
  <p>When I run it, I get this:<br>
  <img src="https://i.stack.imgur.com/5cfo0.png" alt="terminal output"></p>