Was das so gemeint, oder kann ich noch weiter optimieren?:
Code:
void __attribute__ ((naked)) TIMER0_COMP_vect (void)
{
__asm__ __volatile (
"push r0" "\n\t"
"in r0,__SREG__" "\n\t" // Sichere SREG in r0
"dec r2" "\n\t" // --prescaler
"brne return" "\n\t" // if (prescaler!=0) goto return:
"push r24" "\n\t"
"sec" "\n\t" // system_time++
"lds r24,%0" "\n\t"
"adc r24,r2" "\n\t"
"sts %0,r24" "\n\t"
"lds r24,%0+1" "\n\t"
"adc r24,r2" "\n\t"
"sts %0+1,r24" "\n\t"
"lds r24,%0+2" "\n\t"
"adc r24,r2" "\n\t"
"sts %0+2,r24" "\n\t"
"lds r24,%0+3" "\n\t"
"adc r24,r2" "\n\t"
"sts %0+3,r24" "\n\t"
"ldi r24,75" "\n\t" // prescaler=75
"mov r2,r24" "\n\t"
"pop r24" "\n\t"
"return:" "\n\t"
"out __SREG__,r0" "\n\t"
"pop r0" "\n\t"
"reti" "\n\t"
:: "i" (&system_time)
);
}
Lesezeichen