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

📄 8.8.2.htm

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

<head>
<title>8.2的解答</title>
</head>

<body background="../images/background.gif">

<center><font class="title2"><b>练习8.2</b></font></center><br>

<p align="left">解:</p>

<p align="left">&nbsp;&nbsp;&nbsp;&nbsp; 设栈顶活动记录的开始地址在R<sub>0</sub>中,用变量的名字表示其在活动记录中的偏移量(offset)。例如,变量a的地址表示成 
a(R<sub>0</sub>)。<br>
&nbsp;&nbsp;&nbsp;&nbsp; 目标代码如下:</p>

<p align="left"><span lang="EN-US">&nbsp;&nbsp;&nbsp; (a)</span><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;
mso-hansi-font-family:&quot;Times New Roman&quot;"> 
MOV&nbsp;&nbsp;&nbsp; #1&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; x(R</span><sub>0</sub><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;
mso-hansi-font-family:&quot;Times New Roman&quot;">)</span></p>

<p align="left"><span lang="EN-US">&nbsp;&nbsp;&nbsp; (b)</span><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:
&quot;Times New Roman&quot;"> 
MOV&nbsp;&nbsp;&nbsp; y(R</span><sub>0</sub><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:
&quot;Times New Roman&quot;">) 
&nbsp; &nbsp;x(R</span><sub>0</sub><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:
&quot;Times New Roman&quot;">)</span></p>

<p><span lang="EN-US">&nbsp;&nbsp;&nbsp; (c)</span><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:
&quot;Times New Roman&quot;"> 
ADD&nbsp;&nbsp;&nbsp; #1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x(R</span><sub>0</sub><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:
&quot;Times New Roman&quot;">)</span></p>

<p><span lang="EN-US">&nbsp;&nbsp;&nbsp; (d)</span><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:
&quot;Times New Roman&quot;"> 
MOV&nbsp;&nbsp;&nbsp; b(R</span><sub>0</sub><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:
&quot;Times New Roman&quot;">) 
&nbsp;&nbsp; R</span><sub>1</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MUL&nbsp;&nbsp;&nbsp; c(R<sub>0</sub>) 
&nbsp;&nbsp; R<sub>1</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADD&nbsp;&nbsp;&nbsp; a(R<sub>0</sub>) 
&nbsp;&nbsp; R<sub>1</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MOV&nbsp;&nbsp;&nbsp; R<sub>1</sub> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x(R<sub>0</sub>)<sub>&nbsp;&nbsp;&nbsp;&nbsp; </sub></p>

<p><span lang="EN-US">&nbsp;&nbsp;&nbsp; (e)</span><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:
&quot;Times New Roman&quot;"> 
MOV&nbsp;&nbsp;&nbsp; a(R</span><sub>0</sub><span
style="font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:
&quot;Times New Roman&quot;">) 
&nbsp;&nbsp; R</span><sub>1</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MOV&nbsp;&nbsp;&nbsp; b(R<sub>0</sub>) 
&nbsp;&nbsp; R<sub>2</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADD&nbsp;&nbsp;&nbsp; c(R<sub>0</sub>) 
&nbsp;&nbsp; R<sub>2</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DIV&nbsp;&nbsp;&nbsp; R<sub>2</sub> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; R<sub>1</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MOV&nbsp;&nbsp;&nbsp; e 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; R<sub>2</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADD&nbsp;&nbsp;&nbsp; f 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; R<sub>2</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MUL&nbsp;&nbsp;&nbsp; d(R<sub>0</sub>) 
&nbsp;&nbsp; R<sub>2</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SUB&nbsp;&nbsp;&nbsp; R<sub>2</sub> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; R<sub>1</sub><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MOV&nbsp;&nbsp;&nbsp; R<sub>1</sub> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x(R<sub>0</sub>)</p>
</body>
</html>

<html><script language="JavaScript">

⌨️ 快捷键说明

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