#include<stdio.h> #include<iostream> int fact(int n) { if (n == 1) return 1; return n * fact(n - 1); } int main() { int a; std::cin >> a; fact(a); return 0; }//记得我大一第一次学习C语言的时候,学到递归那点怎么也想不明白,老师也不给讲明白。不过如果 //能从反汇编的角度来看,可能会容易理解一下。
8: int main() 9: { 01045320 55 push ebp 01045321 8B EC mov ebp,esp 01045323 81 EC D0 00 00 00 sub esp,0D0h 01045329 53 push ebx 0104532A 56 push esi 0104532B 57 push edi 0104532C 8D BD 30 FF FF FF lea edi,[ebp-0D0h] 01045332 B9 34 00 00 00 mov ecx,34h 01045337 B8 CC CC CC CC mov eax,0CCCCCCCCh 0104533C F3 AB rep stos dword ptr es:[edi] 0104533E A1 00 F0 04 01 mov eax,dword ptr ds:[0104F000h] 01045343 33 C5 xor eax,ebp 01045345 89 45 FC mov dword ptr [ebp-4],eax 10: int a; 11: std::cin >> a; 01045348 8B F4 mov esi,esp 0104534A 8D 45 F4 lea eax,[a] 0104534D 50 push eax 0104534E 8B 0D 90 00 05 01 mov ecx,dword ptr ds:[1050090h] 01045354 FF 15 94 00 05 01 call dword ptr ds:[1050094h] 0104535A 3B F4 cmp esi,esp 0104535C E8 7E BF FF FF call __RTC_CheckEsp (010412DFh) 12: fact(a); 01045361 8B 45 F4 mov eax,dword ptr [a] 01045364 50 push eax 01045365 E8 FA BC FF FF call fact (01041064h) 0104536A 83 C4 04 add esp,4 13: return 0; 0104536D 33 C0 xor eax,eax
https://blog.csdn.net/zr_lang/article/details/39962679
原文地址:https://www.cnblogs.com/binanry/p/9742219.html
时间: 2024-11-18 17:52:58