📄 8.5.2_2b.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.5.2_2.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.6.1.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>    </td>
<td class="content">
<BR><b> </b><font class="definition2">为条件语句生成目标代码</font><P> 大多数计算机使用一组条件码来指示最后计算出来的或存入一个寄存器的数值是为负、零或正。运用一个比较指令(在我们的目标机器上为CMP)可以置条件码而不必实际地计算出一个值来。例如,CMP
x,y在x>y时将条件码置为正等等,当满足一个指定的条件<,=,>,≤,≠或≥时,条件转移指令将进行转移。我们使用“CJ<=z”来表示“如果条件码为负或为零,则转移到z”。这样,条件语句if
x<y goto z将用如下序列来实现。</P>
<P>
CMP x,y<br></p>
<p>
CJ< z<br> </p>
又如三地址语句序列<br>
<p>
x:=y+z <br></p>
<p>
if x<0 goto p<br> </P>
可实现如下:<br>
<p>
MOV y,R0 <br></P>
<p>
ADD z,R0<br></p>
<p>
MOV R0,x <br></p>
<p>
CJ< p</P>
</td></tr><tr><td width="18"></td>
<td class="content" width="868">
</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.5.2_2.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='8.6.1.htm'"></img></td>
</tr>
</table>
</BODY>
<html><script language="JavaScript">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -