This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: Question about compiling consideration(GNUPro, GCC for SPARC)? Thanks
- From: "Qiang Huang" <jameshq at liverpool dot ac dot uk>
- To: "Robert Cragie" <rcc at jennic dot com>
- Cc: "Lunn, Andrew" <andrew dot lunn at ascom dot ch>,"Ecos-Discuss" <ecos-discuss at sources dot redhat dot com>
- Date: Tue, 8 Oct 2002 09:41:48 +0100
- Subject: RE: [ECOS] Question about compiling consideration(GNUPro, GCC for SPARC)? Thanks
First thanks a lot Andrew, Robert for help me on unimportant this topic.
Sometime this does something relate to ecos. consider the following example
a.S
ass_fun1:
(1) mov %o0, %g2
(2) mov 1, %g1
(3) add %g1, %g2, %g1
(4) mov %g1, %o0 // returns value
(5) ret
example.C
void main()
{
int a, add_one;
a = 8;
add_one = ass_fun1(a);
}
if when runs to line (2)(in thread1) (line 2 executed) and got interrupted,
context switch performed here: VSR called --> default_isr_handler called -->
interrupt_end( ) "C function called" --> HAL_THREAD_SWITCH_CONTEXT -->
another thread (thread2).
because we need to save the execution context of thread1 we need to save the
%g1 which holds the value "2" in ass_fun1(), but how could we know that %g1
would not be used in interrupt_end( ) function? ass_fun1 and main() are both
compiled after finishing compile the interrupt_end( ) (C source code).if
used then the value of "2" will be lost. so how can I find out %g1 is not
used in compilation of interrupt_end( ) or be saved before interrupt_end()
start and restore before exiting interrupt_end()? Thanks for your any
suggestion.
another consideration:
a.S
ass_fun2:
mov 0, %gx
ret
example.C
void main()
{
xxxxxxxxx // do some jobs
xxxxxxxxx // do more jobs
ass_fun2();
xxxxxxxxx // do another job
}
As in the above example, ass_fun2 modified %gx register directly in assembly
code and return without changing it back, so will that cause any problem to
the "C" function main( )? If %gx is call-clobbered, does that mean it won't
cause any problem(not preserved across function call -- does this function
call include assembly function call??) ?
Thanks a lot.
-----Original Message-----
From: Robert Cragie [mailto:rcc@jennic.com]
Sent: 07 October 2002 15:12
To: Qiang Huang
Subject: RE: [ECOS] Question about compiling consideration(GNUPro, GCC for
SPARC)? Thanks
I doubt you'll get much help from the ecos-discuss list.
a) It's the wrong forum
b) There don't seem to be many SPARC experts on it anyway.
You seem to be asking a lot of very low-level SPARC specific questions. You
say you have the ABI; all the information you require is in there, as GCC
follows the ABI (I'm looking at
(http://www.sparc.com/standards/psABI3rd.pdf). The best advice I can give
you is to *really thoroughly* read the ABI document. You will find you
understand things much easier if you understand the fundamentals behind the
issues, and you won't have to ask so many questions - Nick Garnett has
already pointed this out.
Robert
> -----Original Message-----
> From: ecos-discuss-owner@sources.redhat.com
> [mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Qiang Huang
> Sent: 07 October 2002 13:58
> To: Ecos-Discuss
> Subject: [ECOS] Question about compiling consideration(GNUPro, GCC for
> SPARC)? Thanks
>
>
> Hi all:
> Does anyone know a little detail about how the compiler
> works? Thanks a
> lot.
>
> As in Sparc there are %lx, %ix, %ox, %gx,
> eg.
>
> "in example.c"
> int k;
> int fun1(int a)
> { int a,b,c,d;
> b = 2;
> c = a+b;
> k = c*2;
> d = 3*a;
> a = a+b+c+d;
> a +=k;
> return a;
> }
>
> void main()
> { int e,f,g,h;
> e = 2;
> f = fun1(e);
> g = fun1(f);
> h = fun_ass(e);
> }
>
> in "example.S"
> fun_ass:
> add %o0, 1, %o0
> mov 12, %g0
> retl
> nop
>
> Q1. when compiled what type of register will (%lx, %ox, %gx, %ix) be used
> for any local variable or gloable variable in the function written in "C"?
>
> Q2. In the function written in Assembly language %g0 has been
> used, so do I
> need to restore %g0 to the original value before exit this
> function? (note:
> no new register window opened here), If any register has been
> modified does
> it need to be restored before exiting?
>
> Q3. what type of register can I use freely in assembly code without backup
> its original value?
>
> Q4. In the ABI docs it says some registers are call-clobbered or
> call-preserved, what's the exact meaning of that?
>
>
> look forward to hearing from you
>
> Thanks a lot.
>
>
>
>
>
> --
> Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
> and search the list archive: http://sources.redhat.com/ml/ecos-discuss
>
>
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss