See C + + (the process of judgment) with Assembly vision

Source: Internet
Author: User

Turn from: http://blog.csdn.net/feixiaoxing/article/details/6761837#comments

In our usual programming, used to judge a lot of places, but there are three main ways: If-else;switch; :。 One of the last ways is essentially the same as if-else. Switch and If-else are actually the same, if we change the switch to if (...). {} else if (...). {} else {}, then you achieve the same effect as the switch actually, familiar friends will have this experience. Perhaps some friends still do not believe that, we can use their own to write examples of comparison to see.

(1) is the break in switch important?

View Plain 21:       int m = 10;   004017A8    mov         dword ptr [ebp-4],0Ah    22:       switch (m)    23:        {   004017af   mov          eax,dword ptr [ebp-4]   004017b2   mov          dword ptr [ebp-8],eax   004017b5   cmp          dword ptr [ebp-8],0Ah   004017b9   je           process+33h  (004017C3)    004017BB    cmp         dword ptr [ebp-8],0bh    004017bf   je          process+42h  (004017D2)     004017c1   jmp         process+4fh  ( 004017DF)    24:       case 10:   25:            printf ("ten!\n");   004017C3    push        offset string  "ten!\n"   (0046f028)     004017c8   call        printf  (004214d0)    004017cd   add         esp,4    26:           break;   004017D0    jmp         process+4Fh  (004017DF)    27 :   28:       case 11:   29:            printf ("eleven!\n");   004017d2   push         offset string  "eleven!\n"   (0046f01c)    004017d7    call        printf  (004214d0)    004017dc    add         esp,4   30:            break;  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.