flat assembler
Message board for the users of flat assembler.

flat assembler > Heap > fasm1: placing in output ASC sorted unique string list (Idea

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 276
Location: Russian Federation, Sochi
Code:
macro dummy [arg]{
 common
        local ..StrTbl,..Strings
        virtual at 0
                ..StrTbl::
        end virtual

        virtual at 0
                ..Strings::
        end virtual

        macro def_astring labl,[string] \{
         \common
                \local ..offs,sz
                virtual ..Strings
                        ..offs db string,0
                        sz = $-..offs
                        virtual ..StrTbl
                                labl\#id = $/8
                                dd labl\#id
                                dw ..offs,sz
                        end virtual
                end virtual \}
 forward
        local ..arg
        def_astring ..arg,arg

 common
        local count,x,y,z,v1,v2,str1,str2
        virtual ..StrTbl
                count = $/8
        end virtual
        x = count shr 1
        while x > 0
                y = x
                while y < count
                        z = y
                        while z-x >= 0
                                load str1 word from ..StrTbl:(z*8+4)
                                load str2 word from ..StrTbl:((z-x)*8+4)
                                v1 = str1
                                while v1 > 0
                                        load v1 byte from ..Strings:(str1+%-1)
                                        load v2 byte from ..Strings:(str2+%-1)
                                        if v1 <> v2
                                                break
                                        end if
                                end while
                                if v2>v1
                                        break
                                else
                                        load v2 dword from ..StrTbl:((z-x)*8)
                                        if v1<v2
                                                load v1 dword from ..StrTbl:(z*8)
                                                store dword v1 at ..StrTbl:((z-x)*8)
                                        end if
                                        store dword v2 at ..StrTbl:(z*8)
                                        load v2 word from ..StrTbl:((z-x)*8+4)
                                        if v1<v2
                                                load v1 word from ..StrTbl:(z*8+4)
                                                store word v1 at ..StrTbl:((z-x)*8+4)
                                        end if
                                        store word v2 at ..StrTbl:(z*8+4)
                                        load v2 word from ..StrTbl:((z-x)*8+6)
                                        if v1<v2
                                                load v1 word from ..StrTbl:(z*8+6)
                                                store word v1 at ..StrTbl:((z-x)*8+6)
                                        end if
                                        store word v2 at ..StrTbl:(z*8+6)
                                end if
                                z = z-x
                        end while
                        y = y+1
                end while
                x = x shr 1
        end while
        repeat count
        load v1 dword from ..StrTbl:((%-1)*8)
 forward
                if ..arg#_id = v1
                label ..arg at $
 common
                load str1 word from ..StrTbl:((%-1)*8+4)
                load v1 word from ..StrTbl:((%-1)*8+6)
                v2=v1 shr 3
                repeat v1 shr 3
                        load v2 qword from ..Strings:(str1+(%-1)*8)
                        dq v2
                end repeat
                repeat v1 and 7
                        load v2 dword from ..Strings:(str1+(v1 and (-8))+%-1)
                        db v2
                end repeat
        end repeat }    

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 25 Mar 2019, 15:10
View user's profile Send private message Send e-mail Reply with quote
rocketsoft



Joined: 26 Jan 2010
Posts: 186
An unique string is called an orphan!
Post 04 Apr 2019, 12:10
View user's profile Send private message Visit poster's website 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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.