




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、計(jì)算機(jī)組成原理實(shí)驗(yàn)報告年級、專業(yè)、班級姓名實(shí)驗(yàn)題目浮點(diǎn)數(shù)的表示和計(jì)算實(shí)驗(yàn)時間實(shí)驗(yàn)地點(diǎn)A 主 404實(shí)驗(yàn)成績實(shí)驗(yàn)性質(zhì)驗(yàn)證性設(shè)計(jì)性口綜合性教師評價:口算法/實(shí)驗(yàn)過程正確;口源程序/實(shí)驗(yàn)內(nèi)容提交程序結(jié)構(gòu)/實(shí)驗(yàn)步驟合理;口實(shí)驗(yàn)結(jié)果正確;口語法、語義正確;口報告規(guī)范;其他:評價教師簽名:一、實(shí)驗(yàn)?zāi)康?1) 深入掌握二進(jìn)制數(shù)的表示方法以及不向進(jìn)制數(shù)的轉(zhuǎn)換;(2) 掌握二進(jìn)制不向編碼的表示方法;(3) 掌握IEEE 754中單精度浮點(diǎn)數(shù)的表示和計(jì)算。二、實(shí)驗(yàn)項(xiàng)目內(nèi)容假設(shè)沒有浮點(diǎn)表示和計(jì)算的硬件,用軟件方法采用仿真方式實(shí)現(xiàn)IEEE 754單精度浮點(diǎn)數(shù)的表示及運(yùn)算功能,具體要求如下:(1)程序需要提供人機(jī)交互方
2、式( GUI或者字符界面)供用戶選擇相應(yīng)的功能;(2)可接受十進(jìn)制實(shí)數(shù)形式的輸入,在內(nèi)存中以IEEE 754單精度方式表示,支持以二進(jìn)制和十六進(jìn)制的方式顯示輸出;(3)可實(shí)現(xiàn)浮點(diǎn)數(shù)的加減乘除運(yùn)算;(4)可以使用80X86或MIPS或ARM匯編指令,但是不能使用浮點(diǎn)指令,只能利 用整數(shù)運(yùn)算指令來編寫軟件完成。三、實(shí)驗(yàn)過程或算法(源程序)1.本次項(xiàng)目我們采用單精度浮點(diǎn)數(shù)格式讀入兩個浮點(diǎn)數(shù),并讀入一個操作符,然 后根據(jù)操作符類型選擇運(yùn)算類型,加法指令如下:sum:subu $sp, $sp, 32sw $ra, 20($sp)sw $fp, 16($sp)addiu $fp, $sp, 28sw $
3、a0,0($fp)#calculate the first numberandi$s2, $s0,0x80000000# s2 is the signsrl $s2,$s2, 31andi$s3, $s0,0x7f800000# s3 is the exponentsrl $s3,$s3, 23andi$s4, $s0,0x007fffff# s4 is the fractionaddi $s4, $s4, 0x00800000 #calculate the second numberandi$s5, $s1,0x80000000# s5 is the signsrl $s5,$s5, 31a
4、ndi$s6, $s1,0x7f800000# s6 is the exponentsrl $s6,$s6, 23andi$s7, $s1,0x007fffff# s7 is the fractionaddi $s7, $s7, 0x00800000sub $t0,$s3, $s6blt $t0,0, sumL1# addsubbgt $t0,0, sumL2# subaddbeq $t0,0, sumL32.減法指令如下:mysub: subu $sp, $sp, 32 sw $ra, 20($sp)sw $fp,16($sp)addiu$fp, $sp, 28sw $a0,0($fp)#c
5、alculate the first numberandi$s2, $s0,0x80000000# s2 is the signsrl $s2,$s2, 31andi$s3, $s0,0x7f800000# s3 is the exponentsrl $s3,$s3, 23andi$s4, $s0,0x007fffff# s4 is the fractionaddi $s4, $s4, 0x00800000 #calculate the second numberxori$s5, $s1,0x80000000# s5 is the signsrl $s5,$s5, 31andi$s6, $s1
6、,0x7f800000# s6 is the exponentsrl $s6,$s6, 23andi$s7, $s1,0x007fffff# s7 is the fractionaddi $s7, $s7, 0x00800000sub $t0, $s3, $s6blt $t0,0, subL1bgt $t0, 0, subL2beq $t0, 0, subL3# +,-# -,+# +,+ or -,-3.乘法指令如下:mutilStart: srl$t2, $s0, 31srl $t3, $s1, 31sll $t4, $s0, 1srl$t4, $t4, 24# expsll$t5, $s
7、1, 1srl$t5, $t5, 24# exp # 01fracsll $t6,$s0, 9srl$t6, $t6, 9ori$t6, $t6, 0x00800000sll$t6, $t6, 8addi$t4, $t4,1# 01fracsll$t7, $s1, 9srl$t7, $t7, 9ori$t7, $t7, 0x00800000sll$t7, $t7, 8addi$t5, $t5,1sub$t4, $t4, 127add$t4, $t4, $t5# final expsub$t5, $t5, $t5mutilCompareSign:add$t2, $t2, $t3sll$t2, $
8、t2, 31# final signmultu $t6, $t7mfhi$t5#regularandi$t8, $t5,0x80000000beq$t8, 0x80000000, mutilnextsll$t5, $t5, 1sub$t4, $t4, 1mutilnext:sll $t5, $t5,1# IEEE754sub$t4, $t4, 1srl$t5, $t5, 9# final fractionmutilFinal: sll$t4, $t4,24srl$t4, $t4, 1addu$t2, $t2, $t4addu$t2, $t2, $t5# resultadd $s2,$t2, $
9、zero# save resultli $v0,4la $a0,msg3syscallli $v0,2mtc1$t2, $f12syscallla$a0, msg0# new lineli$v0, 4syscallIw$ra,20($sp)Iw $fp,16($sp)addiu$sp, $sp, 32jr$ra4.除法指令如下divideStart:srl$t2, $s0, 31srl$t3,$s1, 31sll$t4,$s0, 1srl$t4,$t4, 24# expsll$t5,$s1, 1srl$t5,$t5, 24# expsll$t6,$s0, 9srl$t6,$t6, 9ori$t
10、6,$t6, 0x00800000sll$t7,$s1, 9srl$t7,$t7, 9ori$t7,$t7, 0x00800000sub$t4,$t4, $t5# final expaddi$t4, $t4,127sub$t5,$t5, $t5divideCompareSign:add$t2, $t2, $t3sll$t2,$t2, 31# final signsub$t8,$t8, $t8# use to record dividsub$t3,$t3, $t3# use to record remaindersub$t5,$t5, $t5# use as counterdividecompa
11、rebge $t5,24, dividebreakout #compare the two numberblt$t6,$t7, dividelowerdividegreater:sub $t6,$t6, $t7#divide is lowersll$t6,$t6, 1sll$t8,$t8, 1addi$t8, $t8,1addi$t5, $t5,1jdividecomparedividelower:sll$t6, $t6,1sll$t8,$t8, 1addi$t5, $t5,1jdividecomparedividebreakout: blt$t8,0x00800000, dividedoSl
12、lbge$t8,0x01000000, dividedoSrlj divideresultdividedoSll: sll$t8, $t8, 1$t4, $t4, 10x00800000, dividedoSll leresultsubiblt $t8,j dividdividedoSrl: srl$t8, $t8, 1addi$t4, $t4, 1bge $t8,0x01000000, dividedoSrlj divideresultdivideresult:bgt $t4, 255, divideoverFlowsll $t8,$t8, 9srl $t8,$t8, 9sll $t4,$t
13、4, 24srl $t4,$t4, 1add $t2,$t2, $t4add $t2,$t2, $t8add $s2,$t2, $zero# save resultli $v0,4la $a0,msg3#output messagesyscall li $v0,2mtc1$t2, $f12syscallj diviedend5 .十進(jìn)制轉(zhuǎn)換為二進(jìn)制指令如下:dex2:subu $sp, $sp, 32sw $ra,20($sp)sw $fp,16($sp)addiu$fp, $sp, 28sw $a0,0($fp)add $a0,$s2, $zeroadd $t9,$zero, $a0sub
14、$t6,$t6, $t6# set $t6=0sub $t7,$t7, $t7# set $t7=0addi$t5, $zero, 32# set $t5=32 as a counteraddi$t8, $zero, 0x80000000# set $t8=1000 00000000 0000 00000000 0000 0000beginLoop:addi$t5,$t5, -1# counter -and$t7, $t8,$t9srl$t8,$t8, 1srlv $t7,$t7, $t5add $a0, $t7,$zero#output one bitli $v0,1syscallbeq $
15、t5, $t6, Exist #if equals jump exist j beginLoop6 .十進(jìn)制轉(zhuǎn)換為十六進(jìn)制指令如下:dex16: subu $sp, $sp, 32 sw $ra, 20($sp) sw $fp, 16($sp) addiu $fp, $sp, 28 sw $a0, 0($fp) sub $t0, $t0, $t0# use as countersrloop: bge $t0, 8, dex16end #16addi $t0,$t0, 1srl $t1,$s2, 28sll $s2,$s2, 4bgt $t1,9, outcharli $v0,1add $a0,
16、$t1, $zerosyscallj srloopoutchar: addi$t1, $t1, 55 # change to charli $v0,11add $a0, $t1, $zerosyscallj srloopdex16end:la $a0, nsg0 # new line li $v0, 4 syscall lw $ra, 20($sp) lw $fp, 16($sp) addiu $sp, $sp, 32 jr $ra四、實(shí)驗(yàn)結(jié)果及分析和(或)源程序調(diào)試過程1.實(shí)驗(yàn)結(jié)果:本次實(shí)驗(yàn)我們以十進(jìn)制實(shí)數(shù)形式的輸入兩個浮點(diǎn)數(shù),在內(nèi)存中以 IEEE 754單精 度方式表示,執(zhí)行運(yùn)算操作后,以
17、十進(jìn)制形式把結(jié)果輸出,并且可以以二進(jìn)制和十六 進(jìn)制的方式顯示輸出,下圖是執(zhí)行加法運(yùn)算,并輸出二進(jìn)制形式:Hnpuit a OP: 1, add 2.3. miol 4. Aiv Cl. qui t1I tie F Lirs t Float mg value i s " 1.25Ihe Second floating value i s : 1. 1 充Ih«! rgASMit i s. 2.375Input b. the Tarm at t o cratjuut : 5_ biaary B Hex :5Diooooaocooi woooooooooaocoooGooInpu
18、t b. OP: 1, add2. sul3. mial4.diw0.qm t下圖是執(zhí)行乘法操作,并輸出十六進(jìn)制形式:Hnpiit b. OP: L add2. sill3. nnol4.AiwCl.quitRTh 名 TIjts t Fleat liigValliejl 后 5The Second Fluatingr虹u®is_0. 5The reasul t i s. 1.25Input a. the f ormat to outjut: 5. binary 6 Hex :63FMMOOOInput 且 0F. L. add 2 *ufb 3. niul 4. div 0, qu
19、it減法運(yùn)算如下圖:Titput a OP :1 . add 2. sub 3. mJ. 4. div G. -jui t2IIle First FT口ating value i e 710Iksv&lutIke reasultGInput t tht F«r*nat tc output ;5. binwry 6 K«x ;6CL200000Ikput t OP- 1 add 2. sub 3 mli1 4 div Q, git除法運(yùn)算如下圖:Iiupiit a OP :1. add 2. wub 3, mul 4- da v 0. qni tAIlie First
20、 Floating value i s 112. 24The Second floating value i s :2Th總 reasult is! 6.12Inpiit b th* Format tg tput ;5> binary & Xu苦 二 5plOOOOOOl LOOOOl 111010111DOOO1010Input & OP:1 .3己d 2. sub 3. mul 4. dir G. q-uit當(dāng)輸入錯誤,如除數(shù)為 0時,會顯示錯誤信息并退出,如下圖:Input a OP 11L add 2. sub 3. mil 4. div 0. qui t4I h
21、e F 11rmit FLd all ng value is: 1Iht Second FLoafinc valu# is;0Error1 - prograim is finishe! running: 一2 .實(shí)驗(yàn)分析:本次實(shí)驗(yàn)我們使用 MIPS匯編指令,利用整數(shù)運(yùn)算指令來編寫了一個浮點(diǎn)數(shù)運(yùn)算 程序,通過在 MARS 4.4軟件上進(jìn)行調(diào)試運(yùn)行,得到了正確結(jié)果,本次實(shí)驗(yàn)實(shí)現(xiàn)了以 下功能:(1)程序提供了人機(jī)交互方式(字符界面)供用戶選擇相應(yīng)的功能;(2)接受十進(jìn)制實(shí)數(shù)形式的輸入,在內(nèi)存中以IEEE 754單精度方式表示,支持以二進(jìn)制和十六進(jìn)制的方式顯示輸出;(3)實(shí)現(xiàn)了浮點(diǎn)數(shù)的加減乘除運(yùn)算;(
22、4)沒有使用浮點(diǎn)指令,只利用了整數(shù)運(yùn)算指令來完成軟件的編寫。3 . 成員分工:力口、減、乘、除四個運(yùn)算指令程序的編寫。:十進(jìn)制轉(zhuǎn)二進(jìn)制,十進(jìn)制轉(zhuǎn)十六進(jìn)制代碼的編寫。實(shí)驗(yàn)報告由兩人共同完成。備注:1、教師在布置需撰寫實(shí)驗(yàn)報告的實(shí)驗(yàn)前,應(yīng)先將報告書上的“實(shí)驗(yàn)題 目”、“實(shí)驗(yàn)性質(zhì)”、“實(shí)驗(yàn)?zāi)康摹?、“?shí)驗(yàn)項(xiàng)目內(nèi)容”等項(xiàng)目填寫完成, 然后再下發(fā)給學(xué)生。2、教師在布置需撰寫報告的實(shí)驗(yàn)項(xiàng)目時,應(yīng)告知學(xué)生提交實(shí)驗(yàn)報告的最后期限。3、學(xué)生應(yīng)按照要求正確地撰寫實(shí)驗(yàn)報告:1) 在實(shí)驗(yàn)報告上正確地填寫“實(shí)驗(yàn)時間”、 “實(shí)驗(yàn)地點(diǎn)”等欄目。2) 將實(shí)驗(yàn)所涉及的源程序文件內(nèi)容(實(shí)驗(yàn)操作步驟或者算法)填寫在“ 實(shí)驗(yàn)過程或算法(源程序) ”欄目中。3) 將實(shí)驗(yàn)所涉及源程序調(diào)試過程(輸入數(shù)據(jù)和輸出結(jié)果)或者實(shí)驗(yàn)的分析內(nèi)容填寫在“實(shí)驗(yàn)結(jié)果及分析和(或)源程序調(diào)試過程 ”欄目中。4) 在實(shí)驗(yàn)報告頁腳的“報告創(chuàng)建時間: ”處插入完成實(shí)驗(yàn)報告時的日期和時間。5) 學(xué)生將每個實(shí)驗(yàn)完成后,按實(shí)驗(yàn)要求的文件名通過網(wǎng)絡(luò)提交(上載) 到指定的服務(wù)器所規(guī)定的共享文件夾中。每個實(shí)驗(yàn)一個電子文檔,如果實(shí)驗(yàn)中有多
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 暖氣安裝合同協(xié)議書
- 山東省臨沂市郯城縣2024-2025學(xué)年八年級上學(xué)期期末生物學(xué)試題(含答案)
- 辦公樓簡易裝修合同
- 證券投資咨詢服務(wù)協(xié)議書
- 深圳房屋出租合同
- 智能家居設(shè)備購買安裝合同
- 全球金融中心交易量對比表
- 季度工作計(jì)劃與執(zhí)行方案
- 健康管理與咨詢協(xié)議書
- 會議室內(nèi)設(shè)備使用情況統(tǒng)計(jì)表
- 法考-01刑法-案例指導(dǎo)用書【】
- 《考古學(xué)》第二章-田野考古課件
- 膀胱鏡檢查記錄
- 檔案銷毀清冊
- 固體物理21固體的結(jié)合課件
- 水平定向鉆施工規(guī)范方案
- 細(xì)支氣管肺泡癌的影像診斷(61頁)
- 2022年東北大學(xué)現(xiàn)代控制理論試題及答案
- X射線的物理學(xué)基礎(chǔ)-
- 教學(xué)樓畢業(yè)設(shè)計(jì)資料
- 國網(wǎng)直流電源系統(tǒng)技術(shù)監(jiān)督規(guī)定
評論
0/150
提交評論