flat assembler
Message board for the users of flat assembler.
Index
> Main > (text) search procedure - i've got an update |
Author |
|
idle 03 Apr 2011, 06:23
hi
there it is Last edited by idle on 03 Apr 2011, 12:19; edited 1 time in total |
|||
03 Apr 2011, 06:23 |
|
revolution 03 Apr 2011, 07:11
Can you be more detailed in your explanation please. What is the code for?
|
|||
03 Apr 2011, 07:11 |
|
idle 03 Apr 2011, 12:20
examples added
follow same link |
|||
03 Apr 2011, 12:20 |
|
Tyler 03 Apr 2011, 19:43
Most can't open .rar's anyway. It's a pain, especially in Linux.
|
|||
03 Apr 2011, 19:43 |
|
idle 04 Apr 2011, 04:23
Tyler wrote: Most can't open .rar's anyway. It's a pain, especially in Linux. zip, 7z(preferred)? edfed wrote: it is a minimal thing to at least explain what can be inside your file. \revolution\compatibility.inc: Code: http://board.flatassembler.net/topic.php?t=12443 \pos.inc (russian version of comments killed, see below, that's why archives used): Code: ;include 'revolution\compatibility.inc' ;.386 ; ;enu: position function returns displacement of a subdata in a data ; positions counted from 1, not 0 ; params are: ; - this - subdata(wanted, substring, etc) ; - lthis - length in bytes of that subdata ; - here - data ; - lhere - length in bytes of that data ; - start - byte number to start from ; counted from data front side if flags.df=0 ; counted from data back side if flags.df=1 ; - stop - byte number this proc may neither exceed nor touch ; counted from data front side if flags.df=0 ; counted from data back side if flags.df=1 ; ignored if 0 or exceeds lhere parameter i.e. data ; on exit: ; - flags - ?, df flag retained ; - eax - 0 or smth else :) ; flags.df implied 0 ; ; contact - edemko@rambler.ru ; ;rus: 2>72@0B8BL 2E>645=85 8A:><>3> 2 =01>@5 109B ; AG5B 2545BAO A 1, =5 0 ; ?0@0<5B@K: ; - this - 8A:><>5 ; - lthis - 109B 2 8A:><>< ; - here - =01>@ 109B ; - lhere - 109B 2 =01>@5 ; - start - AB0@B>2K9 109B =01>@0 ; >B=>A8B5;L=> =0G0;0 =01>@0 5A;8 flags.df=0 ; >B=>A8B5;L=> :>=F0 =01>@0 5A;8 flags.df=1 ; - stop - =0G8=0O A MB>3> 109B0 8A:0BL =5;L7O ; >B=>A8B5;L=> =0G0;0 =01>@0 5A;8 flags.df=0 ; >B=>A8B5;L=> :>=F0 =01>@0 5A;8 flags.df=1 ; 83=>@8B?AO 5A;8 0 8;8 2=5 =01>@0 ; 2KE>4: ; - flags - ?, df ?@56=89 ; - eax - 0 8;8 =5B :) ; 7=0G5=85 :0:-1K flags.df=0 ; ; ?>GB0 - edemko@rambler.ru ; ;fasm---------------------------------- ;format pe gui ; ; this db '124' ; .: ; here db '0123456789 124 ' ; .: ; ;entry $ ; ;std ; push 0 ; push 1 ; push here.-here ; push here ; push this.-this ; push this ; call pos ; cld ; ret 0 ;-------------------------------------- ; if used pos if defined DEBUG & DEBUG=1 db 'dbug:pos',0 end if pos: sub eax,eax ;pos = 0 pusha ;push eax ecx edx ebx old_esp ebp esi edi pushf label .this dword at esp+10*4 label .lthis dword at esp+11*4 label .here dword at esp+12*4 label .lhere dword at esp+13*4 label .start dword at esp+14*4 label .stop dword at esp+15*4 or eax,[.stop] mov ecx,[.lhere] jz .stop_applied ;stop = 0 -> no stop cmp ecx,eax jb .stop_applied ;lhere < stop -> no stop lea ecx,[eax-1] .stop_applied: mov edi,[.start] sub edi,1 jc .ret ;start = 0 sub ecx,edi jna .ret ;start > lhere mov edx,[.lthis] sub edx,1 ;cmpsb.ecx jc .ret ;lthis = 0 sub ecx,edx ;scasb.ecx jna .ret ;lthis > lhere bt dword[esp],10 mov esi,[.this] jnc .forward add esi,edx ;@this[lthis] not edi ;-start-1 add edi,[.lhere] ;+lhere .forward: lodsb ;this[1] or this[lthis] add edi,[.here] .find:repne scasb jne .ret ;pos = 0 test edx,edx jz .found ;lthis = 1 mov ebx,ecx mov ecx,edx mov ebp,esi push edi repe cmpsb pop edi je .found test ebx,ebx jz .ret ;pos = 0 mov ecx,ebx mov esi,ebp jmp .find .found: bt dword[esp],10 jnc .forward_ sub edi,edx ;pre-entry add edi,2 ;pre-entry + 1 -> entry + 1 -> post-entry .forward_: sub edi,[.here] mov [esp+8*4],edi ;popa.eax .ret: popf popa ret 6*4 ;2011_04_03 end if \primitive_test\primitive_test.inc: Code: format pe gui include 'win32ax.inc' section '' code executable import readable writable library kernel32,'kernel32.dll',\ user32,'user32.dll' import kernel32,\ ExitProcess,'ExitProcess' import user32,\ MessageBoxA,'MessageBoxA',\ wsprintfA,'wsprintfA' include '..\pos.inc' entry $ mov ebx,this mov ecx,this.-this mov edx,here mov esi,here.-here mov edi,1 mov ebp,0 mov [flags.df],_cld cld call demonstrate mov ebx,this mov ecx,this.-this mov edx,here mov esi,here.-here mov edi,2 mov ebp,13 mov [flags.df],_cld cld call demonstrate mov ebx,this mov ecx,this.-this mov edx,here mov esi,here.-here mov edi,2 mov ebp,12 mov [flags.df],_cld cld call demonstrate mov ebx,this mov ecx,this.-this mov edx,here mov esi,here.-here mov edi,1 mov ebp,-1 mov [flags.df],_std std call demonstrate mov ebx,this mov ecx,this.-this mov edx,here mov esi,here.-here mov edi,3 mov ebp,-1 mov [flags.df],_std std call demonstrate mov ebx,this mov ecx,this.-this mov edx,here mov esi,here.-here mov edi,4 mov ebp,0 mov [flags.df],_std std call demonstrate mov ebx,this mov ecx,this.-this mov edx,here mov esi,here.-here mov edi,4 mov ebp,12 mov [flags.df],_std std call demonstrate mov ebx,this mov ecx,this.-this mov edx,here mov esi,here.-here mov edi,4 mov ebp,11 mov [flags.df],_std std call demonstrate invoke ExitProcess,eax demonstrate: stdcall pos,ebx,ecx,edx,esi,edi,ebp cld test eax,eax jz @f lea eax,[edx+eax-1] @@:cinvoke wsprintfA,temp,pattern ,[flags.df] ,ebx,ecx,edx,esi,edi,ebp ,eax invoke MessageBoxA,0,temp,0,0 ret 0 here db ' Can you can a can as a canner can can a can? ' .: db 0 this db 'can' .: db 0 _cld db 'cld',0 _std db 'std',0 flags.df dd ? pattern db '%s' ,10,\ 'stdcall pos,\' ,10,\ 9,'/*this*/ "%s",\' ,10,\ 9,'/*lthis*/ %u,\' ,10,\ 9,'/*here*/ "%s",\' ,10,\ 9,'/*lhere*/ %u,\' ,10,\ 9,'/*start*/ %u,\' ,10,\ 9,'/*stop*/ %u' ,10,\ '-> "%s"' ,0 temp rb 255 |
|||
04 Apr 2011, 04:23 |
|
Tyler 04 Apr 2011, 05:21
idle wrote: zip, 7z(preferred)? |
|||
04 Apr 2011, 05:21 |
|
idle 04 Apr 2011, 05:43
For Windows, there is a Total Commander plug-in, Total7zip. Alternative link.
It uses Igor Pavlov's API. Hence, have no packers installed, as any archive is seen as a folder, entered thorough <Enter> or <Ctrl+PgDown>. English for TC. |
|||
04 Apr 2011, 05:43 |
|
idle 11 Apr 2011, 04:58
link from the 1st post points at new archive
*.rar type used still as gives best results (text) searching proc // поиск (текста) (text) searching proc for Tyler from board.FlatAssembler.net part of an ENU comments from the main file: Code: ... ;enu: emulates scasb, scasw, cmpsb, cmpsw ; exits if ecx=0 ; native case-sensitive instrunction used if ebx=0 ; else ebx must contain 256(scasb&cmpsb) or 65'536(scasw&cmpsw) triplets(small,CAPITAL,Normal) of the form: ; scasb&cmpsb: small$00 ,CAPITAL$00 ,Normal$00 ... small$ff ,CAPITAL$ff ,Normal$ff ; scasw&cmpsw: small$0000 ,CAPITAL$0000 ,Normal$0000 ... small$ffff ,CAPITAL$ffff ,Normal$ffff ; flags.zero set accordingly regardless ecx=0 ... ;enu: find subdata in data ; values counted in chars from 1, not 0 ; byte(flags.cf=0) and word(flags.cf=1) chars possible ; forward(flags.df=0) and backward(flags.df=1) directions possible ; case ignorance(see emul_xxxx intros for details) possible ; stdcall-params are: ; this - subdata to be found ; lthis - chars in subdata ; here - data to find in ; lhere - chars in that data ; start - char number to start from ; related data front if direction is forward and vice-versa ; stop - search may neither touch nor exceed this char ; related data front if direction is forward and vice-versa ; ignored if out of data(0 or exceeds lhere) ; on exit eax register receives the result as if direction is forward ... ; ... ; gpu.ebx ; flags.cf ; flags.df |
|||
11 Apr 2011, 04:58 |
|
Tyler 11 Apr 2011, 05:39
I don't have time to look at it right now, but have you done any research on the topic? String searching is pretty much a mapped field.
http://en.wikipedia.org/wiki/String_searching_algorithm vid has an implementation of Boyer-Moore-Horspool in fasmlib. |
|||
11 Apr 2011, 05:39 |
|
idle 11 Apr 2011, 14:48
http://fasmme.googlecode.com/files/pos.rar
contents: Code: revolution\ ;cpu version control compatibility.inc table\ ;tables to ignore case of letters input\ ;unprocessed text 1250.txt 1251.txt 1252.txt 1253.txt 1254.txt 1255.txt 1256.txt 1257.txt 1258.txt output\ ;processed text, ready to be used 1250.bin 1251.bin 1252.bin 1253.bin 1254.bin 1255.bin 1256.bin 1257.bin 1258.bin unicode.bin test\ ;win32 test program resource\ ;resources, created with ResEd test.rc.inc test.rc test.RES test.asm ;source of test program test.byte.exe ;byte chars mode test.word.exe ;wide chars mode pos.inc ;main file all's based on |
|||
11 Apr 2011, 14:48 |
|
idle 11 Apr 2011, 22:14
http://fasmme.googlecode.com/files/pos.rar
new: table files decreased by 1/3 due format change -> scanner and comparer work a bit faster Code: ;enu: emulates scasb, scasw, cmpsb, cmpsw ; exits if ecx=0 ; native case-sensitive instrunction used if ebx=0 ; else ebx must point at 256(scasb&cmpsb) or 65'536(scasw&cmpsw) doublets(small,CAPITAL) of the form: ; scasb&cmpsb: small$00 ,CAPITAL$00 ... small$ff ,CAPITAL$ff ; scasw&cmpsw: small$0000 ,CAPITAL$0000 ... small$ffff ,CAPITAL$ffff ; flags.zero set accordingly regardless ecx=0 ;rus: 8<8B0B>@ scasb, scasw, cmpsb, cmpsw ; 2K945B 5A;8 ecx=0 ; =8G53> =5 8<8B8@>20BL 5A;8 ebx=0 ; 8=0G5 ebx 4>;65= A>45@60BL C:070B5;L =0 256(scasb&cmpsb) 8;8 65'536(scasw&cmpsw) ?0@(<0;5=L:0O,,(/): ; scasb&cmpsb: <0;5=L:0O$00 ,,(/$00 ... <0;5=L:0O$ff ,,(/$ff ; scasw&cmpsw: <0;5=L:0O$0000 ,,(/$0000 ... <0;5=L:0O$ffff ,,(/$ffff ; flags.zero CAB0=>28BAO A>>B25BAB2C5I5 2=5 7028A8<>AB8 >B ecx=0 macro _[name]{ forward if used emul_#name if defined DEBUG & DEBUG=1 db 'dbug:',`emul_,`name,0 end if emul_#name: pushf test ecx,ecx jz .ne test ebx,ebx jnz .emul ;------------------------------- if name eq scasb | name eq scasw repne name else repe name end if ;------------------------------- jne .ne .e: or byte[esp],1 shl 6 popf ret 0 .emul:bt dword[esp],10 push edx rcr edx,1 push eax ;------------------------------- if name eq scasb movzx eax,al mov dl,[ebx+eax*2] else if name eq scasw movzx eax,ax mov dx,[ebx+eax*4] end if ;------------------------------- .loop: ;------------------------------- if name eq scasb movzx eax,byte[edi] test edx,edx jns .df0 dec edi jmp .df1 .df0: inc edi .df1: cmp [ebx+eax*2],dl loopne .loop else if name eq scasw movzx eax,word[edi] test edx,edx jns .df0 sub edi,2 jmp .df1 .df0: add edi,2 .df1: cmp [ebx+eax*4],dx loopne .loop else if name eq cmpsb movzx eax,byte[edi] mov dl,[ebx+eax*2] movzx eax,byte[esi] test edx,edx jns .df0 dec edi dec esi jmp .df1 .df0: inc edi inc esi .df1: cmp [ebx+eax*2],dl loope .loop else if name eq cmpsw movzx eax,word[edi] mov dx,[ebx+eax*4] movzx eax,word[esi] test edx,edx jns .df0 sub edi,2 sub esi,2 jmp .df1 .df0: add edi,2 add esi,2 .df1: cmp [ebx+eax*4],dx loope .loop end if ;------------------------------- pop eax pop edx je .e .ne: and byte[esp],not(1 shl 6) popf ret 0 end if } _ scasb,scasw,cmpsb,cmpsw purge _ this automata(dummy code) has rebuilt tables: Code: format pe gui include 'win32ax.inc' section '' code executable import readable writable library kernel32,'kernel32.dll' include 'api\kernel32.inc' entry $ again: mov edi,table mov esi,edi invoke CreateFile,patient,GENERIC_READ,0,0,OPEN_EXISTING,0,0 push eax invoke GetFileSize,eax,0 cmp eax,256*2 je cancel mov eax,[esp] invoke ReadFile,eax,edi,256*3,esp,0 invoke CloseHandle mov ecx,256 @@:lodsw inc esi stosw loop @b invoke CreateFile,patient,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0 push eax invoke WriteFile,eax,table,256*2,esp,0 cancel: invoke CloseHandle add byte[patient+10],1 cmp byte[patient+10],'9' jne again mov edi,table mov esi,edi invoke CreateFile,patient_,GENERIC_READ,0,0,OPEN_EXISTING,0,0 push eax invoke GetFileSize,eax,0 cmp eax,65'536*2*2 je cancel_ mov eax,[esp] invoke ReadFile,eax,edi,65'536*3*2,esp,0 invoke CloseHandle mov ecx,65'536 @@:lodsd add esi,2 stosd loop @b invoke CreateFile,patient_,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0 push eax invoke WriteFile,eax,table,65'536*2*2,esp,0 cancel_:invoke CloseHandle invoke ExitProcess,eax patient db 'output\1250.bin',0 patient_ db 'output\unicode.bin',0 table rw 65'536*3 |
|||
11 Apr 2011, 22:14 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.