写得不好。
szTestStr1
byte
"AB123ABCABBABAB",0
szTest1
byte
"AB",0
szTest2
byte
"YY",0
调用: invoke ReplaceStr,addr szTestStr1,addr szTest1,addr szTest2
ReplaceStr
proc
_lpSource,_lpBuffer1,_lpBuffer2
LOCAL
@dwLength,@dwCount
mov
@dwCount,0
invoke lstrlen,_lpBuffer1
push
eax
invoke lstrlen,_lpBuffer2
mov
@dwLength,eax
pop
ebx
.if
eax != ebx
mov eax,FALSE
ret
.endif
invoke lstrlen,_lpSource
mov
ecx, eax
mov
esi,_lpSource
mov
edi,_lpBuffer1
mov
ebx,_lpBuffer2
.while ecx
push
ecx
invoke lstrlen,_lpBuffer2
mov
@dwLength,eax
.while @dwLength
;2
mov dl,byte ptr [esi]
.if dl != byte ptr [edi]
.break
.else
inc @dwCount
inc esi
inc edi
.endif
dec @dwLength
.endw
invoke lstrlen,_lpBuffer2
.if
@dwCount != eax
inc esi
mov edi,_lpBuffer1
mov @dwCount,0
.else
push esi
sub esi,@dwCount
mov edi,esi
mov esi,_lpBuffer2
mov ecx,@dwCount
cld
rep movsb
pop esi
mov edi,_lpBuffer1
mov @dwCount,0
.endif
pop ecx
dec ecx
.endw
ret
ReplaceStr
endp