On Tue, 17 Apr 2007 09:58:09 -0000, you wrote:
>Hi guys,
>
>I was writing some software for a scrolling message board when I came
>across the problem of clearing arrays during run-time in C.
>
>Usually I do something like:
>
>unsigned char array1[100];
>unsigned char count;
>
>for (count = 0; count < 100; count++){
>
> array1[count] = 0;
>}
>
>Has anybody ever come across a faster or more interesting way of
>accomplishing this ?
Faster would generally depend on how clever the compiler is, but giving it a helping hand with
something like
for (count = 0; count < 100; array1[count++]=0);
may help as it might encourage the compiler to use an auto-incrementing addressing mode. Maybe.
Partially unrolling the loop is also likely to help significantly, at the cost of code space.Message
Re: [AVR-Chat] Clearing Arrays In C
2007-04-17 by Mike Harrison
Attachments
- No local attachments were found for this message.