Chapter 9 Subprogram Control.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter 9 Subprogram Control.ppt

Chapter 9 Subprogram Control Consider program as a tree- Each parent calls (transfers control to) child Parent resumes when child completes Copy rule – consider child code as copied into parent Subprogram used to Separate program into logical units Execute functions with different parameters Recursion Must maintain storage for multiple copies of data Code is reentrant – stored separately Storage for return address and data Indirect recursion We do not know the number of times that our code or data will be copied PL/1 – specific statement – is recursive Non-recursive subprogram does not need stack implementation Execution structure Child is explicitly called (exceptions are not) Entrance at top or elsewhere FORTRAN, coroutines (resume) Scheduled subprogram call can delay transfer of control Coroutines have multiple activation records active at one time but single thread of control – their execution can be traced Tasks have multiple activation records active at one time and conceptually allow multiple threads of control Implementation of non-recursive routines For execution efficiency Code and data may be joined, with code directly referencing data address Return address stored in no-op at top of subroutine code Last statement of subroutine is branch to first address, indirectly For reliability, may require that code be stored separately (non self modifying code) Cost in storage of all (but smaller) activation records during program’s lifetime Implementation for recursive routines Activation records (frames) on stack contain Caller’s return address (next CIP) Parameters Local variables Return value for functions and temps Ptr to parent activation record (static chain ptr) Ptr to caller’s activation record (dynamic chain ptr) Register contains PC (Current Instruction Ptr) Register contains base address of activation record (current environment pointer) Register contains stack pointer Storage map in general System and program code Static variables Activation records –

文档评论(0)

gshshxx + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档