avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] efficiency of assigning bits


From: Erik Walthinsen
Subject: Re: [avr-gcc-list] efficiency of assigning bits
Date: Mon, 14 Mar 2005 11:53:26 -0800
User-agent: Debian Thunderbird 1.0 (X11/20050116)

E. Weddington wrote:
> If you don't care, then you're
free to have them as two statements, but it would also be inefficient in terms of code space. Your choice.

Actually, it's more efficient to code it as two separate statements, *if* the register is one of the first 32 in the chip's register space. Two statements will result in 2 sbi or cbi instructions, while a single statement will result in a read-modify-write sequence of 3 instructions.

If the register is outside that range, then yes, it is more efficient to do it as a single statement, because sbi/cbi don't work and you're back to a read-modify-write sequence for each of the two statements, resulting in 6 instructions.

I went around on this several times while trying to shave one instruction at a time on a project that's filled the 1024-byte code space (512 instructions) of an ATtiny15 to 99+%. Waiting for ATtiny45 samples......




reply via email to

[Prev in Thread] Current Thread [Next in Thread]