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

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

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


From: Ben Mann
Subject: RE: [avr-gcc-list] Is "noreturn" attribute still not supported?
Date: Mon, 24 Jan 2005 15:02:37 +0800

I'm surprised C is what you're after for self modifying code.

However,

The following appears to work, and a variation on the theme may achieve what
you want. I tried something similar before opting for pure asm with my
latest project.

//only use ((naked)) if you will
//handle push/pop all registers 
//yourself
void g() __attribute__ ((naked));
void g()
{
    asm volatile (
        "LABEL_G:\n\t"
        ::);

        //... do stuff

    asm volatile (
        "rjmp LABEL_F\n\t"
        ::);
}

void f() __attribute__ ((naked));
void f()
{
    asm volatile (
        "LABEL_F:\n\t"
        ::);

        //... do stuff

    asm volatile (
        "rjmp LABEL_G\n\t"
        ::);
}

Ben Mann



-----Original Message-----
From: Lin Gu [mailto:address@hidden 
Sent: Monday, 24 January 2005 2:55 PM
To: address@hidden
Cc: address@hidden
Subject: Re: [avr-gcc-list] Is "noreturn" attribute still not supported?


I actually dynamically generate the code in g() or the
code labeled after G at run time. So I cannot write
it statically that way.

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.

lin
--
Lin Gu
University of Virginia





reply via email to

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