从键盘输入一系列字符(以回车符结束),并按字母、数字及其他字符分类计数,最后显示出这三类的计数结果

;从键盘输入一系列字符(以回车符结束),并按字母、数字及其他字符分类计数,最后
;显示出这三类的计数结果
;create date:2007-11-23
;author:野渡无人
;**************************************************************************
data segment
  count_of_letter db 'the number of letter is :','$'
  count_of_number db 'the number of number is :','$'
  count_of_character db 'the number of character is :','$'
data ends
;**************************************************************************
prognam segment
;--------------------------------------------------------------------------
main proc far
   assume cs:prognam,ds:data

start:
   push ds
   sub  ax,ax
   push ax

   mov  ax,data
   mov  ds,ax
  
   mov  bh,0  ;count_of_letter
   mov  bl,0   ;cout_of_number
   mov  cl,0   ;cout_of_charater

next:
   mov  ah,1
   int  21h      

   cmp  al,0dh   
   je   exit

   cmp  al,30h
   jb   cout_of_charater_add

   cmp  al,39h
   jbe  cout_of_number_add

   cmp  al,41h
   jb   cout_of_charater_add

   cmp  al,5ah
   jbe  count_of_letter_add

   cmp  al,61h
   jb   cout_of_charater_add

   cmp  al,7ah
   jbe  count_of_letter_add

cout_of_charater_add:
   inc  cl
   jmp  next

cout_of_number_add:
   inc  bl
   jmp  next

count_of_letter_add:
   inc  bh
   jmp  next

exit:
   call crlf

   lea  dx,count_of_letter
   mov  ah,09
   int  21h

   mov  al,bh
   call bin_dec
  
  ; mov  ah,02h
  ; mov  dl,bh
  ; int  21h

   call crlf

   lea  dx,count_of_number
   mov  ah,09
   int  21h

   mov  al,bl
   call bin_dec

  ; mov  ah,02h
  ; mov  dl,bl
  ; int  21h

   call crlf

   lea  dx,count_of_character
   mov  ah,09
   int  21h

   mov  al,cl
   call bin_dec

   ;mov  ah,02h
   ;mov  dl,cl
  ; int  21h

   call crlf

   ret

main endp
;------------------------------------------------------------------------
crlf  proc  near
   mov  ah,02
   mov  dl,0dh
   int  21h

   mov  ah,02
   mov  dl,0ah
   int  21h

   ret
crlf endp
;-------------------------------------------------------------------------
bin_dec  proc near
    push bx
    push cx
   
    and  ax,00ffh
    mov  cx,0
    mov  bx,0
    mov  dl,10

rotate:   
    div  dl

    mov  bl,ah
    and  ax,00ffh

    push bx
    inc  cx
   
    cmp  ax,10
    jae   rotate

    mov  bx,ax
    push bx
    inc  cx
continue:   
    pop  bx
    add  bl,30h
    mov  dl,bl

    mov  ah,02h
    int  21h
    loop continue

    pop  cx
    pop  bx

    ret
bin_dec endp
;-------------------------------------------------------------------------------
prognam ends
;*******************************************************************************
    end main
 

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值