Page 9 - BG555
P. 9

Contoh Program : Swap                                                                                           swap:


                                                                                                                             pushl %ebp
       void swap(int *xp, int                                                                                                movl %esp,%ebp                                         Set


       *yp)                                                                                                                  pushl %ebx                                             Up


       {


            int t0 = *xp;                                                                                                     movl 12(%ebp),%ecx



            int t1 = *yp;                                                                                                     movl 8(%ebp),%edx
                                                                                                                              movl (%ecx),%eax
            *xp = t1;                                                                                                         movl (%edx),%ebx                                      Body


            *yp = t0;                                                                                                         movl %eax,(%edx)

                                                                                                                              movl %ebx,(%ecx)
       }






                                                                                                                              movl -4(%ebp),%ebx

                                                                                                                              movl %ebp,%esp

                                                                                                                              popl %ebp                                             Finish

                                                                                                                              ret
   4   5   6   7   8   9   10   11   12   13   14