数组

2019-07-17  本文已影响0人  Justin_901e

下面示例分别示例了 函数内数组,数组作为参数,数组作为返回值 

7 void Show(char szBuffer[]) {

//strcpy(szBuffer, "Hello World");

9 printf(szBuffer);

10 }

11 char* RetArray() {

12 char szBuff[] = { "Hello World" };

13 return szBuff;

14 }

16 int main()

17 {

18 int nArray[5] = { 1,2,3,4,5 };

mov dword ptr ss:[ebp-1C],1

mov dword ptr ss:[ebp-18],2

mov dword ptr ss:[ebp-14],3

mov dword ptr ss:[ebp-10],4

mov dword ptr ss:[ebp-C],5

19 int nOne = 1;

mov dword ptr ss:[ebp-28],1

20 int nTwo = 2;

mov dword ptr ss:[ebp-34],2

21 int nThree = 3;

mov dword ptr ss:[ebp-40],3

22 int nFour = 4;

mov dword ptr ss:[ebp-4C],4

23 int nFive = 5;

mov dword ptr ss:[ebp-58],5

25 char cChar = 'A';

mov byte ptr ss:[ebp-61],41

26 float fFour = 1.0f;

movss xmm0,dword ptr ds:[<__real@3f800000>]

movss dword ptr ss:[ebp-70],xmm0

27 short sShort = 1;

mov eax,1

mov word ptr ss:[ebp-7C],ax

28 int nInt = 2;

mov dword ptr ss:[ebp-88],2

29 double dDouble = 2.0f;

movsd xmm0,qword ptr ds:[<__real@4000000000000000>]

movsd qword ptr ss:[ebp-98],xmm0

//数组作为参数

32 char szHello[20] = { 0 };

xor eax,eax

mov dword ptr ss:[ebp-B4],eax

mov dword ptr ss:[ebp-B0],eax

mov dword ptr ss:[ebp-AC],eax

mov dword ptr ss:[ebp-A8],eax

mov dword ptr ss:[ebp-A4],eax

33 Show(szHello);

lea eax,dword ptr ss:[ebp-B4]

push eax

call array.CB123A

add esp,4

//数组作为返回值

36 printf("justin %s \r\n", RetArray());

call array.CB12DF

push eax

push array.CB7B40

call array.CB1334

add esp,8

//下标寻址和指针寻址

39 char * pChar = NULL;

mov dword ptr ss:[ebp-C0],0

40 char szBuff[] = "Hello";

mov eax,dword ptr ds:[CB7B50]

mov dword ptr ss:[ebp-D0],eax

mov cx,word ptr ds:[CB7B54]

mov word ptr ss:[ebp-CC],cx

41 pChar = szBuff;

lea eax,dword ptr ss:[ebp-D0]

mov dword ptr ss:[ebp-C0],eax

42 printf("%c", *pChar);

mov eax,dword ptr ss:[ebp-C0]

movsx ecx,byte ptr ds:[eax]

push ecx

push array.CB7B58

call array.CB1334

add esp,8

43 printf("%c", szBuff[0]);

mov eax,1

imul ecx,eax,0

movsx edx,byte ptr ss:[ebp+ecx-D0]

push edx

push array.CB7B58

call array.CB1334

add esp,8

 45   return 0;

}

上一篇下一篇

猜你喜欢

热点阅读