Compilers Alignment Alex Aiken Alignment Most modern machines are - - PowerPoint PPT Presentation

compilers
SMART_READER_LITE
LIVE PREVIEW

Compilers Alignment Alex Aiken Alignment Most modern machines are - - PowerPoint PPT Presentation

Compilers Alignment Alex Aiken Alignment Most modern machines are 32 or 64 bit 8 bits in a byte 4 or 8 bytes in a word Machines are either byte or word addressable Alex Aiken Alignment Data is word aligned if it begins at a


slide-1
SLIDE 1

Alex Aiken

Compilers

Alignment

slide-2
SLIDE 2

Alex Aiken

Alignment

  • Most modern machines are 32 or 64 bit

– 8 bits in a byte – 4 or 8 bytes in a word – Machines are either byte or word addressable

slide-3
SLIDE 3

Alex Aiken

Alignment

  • Data is word aligned if it begins at a word boundary
  • Most machines have some alignment restrictions

– Or performance penalties for poor alignment

slide-4
SLIDE 4

Alex Aiken

Alignment

  • Example: A string

“Hello” Takes 5 characters (without a terminating \0)

  • To word align next word, add 3 “padding” characters to

the string

  • The padding is not part of the string, it’s just unused

memory