如何在'?'之后删除字符串中的所有内容? ?到目前为止我的代码搜索了'?'。我该如何从那里开始?
这是我的代码。
INCLUDE Irvine32.inc
.data
source BYTE "Is this a string? Enter y for yes, and n for no",0
.code
main PROC
mov edi, OFFSET source
mov al, '?' ; search for ?
mov ecx, LENGTHOF source
cld
repne scasb ; repeat while not equal
jnz quit
dec edi ; edi points to ?
end main
答案 0 :(得分:-1)
您可以在"?"之后更换所有内容。由零,所以#34;?"之后的所有字符已被删除" :
INCLUDE Irvine32.inc
.data
source BYTE "Is this a string? Enter y for yes, and n for no",0
.code
main PROC
mov edi, OFFSET source
mov al, '?' ; search for ?
mov ecx, LENGTHOF source
cld
repne scasb ; repeat while not equal
jnz quit
dec edi ; edi points to ?
;REPLACE ALL CHARACTERS BY "AL" (ZERO) STARTING WHERE "EDI" WAS AND
;FINISH WHEN "ECX" == 0.
mov al, 0 ;<=====================================
repne stosb ;<=====================================
end main
注意我们在搜索&#34;?&#34;后如何使用EDI和ECX的值。