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

📄 long3.asm

📁 该文件是用汇编语言编写的。文件功能是:从键盘输入一个字符串(长度<80),统计其字母、数字和其他字符个数。
💻 ASM
字号:

;输入一个字符串,长度小于80,统计其字母,数字与其它字符的个数
.386

;* 数据段 
;******************************************************
dseg	segment	use16

;------------------------------------------------------
;MY OWN DATA

be	db	'please input your string: ','$'

data    db	80,?,80 dup(?)
output  db	'The string has',0dh,0ah
num	db	0,20h,20h
	db	'numbers' ,0dh,0ah
char	db	0,20h,20h
	db	'letters',0dh,0ah
other	db	0,20h,20h
	db	'other characters','$'

d	db 	5 dup(?)	
;------------------------------------------------------

dseg	ends





;******************************************************
;* 代码段 
;******************************************************

cseg	segment	use16
;------------------------------------------------------
        
assume	ds:dseg,cs:cseg
start:	mov ax,dseg
	mov ds,ax
	
;------------------------------------------------------
;MY OWN CODE




;提示输入
		lea dx,be
		mov ah,9
		int 21h
;输入字符串
		lea dx, data
		mov ah,0ah
		int 21h
		
		




;判断
	
		mov bx,1
		

check:		inc bx
		cmp data[bx],0dh
		je deal

		cmp  data[bx],30h	
		jb  others
		cmp data[bx],7ah
		ja  others

		cmp  data[bx],39h
		jbe  numbers
		cmp  data[bx],61h
		jae  	chars

		cmp  data[bx],41h
		jb  others
		cmp  data[bx],5ah
		ja  others

		
chars:		inc char		
		jmp check
			
others:		inc other
		jmp check		
				

numbers:	
		inc num		
		jmp check
		

deal:		
		mov ax,0
		mov al,num
		call bintodec
		mov 	ax,	word ptr d
		mov	word ptr num, ax
		
		
		mov al,char
		call bintodec
		mov 	ax,	word ptr d
		mov	word ptr char, ax
	
		mov al,other
		call bintodec
		mov 	ax,	word ptr d
		mov	word ptr other, ax
	
		

exit:		
		
		mov dl,0dh
		mov ah, 2
		int 21h
		mov dl ,0ah
		mov ah,2
		int 21h

		lea dx,output
		mov ah,9
		int 21h

;------------------------------------------------------

              MOV       ah,4CH
              int       21H
bintodec	proc
		push	ax
		push	bx
		push	dx
		push	si
		push	di
		mov 	si,	0
		
		or	ax,	ax
		jz	selfexit
		xor	bl,	bl
		lea	di,	table
selfnext:	cwd
		div	word ptr cs:[di]
		cmp	bl,	0
		jnz	writeinto
		cmp	al,	0
		je	skip
		mov	bl,	1
writeinto:	or	al,	30h
		mov	d[si],	al
		inc	si
skip:		mov	ax,	dx
		add	di,	2
		cmp	cs:word ptr [di], 1
		jne	selfnext
selfexit:	or	al,	30h
		mov	d[si],	al
		inc	si
		
		pop	di
		pop	si
		pop	dx
		pop	bx
		pop	ax
		ret
table		dw	10000,1000,100,10,1
bintodec	endp

    
;------------------------------------------------------
cseg      ends
;******************************************************
             end	start  ;程序结束

⌨️ 快捷键说明

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