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

📄 7.1.3.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='7.1.2.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='7.1.4.htm'"></img></td>
</tr>
</table>
<br><br>

<font class="title2"><b>7.1.3 三地址语句的种类</b></font> 
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
三地址语句与汇编语言代码是类似的。语句可以带有用符号命名的标号,而且存在各种控制流语句。下面列出本书所使用的三地址语句的种类:
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
(1)赋值语句形如x:=y op z,其中op为二目算术算符或逻辑算符。 
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
(2)赋值语句也可形如x:=op y,其中op为一目算符,如一目减uminus、逻辑非not、移位算符及转换算符(如将定点数转换成浮点数)。 
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
(3)复制语句形如x:=y,它将y的值赋给x。
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
(4)无条件转移语句形如<B>goto L</B>,即下一条将被执行的语句是带标号L的语句。
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
(5)条件转移语句形如<B>if</B> x <B>relop</B> y goto <B>L</B>。此语句施用关系运算符号<B>relop</B>(如&lt;  
,=,>= 等等)于x和y,倘若x与y有关系<B>relop</B>,那么下面就执行带标号L的语句,否则下面就继续执行if语句之后的语句。 
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
(6)过程调用语句形如param x和<B>call</B> p,n源程序中的过程调用语句p(x<SPAN class=down><sub>1</sub></SPAN>,x<SPAN class=down><sub>2</sub></SPAN>,…,x<SPAN class=down><sub>n</sub></SPAN>)可以产生如下的三地址代码:
</p>
</td></tr></table>
<center>
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
param x<SPAN class=down><sub>1</sub></SPAN>
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
param x<SPAN class=down><sub>2</sub></SPAN>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
……
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
param x<SPAN class=down><sub>n</sub></SPAN>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
call p,n
</td></tr></table>
</center>
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
其中n为指示实参个数的整数。过程返回语句形如return y,其中y为过程返回的一个值。
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
(7)索引赋值形如x:=y[i]及x[i]:=y。前者把从地址y开始的第i个地址单元里的值赋给x。后者把y的值赋给从地址x开始的第i个地址单元。在这两条指令中的x,y和i均指数据对象。
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
(8)地址和指针赋值形如x:=&y,x:=*y和*x:=y。其中第一个赋值语句x:=&amp;y,将把y的地址赋给x。这里假定y是一个名字,或者是一个临时变量,此临时变量代表一个具有左-值(l-va1ue)的表达式,例如A[i,j];并且是一个指针名字或临时变量。那就是说,x的右-值(r-va1ue)将被赋予对象y的左-值。第二个赋值语句x:=*y,假定y是一个指针或者是一个右-值为地址的临时变量。此语句执行的结果是把y所指示的地址单元里存放的内容赋给x。而第三个赋值语句*x:=y,将置x所指向的对象的右-值为y的右-值。
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
在设计中间代码形式时,选择多少种算符方为合适常常引起争论。显然,算符种类应足以用来实现源语言中的运算。一个小型算符集合较易于在目标机器上实现,但可能使得产生的中间代码冗余低效,并从而需要在目标代码生成时做较多的工作以获得高效的代码
</p>
</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='7.1.2.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='7.1.4.htm'"></img></td>
</tr>
</table>

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

⌨️ 快捷键说明

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