Alignment Quickie

In the following little-endian ordered data snippet, you will find an example of the most common data types. The actual hex value is on the right and the byte arrangement in memory is on the left.

 0000 12            Ape    db       12h         ; (byte) 0001 34 12         Bat    dw       1234h       ; (word) 0003 78 56 34 12   Cat    dd       12345678h   ; (dword) 0007 F0 DE BC 9A      78 56 34 12   Dog    dq       123456789ABCDEF0h ; (qword) 

Note that the data should be properly aligned to their data type, so a slight rearrangement of the previous data snippet is in order. You should note the previous odd addressing versus the following aligned addressing:

 0000 f0 DE BC 9A      78 56 34 12   Dog    dq    123456789ABCDEF0h ; (qword) 0008 78 56 34 12   Cat    dd    12345678h  ; (dword) 000C 34 12         Bat    dw    1234h      ; (word) 000E 12            Ape    db    12h        ; (byte) 

You will note by the base address on the far left that the data has been reordered to ensure that all elements of a data type are properly aligned for their data type. Eight-byte values are aligned on 8-byte boundaries, 4-byte on 4-byte boundaries, etc.

32.64-Bit 80X86 Assembly Language Architecture
32/64-Bit 80x86 Assembly Language Architecture
ISBN: 1598220020
EAN: 2147483647
Year: 2003
Pages: 191

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: