This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to let GCC produce flat assembly


On Friday 16 November 2007, Dave Korn wrote:
> On 16 November 2007 05:56, Li Wang wrote:
> > As you said, the coprocessor has no ABI to describe a stack and a
> > function interface, then inline applies. But how could I inline 'main'?
> > And I am sorry for I misuse the word 'elf assembly', what exactly I mean
> > by that is how to omit the section or any other informations helps
> > linker to organize a executable from the cc1 output. In a word, codes
> > something like the following is what I want, If possible to let cc1
> > produce such assembly? Thanks.
> >
> >     movl    $2, -4(%ebp)
> >     movl    $2, -8(%ebp)
> >     movl    -8(%ebp), %eax
> >     addl    -4(%ebp), %eax
>
>   Various CPU backends (but IIRC not i386) implement a "naked" function
> attribute, which suppresses function epilogue and prologue generation.  You
> could implement something like that.

__attribute__((naked)) isn't useful in that way. A side-effect of suppressing 
supressing the function prologue/epiloge is that you effectively can't use C 
in that function. The compiler will still generate references to the stack 
frame if it feels like it. This will fail fairly rapidly as you've suppressed 
the code to create that stack frame.

IMHO gcc isn't really suited to this kind of absurdly small machine 
implementing a crippled subset of C. C (and most of the other langages gcc 
supports) pretty much assume a machine will a stack.

Note that this doesn't mean your CPU has to have dedicated stack hardware. 
Most RISC architectures don't have any specific support for this, we just 
pick a register, and by convention use that as the stack pointer. If there 
isn't a ABI for your target, to get to design one.

Paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]