[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is fault
From: |
anonymous |
Subject: |
[avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty |
Date: |
Fri, 23 Sep 2005 03:07:20 +0000 |
User-agent: |
|
Follow-up Comment #2, bug #14616 (project avr-libc):
This addition will worsen quality of a code. Look an example:
int acc;
int volatile val;
void foo1 (void)
{
unsigned char i;
for (i = 10; i; i--) {
asm volatile ("cli");
acc += val;
asm volatile ("sei");
}
}
void foo2 (void)
{
unsigned char i;
for (i = 10; i; i--) {
asm volatile ("cli");
acc += val;
asm volatile ("sei" ::: "memory");
}
}
In function 'foo1' the compiler has born reading (and record) a variable
'acc' for frameworks of a cycle:
...
lds r18,acc
lds r19,(acc)+1
.L6:
/* #APP */
cli
/* #NOAPP */
lds r24,val
lds r25,(val)+1
add r18,r24
adc r19,r25
/* #APP */
sei
/* #NOAPP */
subi r20,lo8(-(-1))
brne .L6
sts (acc)+1,r19
sts acc,r18
In function 'foo2' reading/writing of a variable 'acc' is carried out on
everyone itteration:
...
.L15:
/* #APP */
cli
/* #NOAPP */
lds r24,acc
lds r25,(acc)+1
lds r18,val
lds r19,(val)+1
add r24,r18
adc r25,r19
sts (acc)+1,r25
sts acc,r24
/* #APP */
sei
/* #NOAPP */
subi r20,lo8(-(-1))
brne .L15
...
May be, if necessary it is better to add 'volatile' in
definition of a concrete variable, than to endow speed always?
Dmitry.
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?func=detailitem&item_id=14616>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
- [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty, anonymous, 2005/09/22
- [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty, anonymous, 2005/09/22
- [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty,
anonymous <=
- [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty, anonymous, 2005/09/23
- [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty, anonymous, 2005/09/23
- [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty, anonymous, 2005/09/26
- Re: [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty, Joerg Wunsch, 2005/09/26
- Re: [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty, Russell Shaw, 2005/09/26
- Re: [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty, Joerg Wunsch, 2005/09/27
- Re: [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty, Dmitry K., 2005/09/26
- Re: [avr-libc-dev] [bug #14616] definition of sei() in interrupts.h is faulty, Björn Haase, 2005/09/27