题目:在键盘上输入一个字符串,并保存在STR1开始的内存单元,统计字符串'ing在STR1中出现的次数NUM。在终端显示字符串STR1、NUM。
STR1 byte n dup(?)
NUM word 0;存放字符串中'ing’个数word
注:输入字符串长度不小于20;允许在程序设计中增加所需变量、常量、位置定义
include Irvine32.inc
.data
str1 dword 100 dup(?)
num dword 0
.code
main proc
call set
call found
exit
main endp
set proc
mov edx,offset str1
mov ecx,lengthof str1
call readstring
ret
exit
set endp
found proc
mov edx,offset str1
mov ebx,0
check1:
cmp ecx,1
jl sc
movzx eax,byte ptr [edx]
cmp eax,105
je check2
inc edx
dec ecx
jmp check1
check2:
dec ecx
inc edx
movzx eax,byte ptr [edx]
cmp eax,110
je check3
cmp eax,105
je check2
inc edx
jmp check1
check3:
dec ecx
inc edx
movzx eax,byte ptr [edx]
cmp eax,103
je check4
cmp eax,105
je check2
inc edx
jmp check1
check4:
inc ebx
inc edx
dec ecx
jmp check1
sc:
mov num,ebx
mov eax,num
mov edx,offset str1
call writestring
call crlf
call writeint
exit
found endp
end main