Advertisement
Gov_777

ASM Поиск подстроки с позиции

Oct 13th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.65 KB | None | 0 0
  1. function TailPos(const S, SubStr: AnsiString; fromPos: integer): integer;
  2. // TailPos('Искать тут', 'искомое', с какой позиции - интеджер);
  3. asm
  4. PUSH EDI
  5. PUSH ESI
  6. PUSH EBX
  7. PUSH EAX
  8. OR EAX,EAX
  9. JE @@2
  10. OR EDX,EDX
  11. JE @@2
  12. DEC ECX
  13. JS @@2
  14.  
  15. MOV EBX,[EAX-4]
  16. SUB EBX,ECX
  17. JLE @@2
  18. SUB EBX,[EDX-4]
  19. JL @@2
  20. INC EBX
  21.  
  22. ADD EAX,ECX
  23. MOV ECX,EBX
  24. MOV EBX,[EDX-4]
  25. DEC EBX
  26. MOV EDI,EAX
  27. @@1: MOV ESI,EDX
  28. LODSB
  29. REPNE SCASB
  30. JNE @@2
  31. MOV EAX,ECX
  32. PUSH EDI
  33. MOV ECX,EBX
  34. REPE CMPSB
  35. POP EDI
  36. MOV ECX,EAX
  37. JNE @@1
  38. LEA EAX,[EDI-1]
  39. POP EDX
  40. SUB EAX,EDX
  41. INC EAX
  42. JMP @@3
  43. @@2: POP EAX
  44. XOR EAX,EAX
  45. @@3: POP EBX
  46. POP ESI
  47. POP EDI
  48. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement