TITLE Calculating a FactorialINCLUDE Irvine32.inc.codemain PROC push 12 call FactorialReturnMain: call WriteDec call Crlf retmain ENDPFactorial PROC enter 0,0 mov eax,[ebp+8] cmp eax,0 ja L1 mov eax,1 jmp L2L1: dec eax push eax call FactorialReturnFact: mov ebx,[ebp+8] mul ebxL2: leave ret 4Factorial ENDPEND main
这段代码疑惑了很久,认为程序根本没办法正常运行,但调试之后结果却是正常的
最后终于明白了。。。
原来 call 之后压入栈堆是返回到ReturnFact 我本能的以为要返回到Factorial