flat assembler
Message board for the users of flat assembler.
Index
> Main > text seek and find |
Author |
|
DOS386 10 Jan 2008, 03:19
> is there a way to make it faster?
> i'm sure there is one... Are you sure your code works at all ? - Place 2 or 4 letters of your word into AX or EAX if long enough - UTFG String searching algorithm |
|||
10 Jan 2008, 03:19 |
|
edfed 10 Jan 2008, 03:25
i'm sure, i've tested it a couple of minutes ago.
|
|||
10 Jan 2008, 03:25 |
|
bitRAKE 10 Jan 2008, 03:51
Code: xor ecx,ecx .0: xor edx,edx .1: mov ah,[edi+ecx] mov al,[esi+edx] inc ecx inc edx cmp al,ah je .1 test al,al je .2 test ah,ah jne .0 or al,1 ret .2: sub ecx,edx xor ah,ah ret How about?: Code: xor ecx,ecx jmp .0 .a: cmp al,ah je .1 .0: xor edx,edx .1: mov ah,[edi+ecx] mov al,[esi+edx] inc ecx inc edx test ah,ah je .3 test al,al jne .a cwb sub ecx,edx retn .3: or al,1 ret Code: xor ecx,ecx jmp .0 .a: cmp al,ah je .1 .0: xor edx,edx .1: mov ah,[edi+ecx] mov al,[esi+edx] inc ecx inc edx test ah,ah je .3 ; carry flag clear on jump test al,al jne .a sub ecx,edx stc ; set carry flag to indicate no match .3: retn Last edited by bitRAKE on 10 Jan 2008, 04:09; edited 1 time in total |
|||
10 Jan 2008, 03:51 |
|
edfed 10 Jan 2008, 04:09
wich rare instances?
yeah good job. but faster if instead of ah, i use cf to say if string was found faster in post-function treatment. Code:
or al,al
je @f
...
bad design
jc @f
...
good design
Last edited by edfed on 10 Jan 2008, 04:12; edited 1 time in total |
|||
10 Jan 2008, 04:09 |
|
bitRAKE 10 Jan 2008, 04:10
if strings are the same, or pointer same.
(your reply beat my edit ) |
|||
10 Jan 2008, 04:10 |
|
edfed 10 Jan 2008, 04:17
no, if the string and pointers are the same, it works.
probably, your test program have a problem... |
|||
10 Jan 2008, 04:17 |
|
edfed 10 Jan 2008, 04:20
your third version seems to be slow..
too much jxx |
|||
10 Jan 2008, 04:20 |
|
bitRAKE 10 Jan 2008, 05:29
InHere db "Oh, you just try to match my string!",0,0,0,"junk"
Find db "string!",0,"?" |
|||
10 Jan 2008, 05:29 |
|
edfed 10 Jan 2008, 12:14
as string are null terminated, i don't see the problem.
if strings are sized, then , the algorythm doesn't check for 0, but for counter=0 Code: findtxt: xor ecx,ecx .init: xor edx,edx @@: mov al,[esi+edx] inc edx or al,al je @f mov ah,[edi+ecx] inc ecx or ah,ah je .end cmp al,ah je @b jmp .init @@: sub ecx,edx mov eax,ecx clc ret .end: stc ret works even if strings to comapre are the same... |
|||
10 Jan 2008, 12:14 |
|
Vasilev Vjacheslav 18 Jan 2008, 13:43
i am using Boyer-Moore searching algo, pretty fast
|
|||
18 Jan 2008, 13:43 |
|
edfed 18 Jan 2008, 14:27
please, don't speak about names of function inventors.
pleaseee, post some code in asm. ps: i find the names of humans to name functions is a bad principle. adopted since the antiquity but bad. because the algorythms exists before to be discovered. |
|||
18 Jan 2008, 14:27 |
|
LocoDelAssembly 18 Jan 2008, 16:06
Quote: please, don't speak about names of function inventors. But that is the algorithm name...http://www.nist.gov/dads/HTML/boyermoore.html http://www.movsd.com/bm.htm |
|||
18 Jan 2008, 16:06 |
|
OzzY 18 Jan 2008, 17:12
start: Use scasb to find the first character, then cmp byte per byte till you find a space. If not found jmp start.
or call strstr() from libc. Code: invoke LoadLibrary, 'msvcrt.dll' push eax invoke GetProcAddress,eax,'_strstr' mov [strstr],eax invoke strstr, thetext, thestring test eax,eax jz not_found ;eax = pointer to the word you want to find . . . not_found: pop eax invoke FreeLibrary,eax I doubt we can make it any faster than the libc. |
|||
18 Jan 2008, 17:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.