[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-chat] Atmega128, JTAG and ADC
From: |
Jeff Epler |
Subject: |
Re: [avr-chat] Atmega128, JTAG and ADC |
Date: |
Sun, 17 Jul 2005 20:54:05 -0500 |
User-agent: |
Mutt/1.5.9i |
On Sun, Jul 17, 2005 at 04:39:58PM -0700, Larry Barello wrote:
> BTW Testing for zero/non-zero takes less code than comparing to an explicit
> bit value...
With avr-gcc 3.3.2, -Os, all these variations compile to the same thing,
using an `sbrc' instruction.
/***********************************/
extern void p1(void);
extern void p2(void);
void f1(unsigned char c) {
if((c & 8) != 8) p1(); else p2();
}
void f2(unsigned char c) {
if((c & 8) == 0) p1(); else p2();
}
void f3(unsigned char c) {
if(!(c & 8)) p1(); else p2();
}
/***********************************/
Example disassembly:
0: 83 fd sbrc r24, 3
2: 02 c0 rjmp .+4 ; 0x8
4: 00 d0 rcall p1
6: 08 95 ret
8: 00 d0 rcall p2
a: 08 95 ret
I think the best code would actually be
0: 83 fd sbrc r24, 3
2: 00 d0 rjmp p2
4: 00 d0 rjmp p1
but avr-gcc misses it by a factor of 2. Do newer versions do any better? I
know 3.3.2 is a bit old by now.
Jeff
pgpeGJZd7hcyw.pgp
Description: PGP signature
- [avr-chat] PID Tutorial/ Examples, Royce & Sharal Pereira, 2005/07/15
- Re: [avr-chat] PID Tutorial/ Examples, Christopher X. Candreva, 2005/07/15
- Re: [avr-chat] PID Tutorial/ Examples, Royce & Sharal Pereira, 2005/07/16
- Re: [avr-chat] PID Tutorial/ Examples, Richard Urwin, 2005/07/16
- [avr-chat] Atmega128, JTAG and ADC, Larry Barello, 2005/07/17
- RE: [avr-chat] Atmega128, JTAG and ADC, Ben Mann, 2005/07/17
- Re: [avr-chat] Atmega128, JTAG and ADC, Brian Dean, 2005/07/17
- Re: [avr-chat] Atmega128, JTAG and ADC, Richard Urwin, 2005/07/17
- RE: [avr-chat] Atmega128, JTAG and ADC, Larry Barello, 2005/07/17
- Re: [avr-chat] Atmega128, JTAG and ADC, Brian Dean, 2005/07/17
- Re: [avr-chat] Atmega128, JTAG and ADC,
Jeff Epler <=
- RE: [avr-chat] Atmega128, JTAG and ADC, Larry Barello, 2005/07/17
Re: [avr-chat] PID Tutorial/ Examples, Alan Kilian, 2005/07/15
Re: [avr-chat] PID Tutorial/ Examples, Richard Urwin, 2005/07/15