4、通过文件输入一段英文论文,请编写查询、替换和统计等功能。

题目描述

4、通过文件输入一段英文论文,请编写查询、替换和统计等功能。

参考程序

assume cs:code,ds:data
data segment
Input db 0A0h,0A0h dup(?)
Num db 52 dup(0)
InPaper db 'Input paper:$'
Sta db 'Statistics letter number:$'
exc db 'Letter:$'
ex db 'Changed paper:$'
sh db 'Shearch letter:$'
she db 'Result:$'
Number db ?
Do db 'Choose Operation:(1:Statistics 2:Shearch 3:Finish):$'
clf db 0ah,0dh,'$'
data ends
code segment
start:mov ax,data
	mov ds,ax
	lea dx,InPaper
	mov ah,09h
	int 21h
	lea dx,Input
	mov ah,0Ah
	int 21h
	lea si,Input
	mov cl,[si+1]
	mov ch,0
	mov bx,offset Number
	mov [bx],cl
	lea dx,clf
	mov ah,09h
	int 21h
s3:lea dx,clf
	mov ah,09h
	int 21h
	lea dx,Do
	mov ah,09h
	int 21h
	mov ah,01h
	int 21h
	cmp al,'1'
	je do1
	cmp al,'2'
	je do2
	cmp al,'3'
	je do3
do1:lea dx,clf
	mov ah,09h
	int 21h
	call Statistics_Function
	jmp s3
	do2:lea dx,clf
	mov ah,09h
	int 21h
	call Shearch_Function
	jmp s3
do3:mov ax,4c00h
	int 21h
Statistics_Function:
	pushf
	push ax
	push dx
	mov bx,offset Number
	mov cl,[bx]
	mov ch,0
	mov bx,2
s:cmp byte ptr [bx],'A'
	jb fin
	cmp byte ptr [bx],'z'
	ja fin
	cmp byte ptr [bx],'Z'
	jna next1
	cmp byte ptr [bx],'a'
	jnb next2
	jmp fin
next1:mov ax,0
	mov al,[bx]
	push bx
	mov bx,offset Num
	sub al,'A'
	mov si,ax
	add byte ptr [bx+si],1
	pop bx
	jmp fin
next2:mov ax,0
	mov al,[bx]
	push bx
	mov bx,offset Num
	sub al,'a'
	add al,26
	mov si,ax
	add byte ptr [bx+si],1
	pop bx
fin:inc bx
	loop s
	lea dx,Sta
	mov ah,09h
	int 21h
	mov cx,52
	mov si,0
	mov bx,offset Num
s1:cmp si,26
	ja next3
	jna next4
next3:mov ax,si
	sub al,26
	add al,'a'
	mov dl,al
	mov ah,02h
	int 21h
	mov dl,':'
	mov ah,02h
	int 21h
	mov dl,[bx+si]
	call disp_d_1
	mov dl,' '
	mov ah,02h
	int 21h
	jmp fin2
next4:mov ax,si
	add al,'A'
	mov dl,al
	mov ah,02h
	int 21h
	mov dl,':'
	mov ah,02h
	int 21h
	mov dl,[bx+si]
	call disp_d_1
	mov dl,' '
	mov ah,02h
	int 21h
fin2:inc si
	loop s1
	lea dx,clf
	mov ah,09h
	int 21h
	pop dx
	pop ax
	popf
ret
Shearch_Function:
	pushf
	push ax
	push dx
	mov bx,offset Num
	lea dx,sh
	mov ah,09h
	int 21h
	mov ah,01h
	int 21h
	push ax
	lea dx,clf
	mov ah,09h
	int 21h
	lea dx,she
	mov ah,09h
	int 21h
	mov dl,al
	mov ah,02h
	int 21h
	mov dl,':'
	mov ah,02h
	int 21h
	pop ax
	cmp al,'a'
	jnb next5
	jb next6
next5:sub al,'a'
	add al,26
	mov ah,0
	mov si,ax
	mov dl,[bx+si]
	call disp_d_1
	jmp ok
next6:sub al,'A'
	mov ah,0
	mov si,ax
	mov dl,[bx+si]
	call disp_d_1
ok:pop dx
	pop ax
	popf
ret
disp_d_1:
	pushf
	push ax
	push dx
	mov al,dl
	mov ah,0
	mov dl,10
	div dl
	mov dl,al
	call disp_hd_1
	mov dl,ah
	call disp_hd_1
	pop dx
	pop ax
	popf
ret
disp_hd_1:
	pushf
	cmp dl,9
	ja L1_1
	call disp_1_dec
	jmp L1_2
L1_1:
	call disp_1_hex
L1_2:
	popf
ret
disp_1_dec:
	push ax
	push dx
	pushf
	add dl,30h
	mov ah,02h
	int 21h
	popf
	pop dx
	pop ax
ret
disp_1_hex:
	push ax
	push dx
	pushf
	add dl,37h
	mov ah,02h
	int 21h
code ends
end start

运行截图

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_29711355/article/details/125463348
今日推荐