Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 04 Mar 2001 06:06:18 +0100
From:      Roelof Osinga <roelof@eboa.com>
To:        Edward <edward_gess@hotmail.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: programming
Message-ID:  <3AA1CD4A.DE2F78B7@eboa.com>
References:  <3A9EACC2.8AA6D430@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Edward wrote:
> 
>         Hello all,
> 
>     I have one very important question: What does it
> mean align ??? In a word, when doing align in assembler programs I do
> 
>     understand it, it is usable to get a quickest access
> to that (aligned) part of memory where the variable is loaded, but I can't
> 
>     understand how not doing align can affect the program??????
> 
>     Please help me to get more information on such questions...
> I like assembler, where can I get more information???


Since this went unanswered... Alas... Let me give it a shot...

One can always shoot me if I get it wrong ;).

After all... They do shoot horses, don't they?


The basic principle is speed. You've got a process, any processor,
which accesses words, any words. Whatever the word size in question
that is the quickest means of access. Worse still, the quickest
means of access is on word boundaries.

So suppose you've got a modern 64 bit machine. Say, the promised
Merced architecture. A prototype or something ;). Then a word would
be 64 bits in a row. Lets name that a QWORD, for no reason other
than that a naming is convenient.

Now this Merced of yours would access memory a QWORD at a time. You
need a BYTE? Fine. You get a QWORD.

Now, depending on the smarts of the processor in question the
manure hits the whirling processor cooling device when you request,
say, the fourth BYTE.

There was a time - and I'm not sure what the current status quo,
not to be confused with the Canadian Rock Band :), is - that this
went very slowly indeed. First the processor got the very first
QWORD, then it got processed by a barrel shifter if you were lucky,
next the result got put onto the bus.

However it might be, the bottom line was that it was fastest by
any measure to ask for stuff that was aligned on a xWORD boundary.
Be the 6 bits, 7 bits, 8 bits or even n bits words.

Again, today this situation should'a be much improved.

If you want to read more about this I would like to suggest
Michael Abrash's The Zen of Assembly Language. Even if he pronounces
Assembly the wrong way <g,d&r>

For the record. I am afraid I choose the example wrongly. That
having been said, at this time of the morning it would strain
me too much to seriously consider, let alone calc, which BYTE
would possess the proper number quantaty so as to be the just
right example. Use your imagination ;).

Roelof

-- 
-----------------------------------------------------------------------
EBOAź                                        web. http://EBOA.com/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3AA1CD4A.DE2F78B7>