flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > find words in string. How do this ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 814
Roman
I use 32 bit fasm program.
I need write fasm code.
My head is like cotton. Oh.
How found a then b then c then fot\art\zip\ar in t2 ?
Code:
t1 db '(a,b,c) (fot,art) (zip,ar)',0
t2 db 'a = 3; b = 2; c = 0; fot = 2; art = 1',13,10
    db 'zip = 22; ar =2',0
    


1) Get from t1 '(' and get 'a' then find in t2 'a'
2) if found ',' get next 'b' and find in t2 'b'

First problem. 'a' exist in:
Code:
a = 3
art = 1
ar =2
    

I need find 'a' only in a = 3 !
Post 07 Sep 2020, 08:49
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 814
Roman
Why my thread in High Level Languages ?
I need work with text in Fasm 1.73 in 32 bit mode
And write fasm 32 bit program search names in text t2.
Post 07 Sep 2020, 09:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17624
Location: In your JS exploiting you and your system
revolution
You are writing code to generate/scan HLL source, right? So, I think this it the right place, you can post code that scans or generates the HLL source.


Last edited by revolution on 07 Sep 2020, 09:52; edited 1 time in total
Post 07 Sep 2020, 09:18
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17624
Location: In your JS exploiting you and your system
revolution
To start you off you need to define what is a 'separator' in your language. Then the text is what exists between each separator.

I can probably guess that space, equals and semi-colon are separators from the sample you posted. There might be others. So from there you can construct a list of them.
Post 07 Sep 2020, 09:22
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 814
Roman
How i search.
Code:
macro FindWord chFind,chTxt,chZnk,chZnk2 {local j0,j1,j2,j3,j4,j5,jj
        mov edx,chTxt
        dec edx
j0:     sub ecx,ecx
        inc edx       ;
j1:     mov al,[chFind+ecx]
        cmp al,chZnk
        jz  j2
        cmp al,chZnk2
        jz  j2
        cmp al,[edx]
        jnz j0
        inc edx    ;in this place may be a problem ?! a think about label j0: inc edx
        inc ecx
        cmp al,13
        ja  j1
j2:     add ebx,ecx
        ;pusha
        ;Msg edx,'Find:'
        ;popa
j3:
jj:
        }           
    

In code i use:
Code:
t2 db 'a = 3; b = 2; c = 0;',13,10,0
tt db 'a ,b ,c )',13,10,0
mov ebx,tt
FindWord ebx,t2,',',')'
    
Post 07 Sep 2020, 11:19
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 814
Roman
Post 09 Sep 2020, 10:23
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.