реклама на сайте
подробности

 
 
> Как можно уменьшить скомпилированный исходник?
The Fresh
сообщение Apr 15 2007, 07:29
Сообщение #1


Частый гость
**

Группа: Новичок
Сообщений: 146
Регистрация: 3-12-06
Пользователь №: 23 071



Есть исходник, после компиляции забивает память практически полностью 2K AT90S2313. Необходимо дописать к нему приблизительно 1/5 его кода. Я вижу 2 варианта, либо переносить некоторые функции на чистый ASM, либо использовать какой-нибудь продвинутый компилятор. Сейчас использую WinAVR 20050214, использовал 20070122, но код получался больше. Изменял настройки
make файла, но сколь ощутимого результата не увидел!

# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = 2
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
The Fresh
сообщение Apr 15 2007, 12:23
Сообщение #2


Частый гость
**

Группа: Новичок
Сообщений: 146
Регистрация: 3-12-06
Пользователь №: 23 071



Вот make file(прикрепил) и ключи, с плавающей запятой не работаю,
set -e; avr-gcc -MM -mmcu=at90s2313 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst main.c \
| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > main.d; \
[ -s main.d ] || rm -f main.d

Compiling: main.c
avr-gcc -c -mmcu=at90s2313 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst main.c -o main.o

Linking: main.elf
avr-gcc -mmcu=at90s2313 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.o main.o --output main.elf -Wl,-Map=main.map,--cref -lm

Creating load file for Flash: main.hex
avr-objcopy -O ihex -R .eeprom main.elf main.hex

Creating load file for EEPROM: main.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O ihex main.elf main.eep

Creating Extended Listing: main.lss
avr-objdump -h -S main.elf > main.lss

Creating Symbol Table: main.sym
avr-nm -n main.elf > main.sym


Кстати вот pdf есть по этому поводу, но куда что пока не очень ориентируюсь.
Eighteen Hints to Reduce Code Size
1. Compile with full size optimization.
2. Use local variables whenever possible.
3. Use the smallest applicable data type. Use unsigned if applicable.
4. If a non-local variable is only referenced within one function, it should be
declared static.
5. Collect non-local data in structures whenever natural. This increases the possibility
of indirect addressing without pointer reload.
6. Use pointers with offset or declare structures to access memory mapped I/O.
7. Use for(;;) { } for eternal loops.
8. Use do { } while(expression) if applicable.
9. Use descending loop counters and pre-decrement if applicable.
10. Access I/O memory directly (i.e., do not use pointers).
11. Declare main as C_task if not called from anywhere in the program.
12. Use macros instead of functions for tasks that generates less than 2-3 lines
assembly code.
13. Reduce the size of the Interrupt Vector segment (INTVEC) to what is actually
needed by the application. Alternatively, concatenate all the CODE segments
into one declaration and it will be done automatically.
14. Code reuse is intra-modular. Collect several functions in one module (i.e., in one
file) to increase code reuse factor.
15. In some cases, full speed optimization results in lower code size than full size
optimization. Compile on a module by module basis to investigate what gives the
best result.
16. Optimize C_startup to not initialize unused segments (i.e., IDATA0 or IDATA1 if all
variables are tiny or small).
17. If possible, avoid calling functions from inside the interrupt routine.
18. Use the smallest possible memory model.
Five Hints to Reduce
RAM Requirements
1. All constants and literals should be placed in Flash by using the Flash keyword.
2. Avoid using global variables if the variables are local in nature. This also saves
code space. Local variables are allocated from the stack dynamically and are
removed when the function goes out of scope.
3. If using large functions with variables with a limited lifetime within the function,
the use of subscopes can be beneficial.
4. Get good estimates of the sizes of the software Stack and return Stack (Linker
File).
5. Do not waste space for the IDATA0 and UDATA0 segments unless you are using
tiny variables (Linker File).
Прикрепленные файлы
Прикрепленный файл  makefile.txt ( 10.02 килобайт ) Кол-во скачиваний: 51
 
Go to the top of the page
 
+Quote Post

Сообщений в этой теме
- The Fresh   Как можно уменьшить скомпилированный исходник?   Apr 15 2007, 07:29
- - defunct   -Os - оптимизирует сильнее всего. Можно попробоват...   Apr 15 2007, 08:07
- - beer_warrior   ЦитатаСейчас использую WinAVR 20050214, использова...   Apr 15 2007, 09:17
- - aesok   Цитата(The Fresh @ Apr 15 2007, 07:29) Ес...   Apr 15 2007, 10:09
- - aesok   Еще Вам может помочь уменьшить размер кода ключ ко...   Apr 15 2007, 11:56
- - Amper25   Не знаю как в вашем компиллере, но когда-то давно ...   Apr 15 2007, 12:17
|- - Snaky   Цитата(Amper25 @ Apr 15 2007, 16:17) Не з...   Apr 16 2007, 06:25
|- - aesok   Я не увидел никакоко криминала в макефайле. Поэксп...   Apr 15 2007, 12:49
- - The Fresh   Мой взор все больше ориентируется на МК с большим ...   Apr 15 2007, 12:53
|- - aesok   Цитата(The Fresh @ Apr 15 2007, 12:53) Мо...   Apr 15 2007, 13:17
- - The Fresh   Немного отвоевал, есть константы объемные наверное...   Apr 15 2007, 13:38
- - prm   К сведению, был у меня проект на IAR для AT90S2313...   Apr 16 2007, 10:13
- - Snaky   Цитата(prm @ Apr 16 2007, 14:13) Затем пе...   Apr 16 2007, 11:37
- - haker_fox   Цитата(Snaky @ Apr 16 2007, 17:37) Хммм, ...   Apr 18 2007, 07:01
- - prm   Написал на CodeVision около 6 проектов, НИКАКИХ ГЛ...   Apr 18 2007, 09:48


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 19th August 2025 - 22:43
Рейтинг@Mail.ru


Страница сгенерированна за 0.0136 секунд с 7
ELECTRONIX ©2004-2016