汇编实验 分类统计字符个数(debug中查看统计结果)
生活随笔
收集整理的這篇文章主要介紹了
汇编实验 分类统计字符个数(debug中查看统计结果)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2.3 分類統計字符個數
1.題目:分類統計字符個數
2.實驗要求:
程序接收用戶鍵入的一行字符(字符個數不超過80個,該字符串用回車符結束),并按字母,數字及其他字符分類計數,然后將結果存入以letter,digit和other為名的存儲單元中。debug中查看結果。
; test5:classify and count the number of characters ;*************************************************************** dseg segment para 'data' letter dw 0digit dw 0other dw 0mess1 db 'Please input a string: ',13,10,'$' mess2 db 'Statistic completed',13,10,'$' strin label bytemax db 80act db ?str db 80 dup(?) ; dseg ends ;*************************************************************** cseg segment para 'code' ;----------------------------------------------------------------- main proc farassume cs:cseg,ds:dseg;set up stack for returnpush dssub ax,axpush ax ;mov ax,DSEGmov ds,ax start:mov letter,0mov digit,0mov other,0; ; ---------Input string:---------lea dx,mess1mov ah,09int 21hlea dx,strinmov ah,0ahint 21hcmp act,0je exitmov dl,13 ;crlfmov ah,02int 21hmov dl,10mov ah,02int 21h;;----------classify--------------mov al,actcbwmov cx,axmov bx,0;compare_and_classify:mov ah,str[bx]cmp ah,30hjl is_othercmp ah,39hjle is_a_digitcmp ah,41hjl is_othercmp ah,5ahjle is_a_lettercmp ah,61hjl is_othercmp ah,7ahjle is_a_letterjmp is_otheris_a_digit:inc digitjmp short change_addr is_a_letter:inc letterjmp short change_addr is_other:inc otherjmp short change_addrchange_addr:inc bxloop compare_and_classifylea dx,mess2mov ah,09int 21hret exit:ret main endp ;----------------------------------------------------------- cseg ends ;***********************************************************end main運行,先u,查看完整的匯編指令,然后先設置斷點到達38處,使用g38,輸入字符串后,然后再用g87,跳到循環統計完成之后的指令處,使用d0命令,發現,DS中最開始的三個字的內容已經得到了統計結果。
總結
以上是生活随笔為你收集整理的汇编实验 分类统计字符个数(debug中查看统计结果)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 汇编中常用的DOS系统调用功能号
- 下一篇: 汇编实验注意点(待补充和更新)