flat assembler
Message board for the users of flat assembler.

Index > Main > Optimal String Alignment?

Author
Thread Post new topic Reply to topic
Big Red



Joined: 25 Feb 2005
Posts: 43
Big Red
Hey folks,

I've defined all of my project's strings with a struc macro so as to easily align them afterward. I've noticed some C compilers do so, but otherwise have no idea what such alignment is best. I don't trust C compilers too much.

I have quite a few hundred strings, and if I paragraph-align them, the DLL grows by 4000 bytes. It's a standard Win32 DLL.

Any recommendations as to what gives best overall performance? Can it be OS-dependent? (i.e., Win2k/XP/NT vs Win9x)


---------

Code:

DSTR_STRING_ALIGNMENT = whatever

struc dstr [data] {
        common

        if (DSTR_STRING_ALIGNMENT > 0)
          align DSTR_STRING_ALIGNMENT
        end if

        . db data
        .size = $ - .
        db    0
      }      
  
    
Post 30 Dec 2006, 05:50
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
i'd say that there is no need to align your strings at all.
Post 31 Dec 2006, 09:14
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
donkey7



Joined: 31 Jan 2005
Posts: 127
Location: Poland, Malopolska
donkey7
i think alignment is useful when you are using widechar format (ie. aligning to word boundary).
Post 31 Dec 2006, 12:06
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
donkey7: sure, i forgot that. What i meant is that natural alignment is enough (bytes unaligned, words aligned to 2, dwords to 4 etc). 16byte alignment makes sense with code, and 4096 only when the speed gain is worth of memory waste
Post 31 Dec 2006, 12:18
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Big Red



Joined: 25 Feb 2005
Posts: 43
Big Red
Alright then, thank you. I'll take your word for it and leave them unaligned.
Post 03 Jan 2007, 04:32
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
If that you have long zero-terminated strings and use one of the dword-scanning strlen algorithms, 4-byte aligning the strings is a good idea. Of course an even better idea is to store string-lengths when necessary instead of doing a strlen, but that's not always possible.
Post 03 Jan 2007, 06:30
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 cannot attach files in this forum
You can download files in this forum


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

Website powered by rwasa.