實驗3分支和循環(huán)程序設(shè)計_第1頁
實驗3分支和循環(huán)程序設(shè)計_第2頁
實驗3分支和循環(huán)程序設(shè)計_第3頁
實驗3分支和循環(huán)程序設(shè)計_第4頁
實驗3分支和循環(huán)程序設(shè)計_第5頁
已閱讀5頁,還剩2頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

實驗3分支和循環(huán)程序設(shè)計實驗?zāi)康模菏炀氄莆辗种Ш脱h(huán)結(jié)構(gòu)的設(shè)計方法,熟悉跳轉(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ù),顯示運行結(jié)果。建議算法如下:顯示“Firstnumber?”;調(diào)用ReadSDecDword輸入雙字有符號數(shù);minimum:=number;maximum:=number;while(顯示“Anothernumber?(YorN)”)loopif(輸入Y)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)換為有符號十進制字符串,負(fù)數(shù)字符串以“-“引導(dǎo)。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,stdcall.datalowerCountword0upperCountword0otherCountword0chabyte?promortbyte"Pleaseinputthelengthofstring:",0promort1byte"Pleaseinputastring:",0dh,0ah,0promort2byte"lowerCount=",0promort3byte"upperCount=",0promort4byte"otherCount=",0textbyte50dup(?).codestart:WriteStringPromortReadSDecDwordecxWriteStringpromort1ReadStringtextmovebx,0again:moval,byteptrtext[ebx]cmpal,'A'jbotcmpal,'Z'jnaupcmpal,'a'jbotcmpal,'z'jnaloot:incotherCountjmpnextup:incupperCountjmpnextlo:inclowerCountnext:incebxloopagainWriteStringpromort2WriteUDecwordlowerCountWriteCrlfWriteStringpromort3WriteUDecwordupperCountWriteCrlfWriteStringpromort4WriteUDecwordotherCountWriteCrlfretendstart2、編寫程序從鍵盤輸入一系列有符號數(shù),找出其中的最大數(shù)和最小數(shù),顯示運行結(jié)果。3.386.modelflat,stdcall.datapromotbyte"Firstnumber?:",0permot1byte"Anothernumber(YorN)?",0permot2byte"Anothernumber:",0permot3byte"mininum=",0permot4byte"maxinum=",0minnumdword?maxnumdword?.codestart:WriteStringPromotReadSDecDwordeaxmovminnum,eaxmovmaxnum,eaxagain:WriteStringpermot1ReadCharalsubal,'N'cmpal,0jzdonexoreax,eaxWriteStringpermot2ReadSDecDwordeaxcmpeax,minnumjlmincmpeax,maxnumjgmaxmin:movminnum,eaxjmpagainmax:movmaxnum,eaxjmpagaindone:WriteStringpermot3WriteSDecDwordminnumWriteCrlfWriteStringpermot4WriteSDecDwordmaxnumWriteCrlfretendstart3、編寫程序?qū)AX的內(nèi)容轉(zhuǎn)換為二進制字符串.386.modelflat,stdcall.stack.datapromortbyte"Pleaseinputnum:",0BinStrbyte32dup(?),0.codestart:WriteStringpromortReadSDecDwordeaxmovecx,32movebx,offsetBinStragain:shleax,1jcnext1movbyteptr[ebx],'0'jmpnextnext1:movbyteptr[ebx],'1'next:incebxdececxjnzagainWriteStringBinStrretendstart8、編寫程序?qū)⑹M制字符串表示的數(shù)據(jù)存入EAX寄存器.386.modelflat,stdcall.datapromortbyte"Plearseinputthestring(endwith@):",0dh,0ah,0promort1byte"ERRORINPUT!",0arraybyte35dup(?).codestart:WriteStringpromortmovecx,0xoreax,eaxReadStringarrayagain:xorebx,ebxmovbl,array[ecx]cmpbl,'@';判斷字符串是否結(jié)束jzendincmpbl,'0';判斷輸入的字符是否為‘0’-‘9’jberror0cmpbl,'9'jbedone1subbl,'A';判斷輸入的字符是否為A-Fcmpbl,0jberror0cmpbl,6jaerror0roleax,4;是A-F,則將字符轉(zhuǎn)化為10-15addebx,10addeax,ebxjmpn2done1:roleax,4andebx,0fhaddeax,ebxn2:incecxjmpagainendin:WriteCrlfWriteUDecDwordeaxjmpdoneerror0:WriteStringpromort1done:retendstartHYPERLINK"/retype/zoom/f11a

溫馨提示

  • 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論