Array and pointer array assembly differences

Source: Internet
Author: User

int array[] = {2,3,4,5};
00A3355E mov dword ptr [array],2
00a33565 mov dword ptr [ebp-10h],3
00A3356C mov dword ptr [ebp-0ch],4
00a33573 mov dword ptr [ebp-8],5
int *p =array;
00a3357a Lea Eax,[array]
00A3357D mov dword ptr [P],eax

printf ("%d\t", array[2]);
00A33580 mov Esi,esp
00a33582 mov eax,dword ptr [ebp-0ch]
00a33585 push EAX
00a33586 Push offset string "%d/t" (0a357a0h)
00a3358b call DWORD ptr [__imp__printf (0a382c0h)]
00a33591 Add esp,8
00a33594 CMP ESI,ESP
00a33596 call @ILT +315 (__RTC_CHECKESP) (0a31140h)
printf ("%d\t", p[2]);
00A3359B mov Esi,esp
00a3359d mov eax,dword ptr [p]
00A335A0 mov ecx,dword ptr [eax+8]
00A335A3 push ECX
00A335A4 Push offset string "%d/t" (0a357a0h)
00a335a9 call DWORD ptr [__imp__printf (0a382c0h)]
00A335AF Add esp,8
00A335B2 CMP ESI,ESP
00A335B4 call @ILT +315 (__RTC_CHECKESP) (0a31140h)
printf ("%d\t", * (p+2));
00A335B9 mov Esi,esp
00A335BB mov eax,dword ptr [p]
00A335BE mov ecx,dword ptr [eax+8]
00A335C1 push ECX
00A335C2 Push offset string "%d/t" (0a357a0h)
00a335c7 call DWORD ptr [__imp__printf (0a382c0h)]
00A335CD Add esp,8
00A335D0 CMP ESI,ESP
00A335D2 call @ILT +315 (__RTC_CHECKESP) (0a31140h)
return 0;
00a335d7 XOR Eax,eax

The array name itself is an address constant

The following table addressing is achieved by (first address + offset)

The pointer itself is a variable whose value is the first address of the array

Pointer addressing takes its value first, plus the offset

Array and pointer array assembly differences

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.