上传者: leonalily
|
上传时间: 2022-12-11 11:26:37
|
文件大小: 1KB
|
文件类型: TXT
Assembly code DATAS SEGMENT
cap1 db "please input a string",0dh,0ah,"$"
cap2 db "plesae input the letter you search",0dh,0ah,"$"
str0 db 40,?,40 dup(0),
str1 db 40 dup (0)
DATAS ENDS
STACKS SEGMENT
dw 40h dup(?)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS笑脸ATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
mov dx,offset cap1;输出提示“please input a string"
mov ah,09h
int 21h
mov dx,offset str0;输入一行字符串
;mov dh,0ah ;此处错误
mov ah,0ah
int 21h
mov dl,0ah;以下三行是实现换行功能
mov ah,02
int 21h
mov dl,13;以下三行是实现回车功能
mov ah,02
int 21h
mov dx,offset cap2
mov ah,09h
int 21h
mov ah,01h
int 21h
lea si,str0
lea di,str1
;mov dh,dl ;此处错误,输入放在al中
mov dh,al
call search
xor dh,dh
mov cx,dx
;lea di,str0;以下几句是实现依次输入找到的字符串的位置
lea di,str1;
l4:
;loopz l5.
;mov cl,[di]
mov dl,byte ptr [di]
cmp dl,0
jz l5
add dl,30h
mov ah,02h
int 21h
mov dl,','
mov ah,02h
int 21h
inc di
jmp l4
l5:
MOV AH,4CH
INT 21H
search proc;子程序
pushf
push ax
;mov cx,[si+1] ;此处修改
xor cx,cx
mov cl,byte ptr[si+1]
mov dl,0
mov ax,1
l3:cmp [si+2],dh
jnz l1
inc dl
mov [di],al
inc di
l1:inc ax
cmp ax,cx
ja l2
inc si
jmp l3
l2:pop ax
popf
ret
search endp
CODES ENDS
END START