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

📄 4-7.htm

📁 浙江大学计算机学院计算机组成教材《计算机组成与设计》(潘学增)的课堂教学课件。
💻 HTM
📖 第 1 页 / 共 4 页
字号:
      <td width="70" height="4">                           
        <p align="center"><font color="#000000" size="4">0010</font></td>                          
      <td width="110" height="4">                          
        <p align="center"><font color="#000000" size="4">0001                            
        1000</font></td>                           
    </tr>                           
    <tr>                           
      <td width="240" height="9"><font color="#000000" size="4">2a:Rem 0 =&gt; sll R,R0=1</font></td>                           
      <td width="70" height="9">                           
        <p align="center"><font color="#000000" size="4">0010</font></td>                          
      <td width="110" height="9">                          
        <p align="center"><font color="#000000" size="4">0011 0001</font></td>                           
    </tr>                           
    <tr>                           
      <td width="76" height="23" rowspan="2">                           
        <p align="center"><font color="#000000" size="4">4</font></td>                          
      <td width="240" height="11"><font color="#000000" size="4">1: Rem=Rem-Div</font></td>                           
      <td width="70" height="11">                           
        <p align="center"><font color="#000000" size="4">0010</font></td>                          
      <td width="110" height="11">                          
        <p align="center"><font color="#000000" size="4">0001                            
        0001</font></td>                           
    </tr>                           
    <tr>                           
      <td width="240" height="12"><font color="#000000" size="4">2a:Rem 0 =&gt; sll                            
        R,R0=1</font></td>                           
      <td width="70" height="12">                           
        <p align="center"><font color="#000000" size="4">0010</font></td>                          
      <td width="110" height="12">                          
        <p align="center"><font color="#000000" size="4">0010 0011</font></td>                          
    </tr>                          
    <tr>                          
      <td width="76" height="2"></td>                          
      <td width="240" height="2"><font color="#000000" size="4">Shift left half of Rem                            
        right 1</font></td>                           
      <td width="70" height="2">                           
        <p align="center"><font color="#000000" size="4">0010</font></td>                          
      <td width="110" height="2">                          
        <p align="center"><font color="#000000" size="4">0001 0011</font></td>                           
    </tr>                           
  </table>                           
  </center>                           
</div>                           
<p align="left"><font color="#000000" size="4"> &nbsp;&nbsp;&nbsp; 最后的结果是Remainder=0001,Quotient=0011.</font></p>                           
<p align="left"><font color="#000000" size="4">五:<a name="加减交替法">加减交替法</a></font></p>                          
<p align="left"><font color="#000000" size="4"> &nbsp;&nbsp;&nbsp; 设第i步除法的余数为R<sub>i</sub>,第i-1步余数为R<sub>i-1</sub>,则R<sub>i</sub>=2R<sub>i-1</sub>-Div.如果R<sub>i</sub>>=0,则Q0=1,商上1,左移R<sub>i</sub>,                    
下一步为第i+1次:-Div,R<sub>i+1</sub>=R<sub>i+1</sub>-Div;否则R<sub>i</sub>,不恢复余数,左移一位R<sub>i,</sub>2R<sub>i</sub>=2(2R<sub>i-1</sub>-Div)=4R<sub>i-1</sub>-2Div,Q0=0,商上0,下一步为第i+1次:+Div,R<sub>i+1</sub>=4R<sub>i-1</sub>-2Div+Div=4R<sub>i-1</sub>-Div.具体流程图如下:</font></p>                   
<p align="center"><font color="#000000" size="4"><img border="0" src="images/4-7-pic4.gif" width="239" height="429"></font></p>               
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 例子:7÷2=?</font></p>                 
<div align="center">                
  <center>                
  <table border="1" cellpadding="0" cellspacing="0" width="494" height="151" bordercolordark="#CC9966" bordercolorlight="#FFCC66">                
    <tr>                
      <td width="25" height="10" bgcolor="#CCFF99">                
        <p align="center"><font color="#000000" size="4">Iteration</font></td>                
      <td width="247" height="10" bgcolor="#CCFF99">                
        <p align="center"><font color="#000000" size="4">Step</font></td>                
      <td width="58" height="10" bgcolor="#CCFF99">                
        <p align="center"><font color="#000000" size="4">Divisor</font></td>                
      <td width="154" height="10" bgcolor="#CCFF99">                
        <p align="center"><font color="#000000" size="4">Remainder</font></td>                
    </tr>                
  </center>                
  <tr>                
    <td width="25" height="14" rowspan="2">                
      <p align="center"><font color="#000000" size="4">0</font></td>                
    <center>                
    <td width="247" height="7"><font color="#000000" size="4">Initial</font></td>                
    <td width="58" height="7">                
      <p align="center"><font color="#000000" size="4">0010</font></td>                
    <td width="154" height="7">                
      <p align="center"><font color="#000000" size="4">0000 0111</font></td>                 
    </tr>                 
    <tr>                 
      <td width="247" height="7"><font color="#000000" size="4">shift to the left&nbsp;</font></td>                 
      <td width="58" height="7">                 
        <p align="center"><font color="#000000" size="4">0010</font></td>                
      <td width="154" height="7">                
        <p align="center"><font color="#000000" size="4">0000 1110</font></td>                 
    </tr>                 
    <tr>                 
      <td width="25" height="34" rowspan="2">                 
        <p align="center"><font color="#000000" size="4">1</font></td>                
      <td width="247" height="19"><font color="#000000" size="4">1.Rem=Rem-Div</font></td>                
      <td width="58" height="34" rowspan="2">                
        <p align="center"><font color="#000000" size="4">0010</font></td>                
      <td width="154" height="19">                
        <p align="center"><font color="#000000" size="4">1110                  
        1110</font></td>                 
    </tr>                 
    <tr>                 
      <td width="247" height="15"><font color="#000000" size="4">2.r&lt;0, sll R,R0=0</font></td>                 
      <td width="154" height="15">                 
        <p align="center"><font color="#000000" size="4">1101 1100</font></td>                 
    </tr>                 
    <tr>                 
      <td width="25" height="31" rowspan="2">                 
        <p align="center"><font color="#000000" size="4">2</font></td>                
      <td width="247" height="17"><font color="#000000" size="4">1.Rem=Rem+Div</font></td>                
      <td width="58" height="31" rowspan="2">                
        <p align="center"><font color="#000000" size="4">0010</font></td>                
      <td width="154" height="17">                
        <p align="center"><font color="#000000" size="4">1111                  
        1100</font></td>                 
    </tr>                 
    <tr>                 
      <td width="247" height="14"><font color="#000000" size="4">2.R&lt;0, sll R,R0=0</font></td>                 
      <td width="154" height="14">                 
        <p align="center"><font color="#000000" size="4">1111 1000</font></td>                 
    </tr>                 
    <tr>                 
      <td width="25" height="26" rowspan="2">                 
        <p align="center"><font color="#000000" size="4">3</font></td>                
      <td width="247" height="14"><font color="#000000" size="4">1.Rem=Rem+Div</font></td>                
      <td width="58" height="26" rowspan="2">                
        <p align="center"><font color="#000000" size="4">0010</font></td>                
      <td width="154" height="14">                
        <p align="center"><font color="#000000" size="4">0001                  
        1000</font></td>                 
    </tr>                 
    <tr>                 
      <td width="247" height="12"><font color="#000000" size="4">2.R&gt;0, sll R,R0=1</font></td>                 
      <td width="154" height="12">                 
        <p align="center"><font color="#000000" size="4">0011 0001</font></td>                 
    </tr>                 
    <tr>                 
      <td width="25" height="27" rowspan="2">                 
        <p align="center"><font color="#000000" size="4">4</font></td>                
      <td width="247" height="4"><font color="#000000" size="4">1.Rem=Rem-Div</font></td>                
      <td width="58" height="13" rowspan="2">                
        <p align="center"><font color="#000000" size="4">0010</font></td>                
      <td width="154" height="4">                
        <p align="center"><font color="#000000" size="4">0001                  
        0001</font></td>                 
    </tr>                 
    <tr>                 
      <td width="247" height="9"><font color="#000000" size="4">2.R&gt;0, sll T,R0=1</font></td>                 
      <td width="154" height="9">                 
        <p align="center"><font color="#000000" size="4">0010 0011</font></td>                
    </tr>                
    <tr>                
      <td width="25" height="5"></td>                
      <td width="247" height="5"><font color="#000000" size="4">Remainder与Dividend同号,Remainder的左半部分右移一位</font></td>                
      <td width="58" height="5">                
        <p align="center"><font color="#000000" size="4">0010</font></td>                
      <td width="154" height="5">                
        <p align="center"><font color="#000000" size="4">0001 0011</font></td>                 
    </tr>                 
  </table>                 
  </center>                 
</div>                 
<p align="left"><font color="#000000" size="4"> &nbsp;&nbsp;&nbsp; 最后的结果是Quotient=0011,remainder=0001.</font></p>                 
<p align="left"><font color="#000000" size="4">六:<a name="带符号数除法运算">带符号数除法运算</a></font></p>                
<p align="left"><font color="#000000" size="4">                
&nbsp;&nbsp;&nbsp; 在进行带符号数除法时,最简单的方法是首先存储Divisor和Dividend的符号位,然后在最后给remainder                  
和Quotient加上符号位。但是必须遵守下面的等式:Dividend=Quotient*Divisor+Remainder,同时余数的符号与被除数的符号相同,商的符号等于被除数和除数的符号的异或值。</font></p>                  
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 例:(+7)÷(+2)&nbsp;&nbsp;&nbsp;                  
Quotient=+3,Rem=+1<br>                 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (-7)÷(+2)&nbsp;&nbsp;&nbsp;                  
Quotient=-1,Rem=-1<br>                 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (-7)÷(-2)&nbsp;&nbsp;&nbsp;                  
Quotient=+3,Rem=-1<br>                 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (+7)÷(-2)&nbsp;&nbsp;&nbsp;                  
Quotient=-3,Rem=+1</font></p>                  
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                  
带符号数除法也可以用上面的加减交替法。</font></p>                  
<p align="left"><font color="#000000" size="4">七:<a name="MIPS机除法的实现">MIPS机除法的实现</a></font></p>                 
<p align="left"> <font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 我们可以发现在硬件上除法和乘法很相似,都需要a                  
64-bit register that can shift left和a 32-bit ALU that can adds or                  
subtracts,MIPS中用32-bit Hi和32-bit Lo register来代替64-bit register。因此在除法运算之后,remainder在Hi                  
register之中,quotient在Lo register之中。</font></p>                  
<p align="left"> <font color="#000000"> <font size="4"> &nbsp;&nbsp;&nbsp; MIPS有divide(div)和divided                  
unsigned(divu)两中除法指令。同时MIPS中还有mflo和mfhi指令来存取结果</font>。 <br>                 
</font> </p>                 
<p align="left"> </p>                
<p align="left"> </p>                
<p align="left"> </p>                
<p align="left"> </p>                
<p align="left"> </p>                
<p align="left"> </p>                
<p align="left"> </p>                
<p align="left"> </p>                
<p align="left"> </p>                
          
</body>          
          
</html>          

⌨️ 快捷键说明

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