⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2.3分类统计字符个数.asm

📁 清华汇编实验源代码 字符串匹配 查询电话号码 窗口屏幕程序
💻 ASM
字号:
;分类统计字符个数
DATAS SEGMENT
    letter db ?
    digit db ?
    other db ?  
    mess1 db 'Please input the sentence which you want to count:','$'
    letter0 db 'The sum of letters is ','$'
    digit0 db 'The sum of digits is ','$'
    other0 db 'The sum of other letters is ','$'
    h db 'H','$'
DATAS ENDS
;***********************************************
CODES SEGMENT
;----------------------------------------------
	main proc far
    ASSUME CS:CODES,DS:DATAS
START:
	push ds
	xor ax,ax
	push ax
	;
    MOV AX,DATAS
    MOV DS,AX
    ;
    mov cl,0;letter
    mov dl,0;digit
    mov dh,0;other
    ;
    lea dx,mess1
    mov ah,09h
    int 21h
get_key:
 	mov ah,1
 	int 21h
 	cmp al,0dh
 	je disp
 	jne count
 	;
disp: 
    call crlf
    push dx
    lea dx,letter0
    mov ah,09h
    int 21h
    pop dx
    ;	
 	mov letter,cl
 	mov bh,0
 	mov bl,cl
 	call binihex
 	;
 	push dx
 	lea dx,h
 	mov ah,09h
 	int 21h
 	pop dx
 	;
 	call crlf
 	push dx
 	lea dx,digit0
    mov ah,09h
    int 21h
    pop dx
 	;
 	sub dl,3
 	mov digit,dl
 	mov bh,0
 	mov bl,dl
 	call binihex
 	;
 	push dx
 	lea dx,h
 	mov ah,09h
 	int 21h
 	pop dx
 	;
 	call crlf
 	push dx
 	lea dx,other0
    mov ah,09h
    int 21h
    pop dx
 	;
 	mov other,dh
 	mov bh,0
 	mov bl,dh
 	call binihex
 	;
 	push dx
 	lea dx,h
 	mov ah,09h
 	int 21h
 	pop dx
 	;
 	jmp exit
 	;
count:
 	cmp al,'z'
 	jbe a
 	jmp short others
a:
	cmp al,'a'
	jb b
	jmp short letters
	;
b:
	cmp al,'9'
	jbe d
	jmp short others
	;
d:
 	cmp al,'0'
 	jb others
 	jmp short digits
exit:
	ret
letters:
	inc cl
	jmp get_key
digits:
 	inc dl
 	jmp get_key
others:
	inc dh
	jmp get_key
	;
	main endp
;-------------------------------------------------
	binihex proc near
	;
	push cx
	push dx
	;
	mov ch,4
rotate:
 	mov cl,4
 	rol bx,cl
 	mov al,bl
 	and al,0fh
 	add al,30h
 	cmp al,3ah
 	jl printit
 	add al,7h
printit:
	mov dl,al
	mov ah,2
	int 21h
	dec ch
	jnz rotate
	;
	pop dx
	pop cx
	;
	ret
	;
	binihex endp
;------------------------------------------------
	crlf proc near
    push dx
    ;
    mov ah,02h
    mov dl,0dh
    int 21h
    mov ah,02h
    mov dl,0ah
    int 21h
    ;
    pop dx
    ret
    crlf endp
;---------------------------------------------------
CODES ENDS
    END START

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -