avr-gcc

Powiedzcie czemu avr-gcc robi pewna rzecz -

Robię pre-dekrementacje i testuje czy doszlo do zera, i czasem lubie sobie sprawdzic jak wyglada kod po kompilacji...

alarms.lst

251:alarms.c **** if (--timeouts.AL == 0) { .LM74: lds r24,timeouts+5 ; timeouts.AL, timeouts.AL subi r24,lo8(-(-1)) ; timeouts.AL, sts timeouts+5,r24 ; timeouts.AL, timeouts.AL lds r24,timeouts+5 ; timeouts.AL, timeouts.AL ^^^^^^^^^^ <--- po co robi ladowanie spowrotem do rejestru, skoro ta sama wartosc ciagle tam jest...? tst r24 ; timeouts.AL

gdzie timeouts jest strukturą zdefiniowana globalnie

Nie zeby mi to jakos specjalnie przeszkadzalo, ale chcialbym wiedziec czy w gcc jest jakas metoda na optymalizacje tego zjawiska, 4 bajty przy kazdym takim tescie moznaby zaoszczedzic...

; GNU C version 3.4.3 (avr) ; compiled by GNU C version 3.3 20030304 (Apple Computer, Inc. build

1495). ; GGC heuristics: --param ggc-min-expand=30 --param ggc-min- heapsize=4096 ; options passed: -fpreprocessed -mmcu=atmega16 -auxbase-strip -g - Os ; -Wall -Wstrict-prototypes -std=gnu99 -funsigned-char ; -funsigned-bitfields -fpack-struct -fshort-enums -fverbose-asm ; options enabled: -feliminate-unused-debug-types -fdefer-pop ; -fomit-frame-pointer -foptimize-sibling-calls -funit-at-a-time ; -fcse-follow-jumps -fcse-skip-blocks -fexpensive-optimizations ; -fthread-jumps -fstrength-reduce -fpeephole -fforce-mem -ffunction- cse ; -fkeep-static-consts -fcaller-saves -freg-struct-return -fgcse ; -fgcse-lm -fgcse-sm -fgcse-las -floop-optimize -fcrossjumping ; -fif-conversion -fif-conversion2 -frerun-cse-after-loop ; -frerun-loop-opt -fdelete-null-pointer-checks -fsched-interblock ; -fsched-spec -fsched-stalled-insns -fsched-stalled-insns-dep ; -fbranch-count-reg -freorder-functions -fcprop-registers -fcommon ; -fverbose-asm -fregmove -foptimize-register-move -fpack-struct ; -fargument-alias -fstrict-aliasing -fmerge-constants ; -fzero-initialized-in-bss -fident -fpeephole2
Reply to
DJ
Loading thread data ...

DJ pisze:

Czy pole AL nie jest przypadkiem zadeklarowanie jako volatile? Pokaż kilka dalszych instrukcji programu.

Reply to
Łukasz Zemła

Masz racje, to przez volatile. Dzięki.

Reply to
DJ

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.