匯編實(shí)驗三報告-分類統(tǒng)計字符個數(shù)COUNT-CHAR_第1頁
匯編實(shí)驗三報告-分類統(tǒng)計字符個數(shù)COUNT-CHAR_第2頁
匯編實(shí)驗三報告-分類統(tǒng)計字符個數(shù)COUNT-CHAR_第3頁
匯編實(shí)驗三報告-分類統(tǒng)計字符個數(shù)COUNT-CHAR_第4頁
匯編實(shí)驗三報告-分類統(tǒng)計字符個數(shù)COUNT-CHAR_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上 計算機(jī) 學(xué)院 計算機(jī)科學(xué)與技術(shù) 專業(yè) 8 班 學(xué)號 姓名 協(xié)作者_(dá) 教師評定_實(shí)驗題目 實(shí)驗用2.3分類統(tǒng)計字符個數(shù)COUNT_CHAR 一、實(shí)驗?zāi)康呐c要求學(xué)習(xí)用匯編語言編寫與設(shè)計分支循環(huán)程序。題目:分類統(tǒng)計字符個數(shù)COUNT_CHAR二、實(shí)驗內(nèi)容程序接收用戶鍵入的一行字符(字符個數(shù)不超過80個,該字符串用回車符結(jié)束),并按字母、數(shù)字及其它字符分類計數(shù),然后將結(jié)果存入以letter、digit和other為名的存儲單元中。三、 程序代碼;*Datasegmentstring1 db 'Input your string:$'string2 db &#

2、39;Digit:$'string3 db 'Letter:$'string4 db 'Other:$'Digit db 0Letter db 0Other db 0data ends;*prognam segment;-main proc far assume cs:prognam,ds:datastart:push ds ;保留現(xiàn)場sub ax,axpush axmov ax,datamov ds,axlea dx,string1 ;輸出string1mov ah,9int 21hmov cx,80L1:mov ah,1 ;輸入字符int 21hcm

3、p al,0dh ;若是回車則結(jié)束jz overcmp al,30h ;若小于30h(0)則others+1jb otherscmp al,39h ;若大于39h(9)則跳轉(zhuǎn)L2繼續(xù)比較ja L2jmp digits ;否則digits+1L2:cmp al,41h ;若小于41h(A)則others+1jb otherscmp al,5ah ;若大于5ah(Z)則跳轉(zhuǎn)L3繼續(xù)比較ja L3jmp letters ;否則letters+1L3:cmp al,61h ;若小于61h(a)則others+1jb otherscmp al,7ah ;若大于7ah(z)則others+1ja othe

4、rsjmp letters ;否則letters+1digits:inc digitjmp over1others:inc otherjmp over1letters: inc letterjmp over1over1: loop L1 over: call endlinelea dx,string2 ;輸出string2mov ah,9int 21hsub ax,axmov al,digitcall displaycall endlinelea dx,string3 ;輸出string3mov ah,9int 21hsub ax,axmov al,lettercall displaycall

5、 endlinelea dx,string4 ;輸出string4mov ah,9int 21hsub ax,axmov al,othercall displayretmain endp;-endline proc near ;輸出回車與換行mov ah,2mov dl,0ahint 21hmov ah,2movdl,0dhint 21hretendline endp;-display proc near ;輸出結(jié)果mov dl,aladd dl,30h ;0的ascii碼是30mov ah,2int 21hretdisplay endp;- prognam ends;*end start四、

6、 運(yùn)行結(jié)果附錄:由于這個實(shí)驗一開始做錯了題目,實(shí)驗課上機(jī)檢查是檢查了該程序 實(shí)驗2.2查找匹配字符串程序代碼:;-newline macro;回車換行的宏定義 movah, 02h movdl, 0dh int21h movah, 02h movdl, 0ah int21hendm;-datasegmentmaxlenkdb8;關(guān)鍵字的最大長度factlenkdb?;關(guān)鍵字的實(shí)際長度keyword db8 dup(?);關(guān)鍵字的存儲maxlensdb32;字符串的最大長度factlensdb?;字符串的實(shí)際長度sentencedb32 dup(?);字符串的存儲info1db'Ente

7、r Keyword:$'info2db'Enter Sentence:$'mess0db'Match at location:$'mess1db'No match.$'mess2db?,?,'H of the sentence.$'data ends;-stacksegmentstackstackends;-code segment;-mainprocfarassume cs:code, ds:data, es:data, ss:stackstart:pushdssubax, axpushaxmovax, datamovd

8、s, axmoves, axmovah, 09h;輸出字符串信息leadx, info1int21hmovah, 0ah;輸入關(guān)鍵字leadx, maxlenkint21hbegin:newlinemovah, 09hleadx, info2int21hmovah, 0ah;輸入字符串leadx, maxlensint21hnewlineleasi, keyword;關(guān)鍵字的首地址賦予sileabx, sentence;字符串的首地址賦予bxleadi, sentence;字符串的首地址賦予dimovdl, 00h;對dl清零cld;方向標(biāo)志位清零,字符串地址遞增again:movcl, fa

9、ctlenkrepzcmpsbjzmatchmov al, factlenssubal, factlenkjsnext1 inc alleasi, keywordincbxmovdi, bxincdxcmpdl, aljlagainnext1:leadx, mess1movah, 09hint21hjmpbeginmatch:leadx, mess0movah, 09hint21hmovax, bxleabx, sentencesubax, bxmov bx, 0001hadd ax, bxandax, 00ffhxchg ax,bxmov ch, 2rotate: mov cl,4h rol bl,cl mov al,bl and al,0fh add al,30h cmp al,3ah jl print a

溫馨提示

  • 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論