ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Четверг
18 апреля
940813 Топик полностью
MBedder, терминатор (16.08.2019 16:08 - 16:18, просмотров: 138) ответил Mefod на Есть ли способ расположить переменную по определенному адресу в RAM для GCC? Без правки linker файла.
Вот как это делает Microchip в своих GCC-based компиляторах XC (мануал приложен): 2.5.2 Absolute Addressing Variables and functions can be placed at an absolute address by using the __at() construct. Stack-based (auto and parameter) variables cannot use the __at() specifier. 2.5.2.1 EXAMPLE The following example shows two variables and a function being made absolute. int scanMode __at(0x200); const char keys[] __at(124) = { ’r’, ’s’, ’u’, ’d’}; __at(0x1000) int modify(int x) { return x * 2 + 3; } 2.5.2.2 DIFFERENCES The 8-bit compilers have used an @ symbol to specify an absolute address. The 16- and 32-bit compilers have used the address attribute to specify an object’s address. ... 3.4.3.1 HOW DO I POSITION VARIABLES OR FUNCTIONS AT AN ADDRESS I NOMINATE? Nudging the tool chain to allocate variables or functions in specific areas of memory can make it harder for the linker to do its job. Tools are provided to solve problems that may exist, but they should always be used carefully. For example, instead of fixing an object at a specific address (using the address attribute or the __at construct), it may be sufficient to group variables together using the section attribute.