--- On Sat, 7/16/11, Albert-Jan Roskam<fo...@yahoo.com>  wrote:

From: Albert-Jan Roskam<fo...@yahoo.com>
Subject: [Tutor] what is 'doubleword alignment'?
To: "Python Mailing List"<tutor@python.org>
Date: Saturday, July 16, 2011, 8:23 PM

Hello,

What is 'doubleword alignment'? It is used in the following sentence: "Fill up the 
buffer with the correctly encoded numeric and string values, taking care of blank padding 
and doubleword alignment."

I know that the buffer is comprised of variables of 8-bytes, or multiples 
thereof, each. Numeric variables are 8 bytes, char vars are at least 8 bytes. 
For example, a 10-byte value is 'ceiled' to 18 bytes. This is done with padding 
(spaces, I think). But the aligment part...?

TIA

Cheers!!

Albert-Jan

On 07/16/2011 04:53 PM, Albert-Jan Roskam wrote:
Got it already, I think. The word boundary of one chunk of information (in my 
case 8 bytes) is aligned in the computer's memory such that the boundary's 
address is a power of two.

But correct me if I'm wrong ;-)

Cheers!!

Albert-Jan




(please put your new text AFTER the text you're quoting. I moved it in this case, but couldn't also get the indentation right)

Not quite. Doubleword alignment is alignment on an 8byte boundary. The address of such a boundary will be a multiple of 8, not a power of two.

So in your earlier example, the 10 byte string will be padded to 16, not 18 bytes. If the buffer starts aligned, then each such element will also be aligned.


--

DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to