From: Sterten AT aol DOT com Message-ID: Date: Sat, 21 Jul 2001 15:29:38 EDT Subject: Re: assembly translation of a single C-command To: eliz AT is DOT elta DOT co DOT il CC: djgpp AT delorie DOT com MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: AOL 3.0 16-bit for Windows sub 60 Reply-To: djgpp AT delorie DOT com here's, what the FAQ says: >8.20 How to get GCC to generate assembly code >============================================= > >_*Q*: How can I peek at the assembly code generated by GCC?_ > > >_*Q*: How can I create a file where I can see the C code and its assembly >translation together?_ > > >*A*: Use the `-S' (note: _capital_ S) switch to GCC, and it will emit the >assembly code to a file with a `.s' extension. For example, the following >command: > > gcc -O2 -S -c foo.c > >will leave the generated assembly code on the file `foo.s'. > >If you want to see the C code together with the assembly it was converted to, >use a command line like this: > > gcc -c -Wa,-a,-ad [other GCC options] foo.c > foo.lst > >which will output the combined C/assembly listing to the file `foo.lst'. not with GCC 2.03 on my computer. The C-code is not in it. Although you can search for strings and function-names, which gives some clues. The C-code however is in *.ii with some blank lines and included *.h files and comments deleted. But I could find no reference (line-) numbers to the assembly code in *.lst . >If you need to both get the assembly code _and_ to compile/link the program, >you can either give the `-save-temps' option to GCC (which will leave all the >temporary files including the `.s' file in the current directory), or use the >`-Wa,aln=foo.s' option which instructs the assembler to output the assembly >translation of the C code (together with the hex machine code and some >additional info) to the file named after the `='. I had tried all the suggestions and didn't get what I wanted , except the last one. I couldn't get that '-Wa,aln=foo.s' working. Finally I got the idea, that it could be meant to be: '-Wa,-aln=foo.s' so I tried: gcc -c -Wa,-aln=foo.s test1.c which gave me some assembly output with hex-listing in foo.s , but still nothing with the corresponding C-commands. When I get a larger program converted to assembly and peek into foo.s , then it's hard to refind the locations corresponding to the interesting parts in the C-program. Guenter