Re: gcc compile with asm

From: Bo Sun (b0s6067_at_cs.tamu.edu)
Date: 02/23/04

  • Next message: Grant Edwards: "Re: gcc compile with asm"
    Date: Mon, 23 Feb 2004 16:20:38 -0600
    To: "Gerhard W. Gruber" <sparhawk@gmx.at>
    
    

    the sample program asm_test.c is:

    #include <stdio.h>

            unsigned long sp(void)
            {
                    _asm_("mov1 %esp, %eax"); // return stack ptr
            }

    int main()
    {

            printf("%x\n", sp());

            return 0;

    }

    when I use

    gcc asm_test.c

    I got

    Undefined first referenced
     symbol in file
    _asm_ /var/tmp//ccQyonpr.o
    ld: fatal: Symbol referencing errors. No output written to a.out
    collect2: ld returned 1 exit status

    thanks,

    bo

    On Mon, 23 Feb 2004, Gerhard W. Gruber wrote:

    > On Mon, 23 Feb 2004 09:49:57 -0600 wrote Bo Sun <b0s6067@cs.tamu.edu> in
    > comp.os.linux.development.system with
    > <Pine.GSO.4.58.0402230948350.10260@unix.cs.tamu.edu>
    >
    > >I have written a program using "_asm_". I would like to know what is the
    > >command line I can use to compile and link it.
    > >
    > >Suppose the file name is file.c
    > >
    > >gcc file.c
    > >
    > >does not work.
    >
    > If your asm code is inlined, then the command for compiling is the same as
    > compiling a normal C program, because it IS a normal C program.
    >
    > If you have a complete sourcecode in asm then it depends on which assembler
    > you wrote it for, but from what you posted (which is not much) gcc should work
    > just like normal.
    >
    > It would be enlightening if you could have at least included the errormessage
    > you get when you try to compile.
    >
    > --
    > Gerhard Gruber
    > Maintainer of
    > SoftICE for Linux - http://pice.sourceforge.net/
    > Fast application launcher - http://sourceforge.net/projects/launchmenu
    >


  • Next message: Grant Edwards: "Re: gcc compile with asm"

    Relevant Pages

    • Re: How do I install this missing library?
      ... you really should be carefully following LSTC's installation ... libg2c is part of gcc. ... to tell a newcomer to compile. ... like the source code to GNU tar, and make sure you understand what's ...
      (comp.os.linux.misc)
    • Re: link & libraries
      ... gcc: ./selection.o: No such file or directory ... In short this command reads: ... This tells gcc to compile file1 and file2 from C source to object ... For an example of a simple Makefile that works with AMU, ...
      (comp.sys.acorn.programmer)
    • Re: HPGCC Questions ladies and gentlemen!!!
      ... No matter how you slice it in order to compile a C program you need to know ... it took a few hours just to get gcc running in my computer ... of the students that used an ide in the c++ class I took a few years ago. ... so why not use a data inspector if it's available? ...
      (comp.sys.hp48)
    • Re: Problem Linking after gcc Compile
      ... >The following is the command and output to gcc: ... That is not the right command, ... The correct command for a C++ compile by GNU is ... IRIX does). ...
      (comp.sys.sgi.admin)
    • Re: Aquarius prolog so fast?
      ... Mercury cannot do all this because Mercury cannot keep track of the fact ... you need this capability quite rarely, ... Why not the alternative GCC back-end, ... While Mercury can compile to the internal data structures of the gcc backend, ...
      (comp.lang.prolog)