Page 32 - Prosedur
P. 32

Passing Pointer





                                                                                                                                          Stack pada waktu call
            Memanggil s_helper dari sfact

                                                                                                                                         8                    x




          leal -4(%ebp),%eax # Compute &val                                                                                              4            Rtn adr


          pushl %eax                               # Push on stack                                                                       0          Old %ebp                        %ebp

          pushl %edx                               # Push x


           call s_helper # call                                                                                                       -4             val =x!


          movl -4(%ebp),%eax # Return val                                                                                             -8


          • • •                                    # Finish
                                                                                                                                         -


                                                                                                                                      12              Unused




                  int sfact(int x)                                                                                                       -


                  {                                                                                                                   16

                      int val = 1;  s_helper(x,

                      &val);  return val;                                                                                                               &val


                  }                                                                                                                                           x                     %esp
   27   28   29   30   31   32   33