4-8.htm

来自「浙江大学计算机学院计算机组成教材《计算机组成与设计》(潘学增)的课堂教学课件。」· HTM 代码 · 共 650 行 · 第 1/4 页

HTM
650
字号
&nbsp;&nbsp;&nbsp; step4:进行舍入(Round)操作。根据四舍五入原则,product=1.021<sub>ten</sub>×10<sup>6</sup>。<br>                  
&nbsp;&nbsp;&nbsp; step5:求积的符号位,如果两个乘数的符号位相同,则积为正;如果相反,则积为负。因此结果为<br>                  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; product=+1.021<sub>ten</sub>×10<sup>6</sup>。</font></p>                  
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                   
浮点数乘法算法的流程图如下:</font></p>                  
<p align="center"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img border="0" src="images/4-8-pic8.gif" width="350" height="445"></font></p>               
<p align="left"><font color="#000000" size="4"> </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; MIPS中提供支持单精度和双精度计算的指令,如下:<br>                  
&nbsp;&nbsp;&nbsp; 1:Floating-point multiplication、 single(mul.s) and                   
multiplication、double(mul.d)<br>                  
&nbsp;&nbsp;&nbsp; 2:Floating-point division、single(div.s) and division、double(div.d)<br>                  
&nbsp;&nbsp;&nbsp; 3:Floating-point comparison、single(c.x.s) and comparison、double(c.s.d),where                   
x may be&nbsp;<br>                  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; equal(eq),not equal(neq),less than(lt),less than                   
or equal(le),greater than(gt),or<br>                  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; greater than or equal(ge)<br>                  
&nbsp;&nbsp;&nbsp; 4:Floating-point branch、true(bclt) and branch、false(bclf).Floating-point                   
comparison<br>                  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sets a bit ro true or false,depending on the                   
comparison condition,and a floating-point<br>                  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; branch then decides whether or not to                   
branch,depending on the condition.</font></p>                  
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 在MIPS中,设计者专门为浮点数设置了浮点数寄存器——$f0,$f1,$f2,...,用来做浮点数操作。例如:l.s                   
$f4,x($29)&nbsp;&nbsp;&nbsp;&nbsp; #Load 32-bit F.P. number into F4<br>                  
&nbsp;&nbsp;&nbsp; add.s $f2,$f4,$f6&nbsp; #F2=F4+F6 single precision<br>                  
&nbsp;&nbsp;&nbsp; s.s $f2,z($29)&nbsp;&nbsp;&nbsp;&nbsp; #Store 32-bit F.P.                   
number from F2</font></p>                  
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 其具体的MIPS指令如下表:</font></p>                  
<p align="center"><b><font color="#000000" size="4">MIPS floating-point operands</font></b></p>                  
<div align="center">                  
  <center>                  
  <table border="1" cellpadding="0" cellspacing="0" width="670" height="115" bordercolordark="#CC9966" bordercolorlight="#FFCC66">                  
    <tr>                  
      <td width="70" height="22">                  
        <p align="center"><font color="#000000" size="4">Name</font></td>                
      <td width="197" height="22">                
        <p align="center"><font color="#000000" size="4">Example</font></td>                
      <td width="395" height="22">                
        <p align="center"><font color="#000000" size="4">Comments</font></td>                
    </tr>                
    <tr>                
      <td width="70" height="45">                
        <p align="center"><font color="#000000" size="4">32 floating -point regs&nbsp;</font></td>                  
      <td width="197" height="45"><font color="#000000" size="4">$f0,$f1,$f2,......$f31</font></td>                
      <td width="395" height="45"><font color="#000000" size="4">MIPS floating pointer                  
        registers are used in pairs for double precision numbers, Odd numbered                  
        registers cannot be used for arithmetic or branch, just for data                  
        transfer of the right &quot;half&quot; of the double precision register                  
        pairs.</font></td>                 
    </tr>                 
  </center>                 
  <tr>                 
    <td width="70" height="43">                 
      <p align="center"><font color="#000000" size="4">2<sup>30</sup> memory words</font></td>                 
    <center>                 
    <td width="197" height="43"><font color="#000000" size="4">Memory[0],<br>                
      Memory[4],...<br>                
      Memory[429467292]</font></td>                
    <td width="395" height="43"><font color="#000000" size="4">Accessed only by data                  
      transfer instructions. MIPS uses byte addresses, so sequential words                  
      differ by 4.Memory holds data structures, such as arrays, and spilled                  
      registers, such as those saved on procedure calls.</font></td>                 
    </tr>                 
  </table>                 
  </center>                 
</div>                 
<p align="center"><font color="#000000" size="4"> <b>MIPS floating-point assembly                  
language</b></font></p>                 
<p align="center"><font color="#000000" size="4"> </font></p>
<div align="center">
  <center>
  <table border="1" cellpadding="0" cellspacing="0" width="754" height="284" bordercolordark="#CC9966" bordercolorlight="#FFCC66">
    <tr>
      <td width="80" height="16">
        <p align="center"><font color="#000000" size="4">Category</font></td>
      <td width="145" height="16">
        <p align="center"><font color="#000000" size="4">Instruction</font></td>
      <td width="138" height="16">
        <p align="center"><font color="#000000" size="4">Example</font></td>
      <td width="144" height="16">
        <p align="center"><font color="#000000" size="4">Meaning</font></td>
      <td width="235" height="16">
        <p align="center"><font color="#000000" size="4">Comments</font></td>
    </tr>
    <tr>
      <td width="80" height="107" rowspan="8">
        <p align="center"><font color="#000000" size="4">Arithmetic</font></td>
      <td width="145" height="14"><font color="#000000" size="4">FP add single</font></td> 
      <td width="138" height="14"><font color="#000000" size="4">add.s $f2,$f4,$f6</font></td> 
      <td width="144" height="14"><font color="#000000" size="4">$f2=$f4+$f6</font></td>
      <td width="235" height="14"><font color="#000000" size="4">Floating-Pt.add(single  
        prec.)</font></td> 
    </tr> 
    <tr> 
      <td width="145" height="15"><font color="#000000" size="4">FP subtract single</font></td> 
      <td width="138" height="15"><font color="#000000" size="4">sub.s $f2,$f4,$f6</font></td> 
      <td width="144" height="15"><font color="#000000" size="4">$f2=$f4-$f6</font></td>
      <td width="235" height="15"><font color="#000000" size="4">Floating-Pt.sub(single  
        prec.)</font></td> 
    </tr> 
    <tr> 
      <td width="145" height="9"><font color="#000000" size="4">FP multiply single</font></td> 
      <td width="138" height="9"><font color="#000000" size="4">mul.s $f2,$f4,$f6</font></td> 
      <td width="144" height="9"><font color="#000000" size="4">$f2=$f4×$f6</font></td>
      <td width="235" height="9"><font color="#000000" size="4">Floating-Pt.multiply(s.prec.)</font></td>
    </tr>
    <tr>
      <td width="145" height="11"><font color="#000000" size="4">FP divide single</font></td> 
      <td width="138" height="11"><font color="#000000" size="4">div.s $f2,$f4,$f6</font></td> 
      <td width="144" height="11"><font color="#000000" size="4">$f2=$f4÷$f6</font></td>
      <td width="235" height="11"><font color="#000000" size="4">Floating-Pt.divide(s.prec.)</font></td>
    </tr>
    <tr>
      <td width="145" height="13"><font color="#000000" size="4">FP add double</font></td> 
      <td width="138" height="13"><font color="#000000" size="4">add.d $f2,$f4,$f6</font></td> 
      <td width="144" height="13"><font color="#000000" size="4">$f2=$f4+$f6</font></td>
      <td width="235" height="13"><font color="#000000" size="4">Floating-Pt.add(double  
        prec.)</font></td> 
    </tr> 
    <tr> 
      <td width="145" height="18"><font color="#000000" size="4">FP subtr. double</font></td> 
      <td width="138" height="18"><font color="#000000" size="4">sub.d $f2,$f4,$f6</font></td> 
      <td width="144" height="18"><font color="#000000" size="4">$f2=$f4-$f6</font></td>
      <td width="235" height="18"><font color="#000000" size="4">Floating-Pt.sub(single  
        prec.)</font></td> 
    </tr> 
    <tr> 
      <td width="145" height="11"><font color="#000000" size="4">FP mult. double</font></td> 
      <td width="138" height="11"><font color="#000000" size="4">mul.d $f2,$f4,$f6</font></td> 
      <td width="144" height="11"><font color="#000000" size="4">$f2=$f4×$f6</font></td>
      <td width="235" height="11"><font color="#000000" size="4">Floating-Pt.multiply(d.prec.)</font></td>
    </tr>
    <tr>
      <td width="145" height="16"><font color="#000000" size="4">FP divide double</font></td> 
      <td width="138" height="16"><font color="#000000" size="4">div.d $f2,$f4,$f6</font></td> 
      <td width="144" height="16"><font color="#000000" size="4">$f2=$f4÷$f6</font></td>
      <td width="235" height="16"><font color="#000000" size="4">Floating-Pt.divide(d.prec)</font></td>
    </tr>
    <tr>
      <td width="80" height="27" rowspan="2"><font color="#000000" size="4">&nbsp; Data                  
        transter</font></td>                 
      <td width="145" height="13"><font color="#000000" size="4">load word copr.1</font></td>                 
      <td width="138" height="13"><font color="#000000" size="4">lwc1 $f1,100($2)</font></td>                 
      <td width="144" height="13"><font color="#000000" size="4">$f1=Memory[$2+100]</font></td>                
      <td width="235" height="13"><font color="#000000" size="4">32-bit data to FP                  
        register</font></td>                 
    </tr>                 
    <tr>                 
      <td width="145" height="14"><font color="#000000" size="4">store word copr.1</font></td>                 
      <td width="138" height="14"><font color="#000000" size="4">swc1 $f1,100($2)</font></td>                 
      <td width="144" height="14"><font color="#000000" size="4">Memory[$2+100]=$f1</font></td>                
      <td width="235" height="14"><font color="#000000" size="4">32-bit data to memory</font></td>                 
    </tr>                 
    <tr>                 
      <td width="80" height="92" rowspan="4"><font color="#000000" size="4">Conde-<br>                
        tional<br>                
        branch</font></td>                
      <td width="145" height="13"><font color="#000000" size="4">branch on FP true</font></td>                 
      <td width="138" height="13"><font color="#000000" size="4">bc1t 100</font></td>                 
      <td width="144" height="13"><font color="#000000" size="4">if(cond==1) go to                  
        PC+4+100</font></td>                 
      <td width="235" height="13"><font color="#000000" size="4">PC relative branch if FP                  

⌨️ 快捷键说明

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