0
텍스트에서 단어를 검색 할 수있는 x86 어셈블리를 사용하여 프로그램을 작성하려고합니다. 단어가 텍스트에 있으면 프로그램에서 사용자에게 알려줍니다. 문자열을 비교하는 데 여전히 문제가 있습니다. 어떤 충고?주어진 텍스트에서 단어를 검색하는 x86 어셈블리 프로그램
.model small
.stack 200h
.data
message1 db "Enter your text here: $"
text db 150,151 dup(0)
message2 db 10,13,"Enter the word that you want to find: $"
find db 20,21 dup(0)
yesmessage db 10,13,"The word is in the text$"
nomessage db 10,13,"Sorry the word is not in the text$"
.code
Start:
;Display message and key in strings
mov ax,seg message1
mov ds,ax
mov si,offset text
mov di,offset find
mov dx,offset message1
mov ah,09h
int 21h
mov dx,si
mov ah,0Ah
int 21h
mov ax,seg message2
mov ds,ax
mov dx,offset message2
mov ah,09h
int 21h
mov dx,di
mov ah,0Ah
int 21h
;compare strings
mov bx,00
mov bl,text+1
mov bh,find+1
cmp bl,bh
jne L1
add si,2
add di,2
L2:mov bl,byte ptr[si]
cmp byte ptr[di],bl
jne L1
inc si
inc di
cmp byte ptr[di],"$"
jne L2
mov ah,09h
mov dx,offset yesmessage
int 21h
L1:mov ah,09h
mov dx,offset nomessage
int 21H
mov ax,4c00h
int 21h
end start
예상 된 결과는 다음과 같아야합니다
예 1 :
Enter your text here: He is old Enter the word that you want to find: old The word is in the text
예 2 : 코드에서
Enter your text here: He is old Enter the word that you want to find: young Sorry the word is not in the text
; 문자열 부분을 비교 : 아래에있는 내 의견을 참조하십시오? –