Function ReplaceASM(TiStr As String, TiFind As String, TiRep As String) As String
   Dim As ZString Ptr iStr,iFind, iRep
   Dim As Integer val0=Len(TiRep)
   
   If TiStr = "" Or TiFind = "" Or TiRep = "" Then
      Function = TiStr
      Exit Function
   EndIf
   
   iStr = StrPtr(TiStr)
   iFind = StrPtr(TiFind)
   iRep = StrPtr(TiRep)
   
   Dim As Integer iSize=Len(TiStr)-Len(TiFind)
   Dim As ZString Ptr dStr=CAllocate(Len(TiStr)*20)
   Dim  As String toto
   
   Asm
      mov esi, [iStr]
      add [iSize], esi
      mov ebx, [iFind]
      inc dword Ptr[iSize]
      mov edi, [dStr]
   End Asm
   Asm Sub esi, 1
      Asm
         jmp Start1
         Start2 : add esi, ecx
         Start1 : add esi, 1
         cmp [iSize], esi
         jle Done
         movzx eax, Byte Ptr[esi]
         cmp al, [ebx]
         je Match
         mov [edi], al
         add edi, 1
         jmp Start1
         Match : mov ecx, -1
         mov edx, ebx
         B1 : add ecx, 1
         movzx eax, Byte Ptr[edx]
         Test eax, eax
         jz Change
         add edx, 1
         cmp [esi + ecx], al
         je B1
         movzx eax, Byte Ptr[esi]
         mov [edi], al
         add edi, 1
         jmp Start1
         Change : mov edx, [iRep]
      End Asm
      saute : Asm Sub ecx, 1
      Asm
         B2 : movzx eax, Byte Ptr[edx]
         Test eax, eax
         jz Start2
         add edx, 1
         mov [edi], al
         add edi, 1
         jmp B2
         Done : mov ecx, -1
         B3 : add ecx, 1
         movzx eax, Byte Ptr[esi + ecx]
         mov [edi + ecx], al
         Test eax, eax
         jnz B3
         'mov eax,[dStr]
         'mov [toto],eax
      End Asm
      toto = *dStr
      Function = toto
      Sleep(1)
      Deallocate dStr
      
   End Function