更新时间:2023-02-21 17:11:19
您可以替换?"之后的所有内容.以零表示,因此?"之后的所有字符被删除":
You can replace everything after the "?" by zeroes, so all the characters after "?" are been "removed" :
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
请注意,搜索?"后,我们如何使用EDI和ECX的值.
Notice how we are using the values that EDI and ECX have after searching for "?".