我正在编写一个程序,提示用户输入字符串,然后输入他们要搜索字符串的字符。完成后,我要显示出现的次数。我的比较指示是我陷入困境的地方;它无法正常工作。
.data
String1 BYTE "Enter a sentence: ", 0
String2 BYTE 50 DUP (?)
String3 BYTE "Decimal length: ", 0
String4 BYTE "Hexidecimal length: ", 0
String5 BYTE "You entered: ", 0
String6 BYTE "Enter a character: ", 0
String7 BYTE "Searching for: ", 0
String8 BYTE "Number of occurences: ", 0
char BYTE ?
Exercise2 PROC
mov al, 0Ah
call WriteChar
mov al, 0Dh
call WriteChar
mov edx, OFFSET String1
call WriteString
mov ecx, 50
mov edx, OFFSET String2
call ReadString
mov edx, OFFSET String6
call WriteString
call ReadChar
mov esi, OFFSET String2
mov edi, OFFSET char
mov ecx, 12 ;arbitrary string length
mov edx, 0
CLD
REPE CMPSB
inc dl
;how do i store number of occerrence in dl??
mov eax, edx
call WriteDec
Exercise2 ENDP