Re: [AVR-Chat] Re: ASM vs. C
2009-01-15 by subscriptions@aeolusdevelopment.com
David VanHorn Wrote
>> With asm, you have to tediously study one great column of code before and
>> after you do any chopping and pasting. HLLs have a 2D visual aspect to
it.
>
>It's certainly possible to write ASM as one huge tarball of cruft, but
>that's not how I do it.
>
>Here's an ISR that I just compiled with optimization set for smallest
>code, in GCC:
>
>// Timer 0 overflow ISR
>ISR(TIMER0_OVF_vect)
>{
> 498: 1f 92 push r1
<snip>
>Only TWO of those instructions are actually needed!
>If it were me writing, it would look like this:
>
>T0_OVF_ISR:
> sbi ADCSRA,(1<<ADSC)
> reti
>
>Since SBI and CBI don't affect flags, and no registers are used,
>nothing needs to be pushed or popped at all!
>I'm still astounded that at this late date, this kind of thing happens.
This is one of the reasons I don't trust architecture specific keywords
(interrupt keywords in particular).
And also a good illustration of where mixing asm with C can be of great
benefit (reducing the latency substantially and decreasing size to boot)
Robert
--------------------------------------------------------------------
mail2web.com - Microsoft® Exchange solutions from a leading provider -
http://link.mail2web.com/Business/Exchange