previous | start | next

Example: f calls sum

int sum(int, int);                  f:                          
                                     pushl   %ebp               
int f()                              movl    %esp, %ebp 
{                                    subl    $24, %esp  
  int n = 5;                         movl    $5, -12(%ebp)      
  int m = 10;                        movl    $10, -8(%ebp)      
  int ans;                           movl    -8(%ebp), %eax     
                                     movl    %eax, 4(%esp)   ; m on the stack  4 bytes below top
  ans = sum(n, m);                   movl    -12(%ebp), %eax    
                                     movl    %eax, (%esp)    ; n at top of the stack
  return 0;                          call    sum             ; call sum(n,m)
}                                    movl    %eax, -4(%ebp)     
                                     movl    $0, %eax   
                                     leave                      
                                     ret                        



previous | start | next