avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] Re: Atmega128, JTAG and ADC (Jeff Epler)


From: Jeff Epler
Subject: Re: [avr-chat] Re: Atmega128, JTAG and ADC (Jeff Epler)
Date: Tue, 19 Jul 2005 09:57:16 -0500
User-agent: Mutt/1.4.1i

On Tue, Jul 19, 2005 at 08:42:52AM -0500, Dean Hall wrote:
> Jeff,
> 
> The rest of your post was good research, but
> your example code isn't quite right.
> Look what happens in the non-skip-if-bit case:
> the code rjmps to p2, executes p2, returns
> and then rjmps to p1 (regardless), executes p1,
> returns.

Here's my thought process while "optimizing" that code:

The original code generated by gcc was
    sbrc r24, 3
    rjmp l1
    rcall p1
    ret
l1:
    rcall p2
    ret

First, rcall+ret is the same as rjmp, so turn the code into 
    sbrc r24, 3
    rjmp l1
    rjmp p1
l1:
    rjmp p2

This code has a jump to a jump, so turn the code into the final form
    sbrc r24, 3
    rjmp p2
    rjmp p1

I don't see how p2 could return to the 'rjmp p1' instruction; instead,
it will return to whatever address the 'ret' in the original code would
have returned to.

I haven't done much low-level coding for avr, but the 'call followed by
return' optimization is one I've used on other systems.  Is there
something I'm missing about avr that means this doesn't work?

Jeff

Attachment: pgpenz22GaIrY.pgp
Description: PGP signature


reply via email to

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