函数滟归时的活动记录 活动记录参数(实参)返回位置(下一条指令) 局部变量 活动框架 返回地址 活动记录 参数 调用块 ≤下一条指令 Fnc(<参数表>) 函数块 <Return 函数调用与返回
函数递归时的活动记录
long Factorial( long n)i int temp, if (n==0)return 1 else temp =n* Factorial(n-1; Reloc return temp void maine int n. n= Factorial (4); Relock
long Factorial ( long n ) { int temp; if ( n == 0 ) return 1; else temp = n * Factorial (n-1); RetLoc2 return temp; } void main ( ) { int n; n = Factorial (4); RetLoc1 }
计算 Factoria时活动记录的内容 活动记录参数l0ngn返回地址<下一条指令> 参数返回地址 返回时的指令 RetLocl RetLocl n= Factoria(0;/返回到Main程序 递 8 Reloc.letc2tm=46:∥从 Factorial)得到6递 归 return temp;temp=24, 归 用9 RetLoc2 Ret Loc2 temp82:从 factoria()得到2返 调 return temp;/temp=6, 序 次 列□119:02m91从a1得到1序 return tem p ltem p=2 0c)lemp1从aaO)得到1 return temp; temp=
计算Factorial时活动记录的内容