----- Original Message -----
From: "John Samperi" <samperi@ampertronics.com.au>
To: <AVR-Chat@yahoogroups.com>
Sent: Saturday, April 16, 2005 9:02 AM
Subject: Re: [AVR-Chat] Debugging ATMega16
>
> >Sorry can't help - I am a happy Imagecraft C User.
>
> You will be absolutely ecstatic
Well I suspect that Les Grant might me more excited than I (he's the local
Imagecraft disty) ;-)
> to know that, earlier this week,
> I installed the ICCavr thingy from the CD we got at the seminar.
Welcome to the dark side.... (muhaaa...) (hehe)
> Now that I have a Mega64 (or 128) board and a JTAGICE I may be
> able to get the 'Hello world!" program working in C. :-)
easy.. done if four lines
void main(void)
{
puts("Hello World");
}
done!
but - oh wait...
Need to setup
- I/O
- Timers
- ISRs
- UARTs
- ADCs
- Implement the int putch(int ch) function (so puts() works)
- Enable the watchdog .. etc, etc,etc
If won't take long to fill that 64K you have John. ;-)
Just joking, I think you will be pleasantly surprised how compact the code
ends up.
A couple of hits,
1. It is a good idea to look at the generated output listings to get an idea
of how different C statements affect code generation
A few to look at are -
while() vs for()
++i vs i--
arry[idx] vs *(ptr+idx)
switch vs multiple ifs
2. Don't look at the output listing (yes I know that it contradicts 1. ) as
it will constantly frustrate you how dumb the complier can be
("Why is if reloading R6 again - it R6 _already_ contains the value that is
needed? I wouldn't do that in ASM!)
Be content (trust ;-)) that in the big picture (ie over the entire
application) the code size of a reasonably written C program is within
5%-20% (depending on who you believe) of a reasonably written ASM program.
Oh oh - I've really opened myself up for flaming here ;-)
So I'll stop right now before I get myself into a 'religious' C vs ASM war.
;-)
Cheers,
Ivan
PS. If you get stuck let me know if I can be of help.
>
> Regards
>
> John Samperi
>
> ******************************************************
> Ampertronics Pty. Ltd.
> 11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
> Tel. (02) 9674-6495 Fax (02) 9674-8745
> Email: samperi@ampertronics.com.au
> Website http://www.ampertronics.com.au
> * Electronic Design * Custom Products * Contract Assembly
> ******************************************************
>
>
>
>
>
> Yahoo! Groups Links
>
> <*> To visit your group on the web, go to:
> http://groups.yahoo.com/group/AVR-Chat/
>
> <*> To unsubscribe from this group, send an email to:
> AVR-Chat-unsubscribe@yahoogroups.com
>
> <*> Your use of Yahoo! Groups is subject to:
> http://docs.yahoo.com/info/terms/
>
>
>
>
>
MSGTAG has notified the sender that you have read this message.