word alighnment

This is a discussion on word alighnment within the C Programming forums, part of the General Programming Boards category; I know word ailgnment alighns things but why is it just to make things run quicker, ie quicker access to ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    41

    word alighnment

    I know word ailgnment alighns things but why is it just to make things run quicker, ie quicker access to the data members.

    thanks for the help.

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    41
    THanks salem but... is that it or is there more to it, oh and why
    Last edited by anthonye; 07-09-2003 at 12:07 PM.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    Yup, that's pretty much it. Assuming your using an Intel-based PC, you'll find that the Intel CPU is 32-bit, and has 32-bit registers and therefore likes doing things in 32 bits. So, it's faster to play with memory like that also - eg. locations 0, 4, 8, etc. AMD/VIA/etc are the same.

    Windows by default aligns things on a quadword boundary for future compatibility, but most compilers stick to either word or dword alignment.

    Now, 8-bit processors like the PIC Microcontrollers, don't care about alignment, but that's because they only access memory in 8-bit mode, not the 32-bit mode of the Intel (for example).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 02:22 PM
  2. please help with binary tree, urgent.
    By slickestting in forum C Programming
    Replies: 2
    Last Post: 07-22-2007, 08:55 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 06:49 PM
  4. Wrong Output
    By egomaster69 in forum C Programming
    Replies: 7
    Last Post: 01-28-2005, 06:44 PM
  5. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21