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

📄 8.2.2d.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.2c.htm'" width="24" height="24"></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.2.3.htm'" width="26" height="24"></img></td>
</tr>
</table>
<br><br>

<table><tr><td>&nbsp</td>
<td class="content">
      <p>如果ssize,psize和qsize分别为20,40和60,SP通过地址100的第一条指令初始化为600,即栈的开始地址。则在控制从s转移到q时,SP值为620,因为ssize等于20。接下来,当q调用p时,地址320的指令将SP增加到680,这是p的活动记录的开始;当控制从p返回时,SP又变成620。如果下面两次关于q的递归调用是立即返回的,则此次运行SP的最大值为680。但请注意,最终可使用的栈地址为739,因为q的活动记录从680开始并占用60个字节。<br></P>
      <center>
      <table>
      	<tr>
      		<td> </td>
      		<td>
		        <font color="#008000">
		        <font >/*(code for s),s的代码*/</font> </font> <br>
		</td>
	</tr>
	<tr>
		<td>
		        100 :MOV #600,SP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		</td>
		<td>
		       <font color="#008000">/*(initialize the stack),初始化栈*/</font> 
		</td>
	</tr>
	<tr>
		<td>
		        108 :ACTION<sub>1</sub> 
		</td>
		<td> </td>
	</tr>
	<tr>
		<td>
		        128 :ADD #ssize,SP
		</td>
		<td>      
		        <font color="#008000" >/*(call scquence begins),调用序列开始*/</font> 
		</td>
	</tr>
	<tr>
		<td>
		        136 :MOV 152,*SP
		</td>
		<td>      
		        <font color="#008000">/*〔Push return address),压入返回地址*/</font> 
		</td>
	</tr>
	<tr>
		<td>
		        144 :GOTO 300<font color="#008000" >
		</td>
		<td>      
		        <font color="#008000">/*(call q),调用q*/ </font>
		        </font>
		</td>
	</tr>
	<tr>
		<td>
		        152 :SUB #ssize,SP
		</td>
		<td>      
		        <font color="#008000" >/*(restore sp),恢复SP*/ </font>
		</td>
	</tr>
	<tr>
		<td>
		        160 :ACTION<sub>2</sub>
		</td>
		<td>&nbsp;      
		</td>
	</tr>
	<tr>
		<td>
		        180 :HALT 
		</td>
		<td>      
		&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        ……
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>&nbsp;
		</td>
		<td>
		        <font ><font color="#008000">/* (code for p)),p的代码*/</font> </font><br>
		</td>
	</tr>
	<tr>
		<td>
		        200 :ACTION<sub>3</sub> <br>
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        220 :GOTO *0(SP)
		</td>
		<td>
		        <font color="#008000" >/*(return),返回*/ </font>
		</td>
	</tr>
	<tr>
		<td>
		        ……
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>&nbsp;
		</td>
		<td>
		        <font color="#008000">/*(code for p),q的代码*/ </font> 
		</td>
	</tr>
	<tr>
		<td>
		        300 :ACTION<sub>4</sub>
		</td>
		<td>
		        <font color="#008000" >/*(conditional jump to 456),条件转移到456*/ </font>
		</td>
	</tr>
	<tr>
		<td>
		        320 :ADD #qsize,SP <br>
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        328 :MOV 344,*SP
		</td>
		<td>
		        <font color="#008000" >/*(push return address),压入返回地址*/ </font>
		</td>
	</tr>
	<tr>
		<td>
		        336 :GOTO 200
		</td>
		<td>
		        <font color="#008000">/*(call p),调用p*/ </font> 
		</td>
	</tr>
	<tr>
		<td>
		        344 :SUB #qsize,SP 
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        352 :ACTION<sub>5</sub> 
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        372 :ADD #qsize,SP <br>
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        380 :MOV 396,*SP
		</td>
		<td>
		        <font color="#008000" >/*(push return address),压入返回地址*/ </font>
		</td>
	</tr>
	<tr>
		<td>
		        388 :GOTO 300<font ><font color="#008000">
		</td>
		<td>
		        <font color="#008000">/*(call q〕,调用q*/ </font>
		</td>
	</tr>
	<tr>
		<td>
		        396 :SUB #qsize,SP 
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        404 :ACTION<sub>6</sub> 
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        424 :ADD #qsize,SP 
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        432 :MOV 440,*SP,
		</td>
		<td>
		        <font color="#008000">/*(push return address),压入返回地址*/</font>
		</td>
	</tr>
	<tr>
		<td>
		        440 :GOTO 300
		</td>
		<td>
		        <font color="#008000">/*(call q),调用口*/</font>
		</td>
	</tr>
	<tr>
		<td>
		        448 :SUB #qsize,SP <br>
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        456 :GOTO,0(SP)
		</td>
		<td>
		        <font color="#008000">/*(return),返回*/</font> 
		</td>
	</tr>
	<tr>
		<td>
		        ……
		</td>
		<td>&nbsp;
		</td>
	</tr>
	<tr>
		<td>
		        600 :</td>
		<td>
		        <font color="#008000" >/*(stack starts here),栈从此处开始*/</font>
		</td>
	</tr>
	<tr>
		<td colspan=2 >&nbsp;
		</td>
	</tr>
	<tr>
		<td colspan=2 >
		      <p align="center">图8.5相应图8.4的目标代码 </P>
		<td>
	     </tr>	
	  </table>		
      </center>   
</td></tr></table>


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

</BODY>
</html>

⌨️ 快捷键说明

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