ðÒÉ×ÅÔ, Alex!
03 ÍÁÒÔÁ 2006 02:14, Alex Mogilnikov ÐÉÓÁÌ Andrey Samarin:
AS>> çÒÁÖÄÁÎÅ, ÐÌÚ, ÐÏÄÓËÁÖÉÔÅ ÐÏ ÓÁÂÖÕ: ËÁË ÓÄÅÌÁÔØ ÔÁË, ÞÔÏ ÂÙ AS>> ÎÅÉÓÐÏÌØÚÕÅÍÙÅ (ÎÏ ÐÒÉÓÕÔÓÔ×ÕÀÝÉÅ × ÉÓÈÏÄÎÉËÅ) ÎÅ ËÏÍÐÉÌÉÌÉÓØ É AS>> ÎÅ AS>> ×ÌÅÚÁÌÉ × ÇÅÎÅÒÉÒÕÅÍÙÊ hex. AM> -funit-at-a-time. óÐÁÓÉÂÏ, ÎÏ ÎÅ ÐÏÌÕÞÉÌÏÓØ. :(
÷ ÏÂÝÅÍ, ×ÏÔ ×Ù×ÏÄ objdump:
=== Cut ===
Test2.o: file format elf32-avr
Disassembly of section .text:
00000000 <funkt>: //#include"timer.h"
int funkt(int k) {
0: cf 93 push r28
2: df 93 push r29
4: cd b7 in r28, 0x3d ; 61
6: de b7 in r29, 0x3e ; 62
8: 22 97 sbiw r28, 0x02 ; 2 a: 0f b6 in r0, 0x3f ; 63 c: f8 94 cli e: de bf out 0x3e, r29 ; 62
10: 0f be out 0x3f, r0 ; 63
12: cd bf out 0x3d, r28 ; 61
14: 9a 83 std Y+2, r25 ; 0x02
16: 89 83 std Y+1, r24 ; 0x01 return k*k;
18: 29 81 ldd r18, Y+1 ; 0x01
1a: 3a 81 ldd r19, Y+2 ; 0x02
1c: 89 81 ldd r24, Y+1 ; 0x01
1e: 9a 81 ldd r25, Y+2 ; 0x02
20: 28 9f mul r18, r24
22: a0 01 movw r20, r0
24: 29 9f mul r18, r25
26: 50 0d add r21, r0
28: 38 9f mul r19, r24
2a: 50 0d add r21, r0
2c: 11 24 eor r1, r1
2e: ca 01 movw r24, r20
30: 22 96 adiw r28, 0x02 ; 2
32: 0f b6 in r0, 0x3f ; 63
34: f8 94 cli
36: de bf out 0x3e, r29 ; 62
38: 0f be out 0x3f, r0 ; 63
3a: cd bf out 0x3d, r28 ; 61
3c: df 91 pop r29
3e: cf 91 pop r28
40: 08 95 ret
00000042 <main>:
}
int main (void) {
42: c0 e0 ldi r28, 0x00 ; 0
44: d0 e0 ldi r29, 0x00 ; 0
46: de bf out 0x3e, r29 ; 62
48: cd bf out 0x3d, r28 ; 61 // lcdInit(); int i,j; i=1;
4a: 81 e0 ldi r24, 0x01 ; 1
4c: 90 e0 ldi r25, 0x00 ; 0
4e: 9a 83 std Y+2, r25 ; 0x02
50: 89 83 std Y+1, r24 ; 0x01 j=++i;
52: 89 81 ldd r24, Y+1 ; 0x01
54: 9a 81 ldd r25, Y+2 ; 0x02
56: 01 96 adiw r24, 0x01 ; 1
58: 9a 83 std Y+2, r25 ; 0x02
5a: 89 83 std Y+1, r24 ; 0x01
5c: 9c 83 std Y+4, r25 ; 0x04
5e: 8b 83 std Y+3, r24 ; 0x03 // j=funkt(i);
DDRB = 0xFF;
60: 8f ef ldi r24, 0xFF ; 255
62: 80 93 37 00 sts 0x0037, r24 PORTB |= 1<<2;
66: 80 91 38 00 lds r24, 0x0038
6a: 84 60 ori r24, 0x04 ; 4
6c: 80 93 38 00 sts 0x0038, r24 PORTB = (char)j;
70: 8b 81 ldd r24, Y+3 ; 0x03
72: 80 93 38 00 sts 0x0038, r24
return 1;
76: 81 e0 ldi r24, 0x01 ; 1
78: 90 e0 ldi r25, 0x00 ; 0
7a: 00 c0 rjmp .+0 ; 0x7c <Letext>
=== Cut === ëÁË ×ÉÄÎÏ ÉÚ ÄÁÍÐÁ, funkt ÚÁËÏÍÍÅÎÔÉÒÏ×ÁÎÁ. HÏ × ÏÂÖÅËÔÎÉËÅ ţ ËÏÄ ÐÒÉÓÕÔÓÔ×ÕÅÔ. é ËÁË ëÒÁÓÎÏÅ ðÅÒÅÈÏÄÑÝÅÅ úÎÁÍÑ ÐÅÒÅÈÏÄÉÔ × target, ÒÁÚÄÕ×ÁÑ ËÏÄ. ëÓÔÁÔÉ, ÚÄÅÓØ ÐÏËÁÚÁÎ ÄÁÍÐ ÄÌÑ ÕÒÏ×ÎÑ ÏÐÔÉÍÉÚÁÃÉÉ 0, ÎÏ ÐÅÒÅÈÏÄ Ë ÌÀÂÏÍÕ ÄÒÕÇÏÍÕ ÎÉÞÅÇÏ ÎÅ ÄÁÅÔ (ÐÏ ÄÏËÅ, ÏÐÃÉÑ -funit-at-a-time ÐÒÉÓÕÔÓÔ×ÕÅÔ ÐÒÉ ÕÒÏ×ÎÅ ÏÐÔÉÍÉÚÁÃÉÉ -O2). éÓÞÅÚÁÀÔ prologue É epilogue, ÎÏ ÓÁÍ ËÏÄ ÎÅÉÓÐÏÌØÚÕÅÍÏÊ ÆÕÎËÃÉÉ - ÖÉ×ÅÅ ×ÓÅÈ ÖÉ×ÙÈ. óÏÂÓÔ×ÅÎÎÏ, ÜÔÕ ÈÒÅÎØ Ñ ÚÁÍÅÔÉÌ ÐÏÓÌÅ ÐÏÄËÌÀÞÅÎÉÑ Ë ÔÅÓÔÏ×ÏÍÕ ÐÒÏÅËÔÕ ÍÏÄÕÌÑ ÄÌÑ ÒÁÂÏÔÙ Ó öëé ÉÚ AVRlib. ÷ ÒÅÚÕÌØÔÁÔÅ, ÎÁ ×ÙÈÏÄÅ ËÏÄ ÐÏÌÕÞÉÌÓÑ ÎÅÎÏÒÍÁÌØÎÏ ÂÏÌØÛÉÍ. äÁÌØÎÅÊÛÅÅ ÒÁÚÂÉÒÁÔÅÌØÓÔ×Ï ÐÏËÁÚÁÌÏ, ÞÔÏ × ÎÅÍ ÓÉÄÅÌÉ ×ÓÅ ÆÕÎËÃÉÉ ÉÚ lcd.c É timer.c. %)
ôÅÐÅÒØ, ÄÌÑ ÑÓÎÏÓÔÉ × ÒÅÖÉÍÁÈ ËÏÍÐÉÌÑÃÉÉ, ×Ù×ÏÄ GCC:
=== Cut === C:\WinAVR\MyProgram\Test2>make
-------- begin -------- avr-gcc (GCC) 3.4.5 Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiling: Test2.c avr-gcc -c -mmcu=atmega8 -I. -gstabs -DF_CPU=8000000UL -O0 -funsigned-char
-fun signed-bitfields -fpack-struct -fshort-enums -funit-at-a-time -v -Wall
-Wstrict- prototypes -Wa,-adhlns=Test2.lst -IC:\winavr\AVRlib -std=gnu99 -MD -MP -MF .dep/ Test2.o.d Test2.c -o Test2.o Reading specs from C:/WinAVR/lib/gcc/avr/3.4.5/specs Configured with: ../gcc-3.4.5/configure --prefix=/c/WinAVR --target=avr
--enable
-languages=c,c++ --with-dwarf2 --enable-win32-registry=WinAVR Thread model: single gcc version 3.4.5 C:/WinAVR/libexec/gcc/avr/3.4.5/cc1.exe -quiet -v -I. -IC:\winavr\AVRlib
-ipref ix C:\WINAVR\BIN/../lib/gcc/avr/3.4.5/ -MD Test2.d -MF .dep/Test2.o.d -MP -MQ Te st2.o -DF_CPU=8000000UL Test2.c -quiet -dumpbase Test2.c -mmcu=atmega8
-auxbase- strip Test2.o -gstabs -O0 -Wall -Wstrict-prototypes -std=gnu99 -version
-funsign ed-char -funsigned-bitfields -fpack-struct -fshort-enums -funit-at-a-time -o C:\ TEMP/ccF6Tigb.s ignoring nonexistent directory "C:/WinAVR/avr/sys-include" #include "..." search starts here: #include <...> search starts here: . C:\winavr\AVRlib C:\WINAVR\BIN/../lib/gcc/avr/3.4.5/include C:/WinAVR/lib/gcc/avr/3.4.5/include C:/WinAVR/avr/include End of search list. GNU C version 3.4.5 (avr) compiled by GNU C version 3.4.2 (mingw-special). GGC heuristics: --param ggc-min-expand=38 --param ggc-min-heapsize=16307 C:/WINAVR/BIN/../lib/gcc/avr/3.4.5/../../../../avr/bin/as.exe
--traditional-for mat -mmcu=atmega8 -adhlns=Test2.lst -o Test2.o C:\TEMP/ccF6Tigb.s
Linking: Test2.elf avr-gcc -mmcu=atmega8 -I. -gstabs -DF_CPU=8000000UL -O0 -funsigned-char
-funsig ned-bitfields -fpack-struct -fshort-enums -funit-at-a-time -v -Wall
-Wstrict-pro totypes -Wa,-adhlns=Test2.o -IC:\winavr\AVRlib -std=gnu99 -MD -MP -MF .dep/Test2 .elf.d Test2.o --output Test2.elf -Wl,-Map=Test2.map,--cref -lm Reading specs from C:/WinAVR/lib/gcc/avr/3.4.5/specs Configured with: ../gcc-3.4.5/configure --prefix=/c/WinAVR --target=avr
--enable
-languages=c,c++ --with-dwarf2 --enable-win32-registry=WinAVR Thread model: single gcc version 3.4.5 C:/WINAVR/BIN/../lib/gcc/avr/3.4.5/../../../../avr/bin/ld.exe -m avr4 -o Test2. elf C:/WINAVR/BIN/../lib/gcc/avr/3.4.5/../../../../avr/lib/avr4/crtm8.o
-LC:/Win AVR/lib/gcc/avr/3.4.5/avr4 -LC:/WinAVR/lib/gcc/avr/3.4.5 -LC:/WinAVR/lib/gcc
-Lc :/WinAVR/lib/gcc/avr/3.4.5/avr4 -Lc:/WinAVR/lib/gcc/avr/3.4.5
-LC:/WINAVR/BIN/.. /lib/gcc/avr/3.4.5/../../../../avr/lib/avr4
-LC:/WINAVR/BIN/../lib/gcc/avr/3.4.5 /../../../../avr/lib -Lc:/WinAVR/lib/gcc/avr/3.4.5/../../../../avr/lib/avr4
-Lc: /WinAVR/lib/gcc/avr/3.4.5/../../../../avr/lib Test2.o -Map=Test2.map --cref -lm
-lgcc -lc -lgcc
Creating load file for Flash: Test2.hex avr-objcopy -O ihex -R .eeprom Test2.elf Test2.hex
Creating load file for EEPROM: Test2.eep avr-objcopy -j .eeprom --set-section-flags .eeprom=alloc,load \
--change-section-lma .eeprom=0 -O ihex Test2.elf Test2.eep
Creating Extended Listing: Test2.lss avr-objdump -h -S Test2.elf > Test2.lss
Creating Symbol Table: Test2.sym avr-nm -n Test2.elf > Test2.sym
Size after: AVR Memory Usage
---------------- Device: atmega8
Program: 218 bytes (2.7% Full) (.text + .data + .bootloader)
Data: 0 bytes (0.0% Full) (.data + .bss + .noinit)
-------- end --------
=== Cut === ë ÓÏÖÁÌÅÎÉÀ, ËÏÐÉÒÏ×ÁÌ Ó ËÏÎÓÏÌÉ, ÐÏÜÔÏÍÕ ×Ù×ÏÄ ÎÅÍÎÏÇÏ ÐÏËÏÒÅÖÉÌÓÑ (ÐÏÑ×ÉÌÉÓØ ÐÅÒÅ×ÏÄÙ ÓÔÒÏËÉ, ÔÁÍ ÇÄÅ ÉÈ ÂÙÔØ ÎÅ ÄÏÌÖÎÏ).
AS>> úù: õ×ÅÒÅÎ, ÞÔÏ ÕÖÅ ÏÂÓÕÖÄÁÌÏÓØ, AM> HÅ ÐÏÍÎÀ ÔÁËÏÇÏ. HÅÕÖÅÌÉ ÎÉËÔÏ ÎÅ ÓÔÁÌËÉ×ÁÌÓÑ Ó ÔÁËÉÍÉ ÐÒÏÂÌÅÍÁÍÉ? éÌÉ ×ÓÅ ÒÅÛÁÌÉ ÉÈ "ÐÏ ÔÉÈÏÍÕ"?
åÝÅ ÒÁÚ ÓÐÁÓÉÂÏ ÚÁ ÏÔ×ÅÔ.
ó Õ×ÁÖÅÎÉÅÍ, áÎÄÒÅÊ áëá èÏÍÉÞ, áëá UR3LTG. ... õÓÌÙÛÁ× ÌÁÊ ÄÅÍÏÎÁ, ÞÁÓÏ×ÏÊ ÄÕÂÌÉÒÕÅÔ ÅÇÏ ÇÏÌÏÓÏÍ.