資源描述:
《盧偉《計(jì)算機(jī)原理》實(shí)驗(yàn)三》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、《計(jì)算機(jī)原理實(shí)驗(yàn)報(bào)告》實(shí)驗(yàn)(三)名稱:計(jì)算學(xué)生平均成績實(shí)驗(yàn)一、實(shí)驗(yàn)?zāi)康模?.熟悉匯編語言程序的使用2.掌握十進(jìn)制的運(yùn)算,設(shè)計(jì)顯示程序運(yùn)行結(jié)果的格式3.熟練掌握DOS功能調(diào)用二、實(shí)驗(yàn)要求:編寫程序,求30個(gè)分?jǐn)?shù)的平均值,并以十進(jìn)制值表示將結(jié)果顯示在屏幕上。顯示格式的要求如下:第一行顯示:THETHIRTYSCORESARE:以分號(hào)間隔30個(gè)分?jǐn)?shù);第二行顯示:AVERAGESCORETS=求得的平均分?jǐn)?shù)。三、編程算法與說明:1.將求得的二進(jìn)制表示的平均分?jǐn)?shù),轉(zhuǎn)換成十進(jìn)制表示的算法是:平均分?jǐn)?shù)二進(jìn)制值除以100,商為平均分?jǐn)?shù)百位的值;對(duì)于其余數(shù),將其值除以10
2、,商為平均分?jǐn)?shù)十位的值;第二次除法所得的余數(shù)值為平均分?jǐn)?shù)個(gè)位的值。2.顯示字符串信息用DOS功能調(diào)用INT21H,功能號(hào)為09H。3.顯示平均結(jié)果吋,用DOS功能調(diào)用INT21H,功能號(hào)為02Ho每位數(shù)必須轉(zhuǎn)換為相應(yīng)的ASCII碼。四、實(shí)驗(yàn)屮相關(guān)模塊的連接邏輯圖(實(shí)驗(yàn)電路圖):五、程序流程圖:開始初始化宏定義運(yùn)用9號(hào)功能顯示初始輸入學(xué)號(hào)運(yùn)用9號(hào)功能顯示初始輸入姓名運(yùn)用9號(hào)功能顯示初始輸入分?jǐn)?shù)運(yùn)用9號(hào)功能顯示初始輸入分?jǐn)?shù)數(shù)值(累加子程序)開始(調(diào)用求平均值子程序)開始count=30datasum=(bx)bx=bx+2count=count-ldatas
3、um=datasum+(bx)vdatasum為30個(gè)數(shù)的返回DOSdl=3()ax=datasum(ax)除以(dl)datave=al(al為半均值)(ax)=datave(dl)=10(ax)除以(dl)ah=ah+30hal=(al+30h調(diào)用宏定義顯示數(shù)據(jù)返回DOS六、程序清單:SHOWMACROB;定義宏P(guān)USHAXPUSHDX;保護(hù)數(shù)據(jù)MOVDL,BMOVAH,02HTNTPOPDXPOPAXEXDM21HDATASEGMENTSCOREDB80,80,80,80,80,80,80,80,80,80DB90,90,90,90,90,90,9
4、0,90,90,90DB70,70,70,70,70,70,70,70,70,70XEQU($-SCORE)DATA1DB'Mystudentnumberis:201281178',OAH,ODH,'DATA2DB,Mynameis:GuoLinlin',OAH,ODH,'$'DATA3DB'THETHIRTYSCORESAREDATA480,80,80,80,80,80,80,80,80,80','90,90,90,90,90,90,90,90,90,90'DBDBDATA5DBDATASUMDWDATAVE1DBDATAVE2DB'70,70,70,
5、70,70,70,70,70,70,70','$,'AVERAGESCORESIS=,'$'1DUP(O)1DUP(0)1DUP(0)DATAENDSSSG1SEGMENTSTACKDB100DUP(?)SSG1ENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:SSG1START:MOVAX,DATAMOVDS,AXMOVDX,OFFSETDATA1MOVAH,09HTNT21HMOVDX,OFFSETDATA2MOVAH,09HINT21HMOVDX,OFFSETDATA3MOVAH,09HINT2111MOVDX,OFF
6、SETDATA4MOVAH,09HINT21HCALLACCUMCALLAVERAGEMOVAX,4C00HTNT21HACCUM:MOVSI,OFFSETSCOREMOVCX,XMOVBL,OAHL0P1:MOVAX,0MOVAL,[SI]ADDDATASUM,AXINCSILOOPLOP1RETAVERAGE:SHOWSHOWMOVMOVINTMOVMOVDIVMOVMOVMOVDIVADDADDSHOWSHOWRETODHOAIIDX,OFFSETDATA5AH,09H21HAX,DATASUMBL,30BLDATAVE1,ALAH,OHBL,OA
7、HBLAH,30HAL,30HALAHCODEENDSENDSTART七、實(shí)驗(yàn)結(jié)果:賁C:VIVDOVSsyst6b32cb(1.exeRi^tuden^7Hin!w?^i^201^5^^8Mjinaneis:GuoLinlinTHETHIRTYSCORESARE:80,80,80,80,80,80,80,80,80,8090,90,90,90,90,90,90,90,90,9070,70,70,70,70,70,70.70,70,70AUERAGESCORESIS-80C:MASM>TASM3.ASMTui*boAssemblerUersion
8、3.1Copyright1988,1992BorlandInternati