Hi,
I'm looking for the least time and memory consuming
solution of an interrupt routine. I realized that there
are useless register saves/restores when using bit
manipulation. I broke it down to the examples below.
By the way...
In lack of a real-world application I used nonsensical
interrupt vectors ("-1" and "-2", see below). The compiler
answered with a really funny warning:
"warning: Interrupt vector 0xffdf assigned
to ISR 'testint1' does make sense"
;-)
Cheers,
Ralf
here the examples:
the source lines:
=================
volatile int Counter;
char fAdjust;
interrupt (-2) testint2(void)
{
if (fAdjust)
Counter++;
}
compile to:
===========
interrupt (-2) testint2(void)
{
if (fAdjust)
0: c2 93 00 00 cmp.b #0, &0x0000 ;r3 As==00
4: 02 24 jz $+6 ;abs 0xa
Counter++;
6: 92 53 00 00 inc &0x0000 ;
}
a: 00 13 reti
whereas the source lines:
=========================
struct {
int Adjust: 1;
} Flags;
interrupt (-1) testint1(void)
{
if (Flags.Adjust)
Counter++;
}
compile to:
===========
interrupt (-1) testint1(void)
{
c: 0f 12 push r15 ;
if (Flags.Adjust)
e: d2 b3 00 00 bit.b #1, &0x0000 ;r3 As==01
12: 02 24 jz $+6 ;abs 0x18
Counter++;
14: 92 53 00 00 inc &0x0000 ;
}
18: 3f 41 pop r15 ;
1a: 00 13 reti
You