C ++ disassembly 10 (array)

Source: Internet
Author: User
15: void arraytest () 16: {004010d0 push ebp004010d1 mov EBP, esp004010d3 sub ESP, pull Push Pull push edi004010d9 Lea EDI, [ebp-5Ch] 004010dc mov ECx, 1_mov eax, 0cccccccch004010e6 rep STOs dword ptr [EDI] // initialization 17: const int arrsize = 5; 004010e8 mov dword ptr [ebp-4], 5 // The ebp-4 where the array length is assigned 518: int arr [arrsize] = {0}; 004010ef mov dword ptr [ebp-18h], 0 // The ebp-18 is the first address of the array, this sentence = arr [0] = 0; 004010f6 XOR eax, eax004010f8 mov dword ptr [ebp-14h], eax // arr [1] = 0004010fb mov dword ptr [ebp-10h], eax // arr [2] = 0004010fe mov dword ptr [ebp-0Ch], eax // arr [3] = 000401101 mov dword ptr [ebp-8], eax // arr [4] = 019: For (INT I = 0; I <arrsize; I ++) 00401104 mov DWORD PTR [ebp-1Ch], 0 // cyclic variable assigned Initial Value 00040110b JMP arraytest + 46 h (00401116) // hop comparison, determine whether the cyclic condition meets the 0040110d mov ECx, dword ptr [ebp-1Ch] // put the loop variable ecx00401110 add ECx, 1 // ECx ++ 00401113 mov dword ptr [ebp-1Ch], ECX // ECx puts the cyclic variable + + 00401116 cmp dword ptr [ebp-1Ch], 5 // cyclic variable and 5 compare 0040111a jge arraytest + 58 h (00401128) // If the cyclic variable is greater than or equal to 5, the loop is completed. The loop jumps out of the 20: {21: arr [I] = I; 0040111c mov edX, dword ptr [ebp-1Ch] // The loop is not over, put the loop variable value in edX, used to address the array 0040111f mov eax, dword ptr [ebp-1Ch] // put the loop variable into eax00401122 mov dword ptr [EBP + EDX * 4-18 h], eax // The first address of the array at the ebp-18, this address + sizeof (array type) is the memory address of the next array element. Here sizeof (INT) = 4; 22:} 00401126 JMP arraytest + 3DH (0040110d) // continue loop 23:} 00401128 pop edi00401129 pop esi0040112a pop ebx0040112b mov ESP, ebp0040112d pop ebp0040112e RET

Related Article

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.