ARM.SoC.Architecture

ARM.SoC.Architecture

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: struction set, in common with many other RISC processors, is most efficient at loading and storing data items when they are appropriately aligned in Use of memory 183 Figure 6.14 Example stack behaviour. memory. A byte access can be made to any byte address with equal efficiency, but storing a word to a non-word-aligned address is very inefficient, taking up to seven ARM instructions and requiring temporary work registers. Data alignment Therefore the ARM C compiler generally aligns data items on appropriate boundaries: Bytes are stored at any byte address. Half-words are stored at even byte addresses. Words are stored on four-byte boundaries. Where several data items of different types are declared at the same time, the compiler will introduce padding where necessary to achieve this alignment: struct SI {char c; int x; short s;} examplel; This structure will occupy three words of memory as shown in Figure 6.15 on page 184. (Note that structures are also padded to end on a word boundary.) Arrays are laid out in memory by repeating the appropriate basic data item, obeying the alignment rules for each item. Memory efficiency Given the data alignment rules outlined above, the programmer can help the compiler to minimize memory wastage by organizing structures appropriately. A structure with the same contents as above, but reordered as below, occupies only two memory words instead of the original three: 184 Architectural Support for High-Level Languages Figure 6.15 An example of normal struct memory allocation. struct S2 {char c; short s; int x;} example2; This will result in the memory occupancy illustrated in Figure 6.16. In general, ordering structure elements so that types smaller than a word can be grouped within a word will minimize the amount of padding that the compiler has to insert to maintain efficient alignment. Figure 6.16 An example of more efficient struct memory allocation. Packed structs Sometimes it is necessary to exchange data with other computers that follow...
View Full Document

This document was uploaded on 10/30/2011 for the course CSE 378 380 at SUNY Buffalo.

Ask a homework question - tutors are online