[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] More on optimization
From: |
Tvrtko A. Ursulin |
Subject: |
[avr-gcc-list] More on optimization |
Date: |
Thu, 10 Oct 2002 19:41:29 +0200 |
First of all, many thanks to everyone for help with "volatile" issue. Yes, I
now see it is the first question in the FAQ, but until now, I didn't even
know that such a FAQ exists.
So excuse me for asking that, and let me thank everyone once more.
Another thing I was unable to find is the list of all -O options avr-gcc
understands and some details on them. A link woudl be ok.
Then, back to the volatile issue.
Declaring variables volatile really makes the compiler store them after
changing. But I am looking for something more than that and I hope doing
everything in assembler won't be the answer.
Examine this:
volatile uint8_t gval;
DECLARE_TASK(task3);
void task3(void)
{
uint8_t val;
for (;;)
{
cli();
10a: f8 94 cli
gval++;
10c: 80 91 62 00 lds r24, 0x0062
110: 8f 5f subi r24, 0xFF ; 255
112: 80 93 62 00 sts 0x0062, r24
gval--;
116: 80 91 62 00 lds r24, 0x0062
11a: 81 50 subi r24, 0x01 ; 1
11c: 80 93 62 00 sts 0x0062, r24
val = gval;
120: 80 91 62 00 lds r24, 0x0062
sei();
124: 78 94 sei
126: f1 cf rjmp .-30 ; 0x10a
So compiler does lds/sts pair too often? Ok, it is not wrong or a bug, but I
would like to somehow instruct it to behave differently if it is possible.
For my usage, I would like something like this:
cli
lds r24, 0x0060
HEY-MISTER-COMPILER -> although var. at 0x0060 is volatile leave it be until
not explicitly said otherwise
some operations with/on r24...
HEY-MISTER-COMPILER -> i am done with this var, procees
sts 0x0060, r24
sei
etc...
In a way, this would signal the compiler that the entire block surrounded with
HEY-MISTER-COMPILER is atomic eg. no interrupts. So no need to lds/sts more
than once.
Am I doing something terribly wrong or it can be done? :)
Thanks!
avr-gcc-list at http://avr1.org
- [avr-gcc-list] More on optimization,
Tvrtko A. Ursulin <=
- RE: [avr-gcc-list] More on optimization, Dean Ferreyra, 2002/10/11
- Re: [avr-gcc-list] More on optimization, E. Weddington, 2002/10/11
- Re: [avr-gcc-list] More on optimization, Tvrtko A. Ursulin, 2002/10/11
- Re: [avr-gcc-list] More on optimization, E. Weddington, 2002/10/11
- Re: [avr-gcc-list] More on optimization, Theodore A. Roth, 2002/10/11
- Re: [avr-gcc-list] More on optimization, Tvrtko A. Ursulin, 2002/10/23
- Re: [avr-gcc-list] More on optimization, Joerg Wunsch, 2002/10/23
- Re: [avr-gcc-list] More on optimization, Tvrtko A. Ursulin, 2002/10/23