English Amiga Board

Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

Thread Tools
Old 13 March 2018, 10:51   #1
Registered User
Join Date: Sep 2011
Location: Paris/France
Posts: 166
GCC: compiling ASM with comments ?


I have a C function that I want to optimize
So I used GCC to generate the ASM
gcc -S myfunction.c
But how do I add comments to the ASM source generated in myfunction.s ?
I have tried

All give errors ...

So what is the syntax for GCC assembler for comments ?
thellier is offline  
AdSense AdSense  
Old 13 March 2018, 11:09   #2
Registered User

Join Date: Nov 2016
Location: DE
Posts: 4
Comments are removed by the preprocessor, so the C compiler that emits the assembly code never even sees them.

EDIT: Inline assembly might work:

int foo(int x)
  /* hello c */
  asm("/* hello asm */");
  return x + 42;

Last edited by hmn; 13 March 2018 at 11:16.
hmn is offline  
Old 13 March 2018, 11:38   #3
Registered User
Join Date: Sep 2011
Location: Paris/France
Posts: 166
but Inline assembly will not change the problem

>so the C compiler
This is not C the problem

I have an ASM listing in myfunction.s
And I want to modify this ASM (I can) but also manually add comments to make it more readable
But I dont know the syntax for GCC assembly comments ... as I want to compile the whole project with GCC
thellier is offline  
Old 13 March 2018, 11:54   #4
Registered User
ajk's Avatar
Join Date: May 2010
Location: Helsinki, Finland
Posts: 1,030
Apparently the comment syntax is target specific. Have you tried the pipe symbol ("|")?
ajk is online now  
Old 13 March 2018, 12:03   #5
Registered User

Join Date: Nov 2016
Location: DE
Posts: 4
I see, I understood it like you wanted to have the comments from your C code retained along with the generated assembly.

/* comment */ should work in assembly as well [1]. The single line comments are architecture specific, and M68K defaults to '|' [2].
hmn is offline  
Old 13 March 2018, 12:52   #6
Join Date: Mar 2018
Location: Finland
Posts: 36
Vousti is offline  
Old 13 March 2018, 18:21   #7
Registered User
Join Date: Nov 2016
Location: Fadden ACT Australia
Posts: 21
For a standard M68K assembler the source code a comment line must start with a #<space>. A source line starting with #<text> may be identified as an assembler directive instead of being a comment line.
A | within the line and outside of quotes will comment out the rest of the line.

Note - GCC normally generates machine code object modules directly. When you specify generate assembly code instead for the specified target architecture, GCC should generate source code for same architecture for the GNU binutils assembler 'as' to assemble for that same platform.

'as' expects comments to either start with '/*' and end with '*/' or be single whole line comments that start with a line comment character that is 'as' target specific. For 'as', a M68K source line starting with a '*' is a comment line while a line starting with a '#' may be also be a comment line or special line (see https://sourceware.org/binutils/docs...M68K_002dChars)

Last edited by jlin_au; 13 March 2018 at 18:28.
jlin_au is offline  
Old 13 March 2018, 18:48   #8
Registered User

Join Date: Dec 2010
Location: Athens/Greece
Age: 47
Posts: 394
The pipe character as Ajk already said works for me.

(e.g https://github.com/alexalkis/dl/blob...src/astartup.S )
alkis is offline  
Old 14 March 2018, 11:02   #9
Registered User
Join Date: Sep 2011
Location: Paris/France
Posts: 166
Thanks to all for your help
thellier is offline  
AdSense AdSense  

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to rewrite particular asm inline syntax for gcc? wawa Coders. Asm / Hardware 44 15 February 2018 19:54
Compiling GCC 3.x for WarpOS grelbfarlk Coders. C/C++ 2 28 November 2017 05:03
Help with gcc cross-compiling MartinW Coders. C/C++ 7 21 April 2017 14:22
Comments and suggestions markpjd Amiga websites reviews 0 14 May 2014 18:47
Tool to convert asm to gnu asm (gas) Asman Coders. Asm / Hardware 6 12 October 2013 13:45

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 07:04.

Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Page generated in 0.27246 seconds with 12 queries