从键盘输入一系列字符(以回车符结束),并按字母、数字及其他字符分类计数,最后显示出这三类的计数结果
2007-11-24 10:47
2711 查看
;从键盘输入一系列字符(以回车符结束),并按字母、数字及其他字符分类计数,最后
;显示出这三类的计数结果
;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
;显示出这三类的计数结果
;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
相关文章推荐
- 汇编语言: 从键盘上输入一串字符(用回车键结束,使用10号功能调用。),将其中的小写英文 字母变换为大写英文字母,其他字符保持不变。然后将变换后的字符串显示出来。
- 3. 定义10个字节的键盘缓冲区,然后键盘输入字符填满该缓冲区,做如下工作: (1)分别将输入键盘缓冲区的字符按数字,小写字母,大写字母,其他字符进行计数; 分别将这些计数值显示出来。 (2)分别将这
- 编写一个程序,输入一行字符,以回车结束,分别统计出其中的英文字母、空格、数字和其他字符的数
- 习题 7.9 编写一个函数,由实参传来一个字符串,统计此字符串中字母、数字、空格、和其他字符的个数,在主函数中输入字符串以及输出上述的结果。
- 键盘输入若干字符,计算其中的字母个数,空格个数,数字个数,及其他字符的个数。
- 从键盘输入一批字符(以@结束),按要求加密并输出。加密规则为:1.所有字母均转化为小写;2.若是a到y,则转化为下一个字母;3.若是z,则转化为a;4.其他字符保持不变
- 汇编语言: 从键盘上输入一串字符(用回车键结束,使用 10 号功能调用。)放在 STRING 中,试 编制一个程序测试字符串中是否存在数字。如有,则把 CL 的第 5 位置 1,否则将该位置置 0。
- 作业3-3 输入 15 个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数
- 作业三-3输入 15 个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数
- 输入一个字符,字母输出‘c’,数字输出本身,回车结束(8086汇编)
- 作业3-3 输入 15 个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数
- C语言统计一串字符中空格键、Tab键、回车键、字母、数字及其他字符的个数(Ctrl+Z终止输入)
- 编写程序从键盘上输入一些字母和数字,统计显示其中的数字字符的个数和非数字字符个数。
- 编写一个函数,由实参传来一个字符串,统计此字符串中字母,数字,空格,和其他字符的个数,在主函数中输入字符串以及输出上述统计的结果。再考虑将算的的结果放在一个数组中
- 编写一个函数,从实参传来一个字符串,统计其中字母,数字,空格和其他字符的个数,在主函数中输入字符串以及输出上述的结果
- 作业3(3)输入 15 个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数
- 从键盘输入一个字符,判断其是字母字符,还是数字字符,还是其他字符
- 汇编语言: 从键盘上输入一系列以$为结束符的字符串,然后对其中的非数字字符计数,
- (c++)输入一行字符,分别统计出其中英文字母、数字、空格和其他字符的个数。
- 输入一行字符,分别统计其中英文字母、空格、数字和其他字符的个数