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

📄 8.3.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.3.1.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.3.2.htm'"></img></td>
</tr>
</table>
<br><br>
</table>
<P><B><FONT class=example><img border="0" src="images/dingyi.gif" width="32" height="31">例 
8.2&nbsp;</FONT> </B>考虑图8.6中显示的示意性源代码的片殷。它计算两个长度为20的向量a和b的点乘。在我们的目标机器上完成该计算的三地址语句序列见图8.7。</P> 
<table>
	<tr>
		<td width=150>&nbsp;</td>
		<td>
			<P><font color="#0000FF">begin</font> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prod:=0; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i:=1; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000FF">do begin</font>   
			<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prod:=prod+prod a[i] *b[i]; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i:=i+1;<br>   
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000FF">end</font>  
			<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000FF">while</font> i&lt;=20 <BR>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000FF">end</font>;</P>  
			<P>图8.6&nbsp;&nbsp;计算向量点积程序</P>
		</td>
	</tr>
</table>
<P>现在我们采用算法8.1来生成图8.7的三地址代码的基本块。由规则(a),语句(1)为一个入口语句。由规则(b),语句(3)也是一个入口语句,因为从最后一条语句可以转移到该语句。由规则(b),接在语句(14)后的语句是一个入口语句(图8.6仅是一个程序的片段)。因此,语句(1)和(2)组成一个基本块,从语句(3)开始的程序的余下部分组成一个基本块。</P>
<center>
<table>
	<tr>
		<td>
			<br>&nbsp;&nbsp;(1) prod:=0 
			<br>&nbsp;&nbsp;(2) i:=1    
			<br>&nbsp;&nbsp;(3) t<SPAN class=down><sub>1</sub></SPAN>:=4*i   
			<br>&nbsp;&nbsp;(4) t<SPAN class=down><sub>2</sub></SPAN>:=a-4  
			<br>&nbsp;&nbsp;(5) t<SPAN class=down><sub>3</sub></SPAN>:=t<SPAN class=down><sub>2</sub></SPAN>[t<SPAN class=down><sub>1</sub></SPAN>] <FONT size=+0 color="#008000">/* 计算a[i],见7.3.2节的<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;公式(7.3)—(7.5)*/ </FONT>   
			<br>&nbsp;&nbsp;(6) t<SPAN class=down><sub>4</sub></SPAN>:=4*i   
			<br>&nbsp;&nbsp;(7) t<SPAN class=down><sub>5</sub></SPAN>:=b-4   
			<br>&nbsp;&nbsp;(8) t<SPAN class=down><sub>6</sub></SPAN>:=t<SPAN class=down><sub>5</sub></SPAN>[t<SPAN class=down><sub>4</sub></SPAN>]<FONT size=+0 color="#008000">/*计算b[i]*/ </FONT>  
			<br>&nbsp;&nbsp;(9) t<SPAN class=down><sub>7</sub></SPAN>:=t<SPAN class=down><sub>3</sub></SPAN>*t<SPAN class=down><sub>6</sub></SPAN>   
			<br>&nbsp;&nbsp;(10)t<SPAN class=down><sub>8</sub></SPAN>:=prod+t<SPAN class=down><sub>7</sub></SPAN> 
			<br>&nbsp;&nbsp;(11)prod:=t<SPAN class=down><sub>8</sub></SPAN> 
			<br>&nbsp;&nbsp;(12)t<SPAN class=down><sub>9</sub></SPAN>:=i+1 
			<br>&nbsp;&nbsp;(13)i:=t<SPAN class=down><sub>9</sub></SPAN> 
			<br>&nbsp;&nbsp;(14)if i<=20 <font color="#0000FF"> goto</font>(3)</P> 
			<p>图8.7&nbsp;&nbsp;计算向量点积的三地址代码 </p>
		</td>
	</tr>
</table>
</center>
</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.3.1.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.3.2.htm'"></img></td>
</tr>
</table>

</BODY>

<html><script language="JavaScript">

⌨️ 快捷键说明

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