-
-
[旧帖]
[原创]C语言——数组和简单栈
0.00雪花
-
发表于:
2011-5-27 21:46
2938
-
[旧帖] [原创]C语言——数组和简单栈
0.00雪花
数组
具有相同属性的,在内存中顺序排列的一组数据。
int nAge1,nAge2,nAge3…nAge49;
int nAge[50] = {0};
上述两实质是相同的,只是数组提供了跟好的管理,将相同的类型的数据组织起来使用。
int nAge1 = 0x19880808;
00324335 mov dword ptr [nAge1],19880808h
int nAget2 = 0x19870707;
0032433C mov dword ptr [nAget2],19870707h
//.............
int nAge50 = 0x19890909;
00324343 mov dword ptr [nAge50],19890909h
int nAge[50] = {1,2,3,4,5};
0032434A mov dword ptr [nAge],1
00324354 mov dword ptr [ebp-0ECh],2
0032435E mov dword ptr [ebp-0E8h],3
00324368 mov dword ptr [ebp-0E4h],4
00324372 mov dword ptr [ebp-0E0h],5
int nHight[50] ;
for (int i = 0; i < sizeof(nAge)/sizeof(nAge[0]); ++i)
{
nHight[i] = i;
*(int*)(nAge+i) = i;
}
for (int i = 0; i < sizeof(nAge)/sizeof(nAge[0]); ++i)
01144363 mov dword ptr [i],0
0114436D jmp wmain+6Eh (114437Eh)
0114436F mov eax,dword ptr [i]
01144375 add eax,1
01144378 mov dword ptr [i],eax
0114437E cmp dword ptr [i],32h
01144385 jae wmain+9Fh (11443AFh)
{
nHight[i] = i;
01144387 mov eax,dword ptr [i]
0114438D mov ecx,dword ptr [i]
01144393 mov dword ptr nHight[eax*4],ecx
*(int*)(nAge+i) = i;
0114439A mov eax,dword ptr [i]
011443A0 mov ecx,dword ptr [i]
011443A6 mov dword ptr nAge[eax*4],ecx
}
int nTemp1 = nHight[20];
int nTemp2 = *(nHight + 20);
int nTemp3 = *((char*)nHight +sizeof(nHight[0]/*sizeof(int)*/)*20);
int nTemp1 = nHight[20];
003343AF mov eax,dword ptr [ebp-170h]
003343B5 mov dword ptr [nTemp1],eax
int nTemp2 = *(nHight + 20);
003343BB mov eax,dword ptr [ebp-170h]
003343C1 mov dword ptr [nTemp2],eax
int nTemp3 = *((char*)nHight + sizeof(nHight[0]/*sizeof(int)*/)*20);
003343C7 movsx eax,byte ptr [ebp-170h]
003343CE mov dword ptr [nTemp3],eax
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课