實驗3分支和循環(huán)程序設計(精)_第1頁
實驗3分支和循環(huán)程序設計(精)_第2頁
實驗3分支和循環(huán)程序設計(精)_第3頁
實驗3分支和循環(huán)程序設計(精)_第4頁
免費預覽已結束,剩余1頁可下載查看

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

實驗3分支和循環(huán)程序設計實驗目的:熟練掌握分支和循環(huán)結構的設計方法,熟悉跳轉(zhuǎn)和循環(huán)指令的使用方法。實驗要求:按照要求編寫程序,調(diào)試運行。實驗內(nèi)容:1、編寫程序?qū)崿F(xiàn)下面的算法:ifthenlowerCount+1;elseif(ch>?A?)and(ch<?Z?)thenupperCount+1elseotherCount+1;endifendif其中ch調(diào)用ReadChar輸入,lowerCount,upperCount和otherCount的信用WriteUDecByte顯示。2、編寫程序從鍵盤輸入一系列有符號數(shù),找出其中的最大數(shù)和最小數(shù),顯示運行結果。建議算法如下:顯示“Firstnumber?”;調(diào)用ReadSDecDword輸入雙字有符號數(shù);minimum:=number;maximum:=number;while(顯示“Anothernumber?(YorN)”)l(Mp^ifY)then調(diào)用ReadSDecDword輸入雙字有符號數(shù);if(number<minimum)thenminimum:=number;endifif(number>maximum)thenmaximum:=number;endifendwhile3-6題中任選一題:3、編寫程序?qū)AX的內(nèi)容轉(zhuǎn)換為二進制字符串4、編寫程序?qū)AX的內(nèi)容轉(zhuǎn)換為十六進制字符串5、編寫程序?qū)AX的內(nèi)容轉(zhuǎn)換為無符號十進制字符串6、編寫程序?qū)AX的內(nèi)容轉(zhuǎn)換為有符號十進制字符串,負數(shù)字符串以-'引導。7-10題中任選一題:7、編寫程序?qū)⒍M制字符串表示的數(shù)據(jù)存入EAX寄存器8、編寫程序?qū)⑹M制字符串表示的數(shù)據(jù)存入EAX寄存器9、編寫程序?qū)⑹M制字符串表示的無符號數(shù)據(jù)存入EAX寄存器10、編寫程序?qū)⑹M制字符串表示的有符號數(shù)據(jù)存入EAX寄存器實驗步驟及程序:1、編寫程序?qū)崿F(xiàn)下面的算法:.386.modelflat,stdcallinclude\masm32\include\io32.inc.datalowerCountword0upperCountword0otherCountword0chabyte?promortbyte"Pleaseinputthelengthofstring:",0promortlbyte"Pleaseinputastring:",0dh,0ah,0promort2byte"lowerCount=",0promort3byte"upperCount=",0promort4byte"otherCount=",0textbyte50dup(?).codestart:WriteStringPromortReadSDecDwordecxWriteStringpromortlReadStringtextmovebx,0again:moval,byteptrtext[ebx]cmpal,'A'jbotcmpal,'Z'jnaupcmpal,'a'jbotcmpal,'z'jnaloot:incotherCountjmpnextup:incupperCountjmpnextlo:inclowerCountnext:incebxloopagainWriteStringpromort2WriteUDecwordlowerCountWriteCrlfWriteStringpromort3WriteUDecwordupperCountWriteCrlfWriteStringpromort4WriteUDecwordotherCountWriteCrlfretctCobsandPromptMicrosoftCB>WindowslioS-<OCopyri^htMicrosoftCorp199M-2001.P:xMASM32>501Pleaseinputthelengthofstring:6Pleaseinputastring:acdlSolowerCount=4^pperCount=0pthei'Cou.nt=2D:xMASM32>_endstart2、編寫程序從鍵盤輸入一系列有符號數(shù),找出其中的最大數(shù)和最小數(shù),顯示運行結果。3.386.modelflat,stdcallinclude\masm32\include\io32.inc.datapromotbyte"Firstnumber?:",0permotlbyte"Anothernumber(YorN)?",0permot2byte"Anothernumber:",0permot3byte”mininum=",0permot4byte”maxinum=",0minnumdword?maxnumdword?.codestart:WriteStringPromotReadSDecDwordeaxmovminnum,eaxmovmaxnum,eaxagain:WriteStringpermotlReadCharalsubal,'N'cmpal,0jzdonexoreax,eaxWriteStringpermot2ReadSDecDwordeaxcmpeax,minnumjlmincmpeax,maxnumjgmaxmin:movminnum,eaxjmpagainmax:movmaxnum,eaxjmpagaindone:WriteStringpermot3WriteSDecDwordminnumWriteCrlfWriteStringpermot4WriteSDecDwordmaxnumWriteCrlfretendstart3、編寫程序?qū)AX的內(nèi)容轉(zhuǎn)換為二進制字符串.386.modelflat,stdcallinclude\masm32\include\io32.inc.stack.datapromortbyte"Pleaseinputnum:",0BinStrbyte32dup⑺,0.codestart:WriteStringpromortReadSDecDwordeaxmovecx,32movebx,offsetBinStragain:shleax,1jcnext1movbyteptr[ebx],'0'jmpnextnext1:movbyteptr[ebx],'1next:incebxdececxjnzagainWriteStringBinStrretendstartJ'CouandPr0>ptM^roToftWindow^DOS<C=CopyrightMicrosoftCorp1990-2001.D:\MASN32>303Pieaseinputnum:2000300000000000300000000000@10100D:\MASM32>303Pieaseinputnun:10000000000000000000000000001100100D:\MASM32>8、編寫程序?qū)⑹M制字符串表示的數(shù)據(jù)存入EAX寄存器.386.modelflat,stdcallinclude\masm32\include\io32.inc.datapromortbyte"Plearseinputthestring(endwith@):",0dh,0ah,0promort1byte"ERRORINPUT!",0arraybyte35dup(?).codestart:WriteStringpromortmovecx,0xoreax,eaxReadStringarrayagain:xorebx,ebxmovbl,array[ecx]cmpbl,'@';判斷字符串是否結束jzendincmpbl,'0';判斷輸入的字符是否為,0?-,9?jberror0cmpbl,'9'jbedone1subbl,'A';判斷輸入的字符是否為A-Fcmpbl,0jberror0cmpbl,6jaerror0roleax,4;是A-F,則將字符轉(zhuǎn)化為10-15addebx,10addeax,ebxjmpn2donel:roleax,4andebx,0fhaddeax,ebxn2:incecxjmpagainendin:WriteCrlfWriteUDecDwordeaxjmpdoneerror0:WriteStringpromort1done:retendstartc*CouandProB.ptMicrosoft<R>UindousDOS<C>CopyrightMicrosoft

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論