⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8.2.1b.htm

📁 建立《编译原理网络课程》的目的不仅使学生掌握构造编译程序的原理和技术
💻 HTM
字号:
<html>

<head>
<title>编译原理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link type="text/css" rel="stylesheet" href="../css/specification.css">
</head>

<body>

<table align=right width=300>
<tr>
<td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.2.1.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.2.2.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P><FONT class=example><img border="0" src="images/dingyi.gif" width="32" height="31">例8.1&nbsp;</FONT>  
图8.3的指令代码是由图8.2中的过程s和过程p形成的。我们采用伪指令ACTION来实现语句action,它代表那些与本次讨论无关的三地址代码。另外,我们假定过程的代码分别从地址100和200开始,旦每一条ACTION指令占20个字节。过程的活动记录分别从地址300和地址364开始静态地分配。     
<center>
<table border="0" width="550">
  <tr>
    <td width="50%"></td>
    <td width="50%"><font color="#008000">/*s的代码*/</font></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 100:ACTION<sub>1</sub></td>  
    <td width="50%"></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 120: MOV 140,364</td>   
    <td width="50%"><font color="#008000">/*保存返回地址140*/</font></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 132:GOTO 200</td>   
    <td width="50%"><font color="#008000">/*调用p*/</font></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 140:ACTION<sub>1</sub></td>  
    <td width="50%"></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 160:HALT</td>  
    <td width="50%"></td>
  </tr>
  <tr>
    <td width="50%">     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ......</td>  
    <td width="50%"></td>
  </tr>
  <tr>
    <td width="50%"></td>
    <td width="50%"><font color="#008000">/*p的代码*/</font></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 200:ACTION<sub>1</sub></td>  
    <td width="50%"></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 220:GOTO *364</td>   
    <td width="50%"><font color="#008000">/*返回到364存储单元里存放的地址*/</font></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ......</td>  
    <td width="50%"></td>
  </tr>
  <tr>
    <td width="50%"></td>
    <td width="50%"><font color="#008000">/*300-363保留着s的活动记录*/</font></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 300:</td>  
    <td width="50%"><font color="#008000">/*返回地址*/</font></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 304:</td>  
    <td width="50%"><font color="#008000">/*s的局部数据*/</font></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ......</td>  
    <td width="50%"></td>
  </tr>
  <tr>
    <td width="50%"></td>
    <td width="50%"><font color="#008000">/*364-451保留着p的活动记录*/</font></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 364:</td> 
    <td width="50%"><font color="#008000">/*返回地址*/</font></td>
  </tr>
  <tr>
    <td width="50%">&nbsp;&nbsp;&nbsp; 368:</td> 
    <td width="50%"><font color="#008000">/*p的局部数据*/</font></td>
  </tr>
</table>
</center>
<P align=center>图8.3&nbsp;&nbsp;相应图8.2的输入的目标代码</P>
<P>从地址100开始的指令实现第一个过程s的语句:</P>
<P align=center>action<sub>1</sub>; call p; action<sub>2</sub>; halt</P> 
因此,执行是从地址100的ACTION<sub>1</sub>指令开始的,地址120的MOV指令将返回地址140存入机器状态域中,即存入过程p的活动记录的第一个字中,地址132的GOTO指令将控制转移到被调用过程的目标代码。 
<p>由于返回地址值140通过以上调用序列已存放到地址364中,从而当执行地址220的GOTO语句时,*364表示140。因此控制将返回到地址140,恢复调用过程继续运行。




</td></tr></table>

<br>
<table align=right width=300>
<tr>
<td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.2.1.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.2.2.htm'"></img></td>
</tr>
</table>

</BODY>
</html>
<html><script language="JavaScript">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -