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 30 Dec 2006, 05:50
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 31 Dec 2006, 09:14
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 31 Dec 2006, 12:06
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 31 Dec 2006, 12:18
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 03 Jan 2007, 04:32
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: 3175
Location: Denmark
f0dder 03 Jan 2007, 06:30
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.