how to use macro in assemble language embedded in C?

kerler kerler at newmail.net
Wed Dec 27 14:33:41 EST 2000


Hi,

(NOTE: when reply this mail, please cc: kerler at newmail.net , thanks)

I change the first line of temp.c:
    asm("#include <asm\\ptrace.h>\n\t");
to
    asm("#include <asm/ptrace.h>\n\t");
==========temp.c==================
 asm("#include <asm/ptrace.h>\n\t");
 void dummy (void)
 {
     asm("stwu   %r1, -PT_R16(%r1)");             /* stack */
 }
==========end of temp.c===========

failed when:
    gcc -c temp.c
error message:
    /tmp/cc06t5DZ.s: Assembler messages:
    /tmp/cc06t5DZ.s:13: Error: Negative of non-absolute symbol PT_R16
but when use:
    gcc -S temp.c -o temp.S    (note: here is temp.S, not temp.s)
    gcc -c -D_ASSEMBLY__ temp.S
success!

so I know the question is that gcc do pre-process when "gcc -c temp.S",
but not do per-process when "gcc -c temp.s"

so if i want use only one command line to compile temp.c,
such as "gcc -c -other-option temp.c", which other-option should I add to
make
gcc creat a temporal assemble file /tmp/xxxx.S (not /tmp/xxxx.s) ?

----- Original Message -----
From: Kaoru Fukui <k_fukui at highway.ne.jp>
To: kerler <kerler at newmail.net>
Sent: Tuesday, December 26, 2000 9:17 PM
Subject: Re: how to use macro in assemble language embedded in C?


> Hi!
>
> Look at linux/arch/kernel/entry.S or else
>
> Kaoru
>
>
> From: "kerler" <kerler at newmail.net>
> To: <linuxppc-dev at lists.linuxppc.org>
> Subject: how to use macro in assemble language embedded in C?
> Date: Tue, 26 Dec 2000 09:41:09 +0800
> Cc: <gcc at gcc.gnu.org>
>
> >
> > hello,
> >
> > When i use the assemble language embedded in C, how can i use the macro?
> >
> > in the following code, i want to use the macro PT_R16 defined in
> > asm\ptrace.h.
> >
> > =========temp.c==========
> > asm("#include <asm\\ptrace.h>\n\t");
> > void dummy (void)
> > {
> >     asm("stwu   %r1, -PT_R16(%r1)");             /* stack */
> > }
> > =========end of temp.c===
> >
> > when i
> >       gcc -c temp.c
> > error message:
> > /tmp/cc8ztvPf.s: Assembler messages:
> > /tmp/cc8ztvPf.s:13: Error: Negative of non-absolute symbol PT_R16
> >
> > if use
> >       gcc -S temp.c
> > the file temp.s is:
> >
> > =========temp.s==========
> >         .file   "temp.c"
> > gcc2_compiled.:
> >         #include <asm\ptrace.h>
> >
> >         .section        ".text"
> >         .align 2
> >         .globl dummy
> >         .type    dummy, at function
> > dummy:
> >         stwu 1,-16(1)
> >         stw 31,12(1)
> >         mr 31,1
> >         stwu   %r1, -PT_R16(%r1)
> > .L2:
> >         lwz 11,0(1)
> >         lwz 31,-4(11)
> >         mr 1,11
> >         blr
> > .Lfe1:
> >         .size    dummy,.Lfe1-dummy
> >         .ident  "GCC: (GNU) 2.95.2 20000220 (Debian GNU/Linux)"
> > ======end of temp.s=============
> >
> >
> >
> >
>

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-dev mailing list