美文网首页
if switch while dowhile for

if switch while dowhile for

作者: Justin_901e | 来源:发表于2019-07-17 17:52 被阅读0次

7  int LoopDO(int nCount) {

8  int nSum = 0;

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

9  int nIndex = 0;

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

10 do {

11 nSum += nIndex;

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

add eax,dword ptr ss:[ebp-14]

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

12 nIndex++;

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

add eax,1

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

13 } while (nIndex <= nCount);

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

cmp eax,dword ptr ss:[ebp+8]

jle if.19171C

14 return nSum;

mov eax,dword ptr ss:[ebp-8]  将返回值放入eax

15 }

16 int LoopWhile(int nCount) {

17 int nSum = 0;

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

18 int nIndex = 0;

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

19 while (nIndex <= nCount)

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

cmp eax,dword ptr ss:[ebp+8]

jg if.191818

20 {

21 nSum += nIndex;

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

add eax,dword ptr ss:[ebp-14]

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

22 nIndex++;

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

add eax,1

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

23 }

jmp if.1917FC

24 return nSum;

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

25 }

26 int LoopFor(int nCount) {

27 int nSum = 0;

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

28 for (int nIndex = 0; nIndex <= nCount; nIndex++) {

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

jmp if.191797

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

add eax,1

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

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

cmp eax,dword ptr ss:[ebp+8]

jg if.1917AA

29 nSum += nIndex;

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

add eax,dword ptr ss:[ebp-14]

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

30 }

jmp if.19178E

31 return nSum;

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

32 }

34 int main(int argc, char *argv[])

35 {

36 if (argc == 0) {

cmp dword ptr ss:[ebp+8],0    和0比较

jne if.191935     jne: 当零标志 Z=0 则跳转; 否则 零标志 Z=1 则顺序执行下一条指令( jump not equall 不相等跳转)

37 printf("justin %d \r\n", argc);

38 }

39 if (argc > 0) {

cmp dword ptr ss:[ebp+8],0

jle if.19194C    小于等于时跳转

40 printf("justin %d \r\n", argc);

41 }

42 if (argc == 0) {

cmp dword ptr ss:[ebp+8],0

jne if.19195B   不相等时跳转

43 argc = 5;

mov dword ptr ss:[ebp+8],5

44 }

45 else {

jmp if.191962

46 argc = 6;

mov dword ptr ss:[ebp+8],6

47 }

49 int nIndex = 1;

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

50 switch (nIndex)

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

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

51 {

52 case 1: printf("nIndex == 1"); break;

cmp dword ptr ss:[ebp-D0],1

je if.19197D

jmp if.19198C

push if.197B40

call if.191339

add esp,4

54 default:

55 printf("default");

56 break;

57 }

59 LoopDO(2);

push 2

call if.1910FA

add esp,4

60 LoopWhile(2);

push 2

call if.191127

add esp,4

61 LoopFor(2);

push 2

call if.1911E0

add esp,4

63    return 0;

64 }

相关文章

网友评论

      本文标题:if switch while dowhile for

      本文链接:https://www.haomeiwen.com/subject/ujlclctx.html