This is the mail archive of the gcc-help@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]

inline assembly and more


I'm new to gcc, after reading man page, and texinfo documentation,
i have 3 questions:

1) I'm using gcc on a x86 machine i want to review the generated
assembly code the .s file, i would like that gcc output the lines
of the c source file as commentary in the .s file. I tried -fverbose-asm
but didn't change anything.

2) I would like to use inline assembly code in the c source file
the __asm__() syntax seems to be very frustrating is there a way to
use a
    #asm
                fmul
                xor eax,eax
    #endasm 
or a 
        int c = 4;
    asm movl %eax,c
        d = c++;
syntax, if possible with intel syntax notation (ie using nasm)

3) Why does this:
-------------------------------------------------------------------
/** copy src from offset srcoff to dest at offset destoff */
b_t b_cpyn(const b_t src, b_t dest, size_t srcoff, size_t destoff)
{
        size_t srcs = b_sze(src);
        size_t dests = b_sze(dest);
/* fixme: gcc bug ?? if put after the if */
        void *a = (void*) (b_dat(src)+srcoff);
        void *b = (void*) (b_dat(dest)+destoff);

        if ( (srcs<=srcoff) || (dests<=destoff) ) 
                return dest;
        return memcpy(b,a,mins(srcs-srcoff,dests-destoff));
}
--------------------------------------------------------------------

compile and this:

-------------------------------------------------------------------
/** copy src from offset srcoff to dest at offset destoff */
b_t b_cpyn(const b_t src, b_t dest, size_t srcoff, size_t destoff)
{
        size_t srcs = b_sze(src);
        size_t dests = b_sze(dest);
/* fixme: gcc bug ?? if put after the if */
        if ( (srcs<=srcoff) || (dests<=destoff) ) 
                return dest;
        void *a = (void*) (b_dat(src)+srcoff);
        void *b = (void*) (b_dat(dest)+destoff);
        return memcpy(b,a,mins(srcs-srcoff,dests-destoff));
}
--------------------------------------------------------------------

don't

:!make  2>&1| tee /tmp/vim207751.err
gcc -Wall -pedantic -c -o mem.o mem.c
mem.c: In function `b_cpyn':
mem.c:191: parse error before `void'
mem.c:193: `b' undeclared (first use in this function)
mem.c:193: (Each undeclared identifier is reported only once
mem.c:193: for each function it appears in.)
mem.c:193: `a' undeclared (first use in this function)
make: *** [mem.o] Error 1
(3 of 8):  parse error before `void'
Press RETURN or enter command to continue
--------------------------------------------------------------

Thank you for gcc, and thank you in advance for your answers
please reply to: wis at hotmail dot com


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