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]

Re: inline assembly and more


I found the way to what i wanted to do in this newsgroup
Message-ID: <81carb$fh4$1@news.doit.wisc.edu>
Here's a hint:
  $ gcc -Wa,-ahls,-L -g -c main.c
This will dump the listings to the standard output.
Either redirect the lists, or use "=<file>".
  $ gcc -Wa,-ahls=main.lst,-L -g -c main.c
Do look up the documentation for gas please.

i think it should be added to the faq as there are many
post with the same question i counted 4 of them.

And thank you for hint about declaration of var in
the begginning of a block. I think K&R ins't clear
about it except in the appendix, and before i used
to code with some tolerant compiler. but now i want
to do clean ansi C.

but there weren't any clue for better asm code inclusion
tools.

Thanks

Clark L. Coleman wrote:
> 
> In article <3829043A.68263C43@spam.com>, anthony  <no@spam.com> wrote:
> >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.
> 
> Don't know any way to do that.
> 
> >
> >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)
> 
> Not that I know of.
> 
> >
> >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
> 
> In C++, you can sprinkle your variable declarations around your code
> wherever you want, but not in C. Variable declarations go at the top
> of a block, not after any executable code in the block.


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