flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
DOS386
> 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 |
|||
![]() |
|
edfed
i'm sure, i've tested it a couple of minutes ago.
|
|||
![]() |
|
bitRAKE
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 |
|||
![]() |
|
edfed
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 |
|||
![]() |
|
bitRAKE
if strings are the same, or pointer same.
(your reply beat my edit ![]() |
|||
![]() |
|
edfed
no, if the string and pointers are the same, it works.
probably, your test program have a problem... |
|||
![]() |
|
edfed
your third version seems to be slow..
too much jxx |
|||
![]() |
|
bitRAKE
InHere db "Oh, you just try to match my string!",0,0,0,"junk"
Find db "string!",0,"?" |
|||
![]() |
|
edfed
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... |
|||
![]() |
|
Vasilev Vjacheslav
i am using Boyer-Moore searching algo, pretty fast
|
|||
![]() |
|
edfed
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. |
|||
![]() |
|
LocoDelAssembly
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 |
|||
![]() |
|
OzzY
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. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.