User guide
The benefits of using a scatter description file are:
• All the (target-specific) absolute addresses chosen for your devices, code, and data are located in one file and
maintenance is simplified.
• If you decide to change your memory map (for example if peripherals are moved), you do not have to rebuild
your entire project but only to re-link the existing objects.
For a description of scatter loading, see the Linker and Utilities Guide
. For a description of how to specify code and
data sections from C and C++, see the section on pragmas in the Compiler and Libraries Guide
.
6.9.5 Code efficiency
The ARM compiler normally uses a base register plus the immediate offset field available in the load/store instruction
to compile struct member or specific array element access.
The ARM instruction set, LDR/STR word/byte have a 4Kbyte range, but LDRH/STRH has a smaller immediate offset of
256bytes.
The Thumb instruction set is much more restricted in addressing range than the ARM instructions. The Thumb
LDR/STR has a range of 32 words, LDRH/STRH has a range of 32 halfwords, LDRB/STRB has a range of 32 bytes.
You must group related peripheral registers near to each other if possible. The compiler will generally do a good job
of minimizing the number of instructions required to access the array elements or structure members by using base
registers.
There is a choice between one big C struct/array for the whole I/O space and smaller per-peripheral structs. There is
not much difference in efficiency. The big struct might be a benefit if you are using ARM code where a base pointer
can have a 4Kbyte range (for word/byte access) and the entire I/O space is less than 4KB. Smaller structs for each
peripheral are more maintainable.
Writing Code for ROM
Copyright ?1999 2001 ARM Limited 6-27