Page 9 - control flow
P. 9

 Kompilasi Loop - Do-While


          Versi Goto                                           Bahasa Assembly




                                              _fact_goto:
                                                 pushl %ebp                             # Setup

                                                 movl %esp,%ebp                         # Setup

                                                 movl $1,%eax                           # eax = 1
                                                 movl 8(%ebp),%edx  # edx = x



                                            L11:
                                                 imull %edx,%eax                       # result *= x

                                                 decl %edx                             # x--
                                                 cmpl $1,%edx                          # Compare x : 1

                                                 jg L11                                # if > goto loop




        Register
              %edx          x

              %eax          result



        Translasi Umum Do-While



                Kode C                                                               Versi Goto











   Body berisi pernyataan-pernyataan C

       Umumnya berisi kumpulan pernyataan :




                                                                             {
          Test adalah ekspresi untuk                                            Statement ;
                                                                                                  1
             kembali dalam integer                                               Statement ;
                                                                                                  2
           =0 diintepretasikan salah                                                 …

                                                                                 Statement ;
           ≠0 diitepretasikan benar                                                               n
                                                                             }
   4   5   6   7   8   9   10   11   12   13   14