[Top][All Lists]

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

Re: [avr-gcc-list] Is "noreturn" attribute still not supported?

From: Lin Gu
Subject: Re: [avr-gcc-list] Is "noreturn" attribute still not supported?
Date: Tue, 25 Jan 2005 10:47:33 -0500

> > The bottom line is that g() needs to know an
> > address to JMP to. I assume I cannot use
> > a label like F outside a
> > function where it is defined. Hence I need a
> > function. This is why I need to have a function
> > that is compiled with 'noreturn' attribute.
> >
> > Without "noreturn", I have to write the function
> > completely in assembly code.
> Why would that be?
> You don't need anything more than an address. Presumably, you have an address\
> since you've written to the flash.
> So all you have to do is to replace the return address on the top of the stac\
> with the address you want to jump to, and then do a return.
> You could do the replacement with an assembly language macro that takes the
> desired destination address.

Agree. What I need is an address. With that address I  just use 
assembly code to "JMP" to that address. Changing the return
address is nicer but my application has strict size limit so a direct
jump seems more appropriate.

My whole problem originates from how to get that "address" in the
first place. I cannot use the C funtion as the address since it
starts with a prolog of pushes which I do not need.

Fortunately I found a way to do it -- use a global label in inline
assembly code. Like this

  asm volatile (".global global_lable"
                     global_label:" : :);
  ... some C/assembly code ...

Then global_label can be the correct address, assuming gcc does not
move code around agressively.

Thanks to all who replied to my question!

Lin Gu
University of Virginia

reply via email to

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