English Amiga Board


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

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

Hello

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
#comment
;comment
/*comment*/
//comment

All give errors ...

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

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

EDIT: Inline assembly might work:

Code:
int foo(int x)
{
  /* hello c */
  asm("/* hello asm */");
  return x + 42;
}

Last edited by hmn; 13 March 2018 at 10:16.
hmn is offline  
Old 13 March 2018, 10:38   #3
thellier
Registered User
 
Join Date: Sep 2011
Location: Paris/France
Posts: 180
Thanks
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, 10:54   #4
ajk
Registered User
ajk's Avatar
 
Join Date: May 2010
Location: Helsinki, Finland
Posts: 1,150
Apparently the comment syntax is target specific. Have you tried the pipe symbol ("|")?
ajk is online now  
Old 13 March 2018, 11:03   #5
hmn
Registered User

 
Join Date: Nov 2016
Location: DE
Posts: 12
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, 11:52   #6
Vousti
Banned
 
Join Date: Mar 2018
Location: Finland
Posts: 36
https://sourceware.org/binutils/docs....html#Comments
Vousti is offline  
Old 13 March 2018, 17:21   #7
jlin_au
Registered User
 
Join Date: Nov 2016
Location: Fadden ACT Australia
Posts: 25
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 17:28.
jlin_au is offline  
Old 13 March 2018, 17:48   #8
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 47
Posts: 431
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, 10:02   #9
thellier
Registered User
 
Join Date: Sep 2011
Location: Paris/France
Posts: 180
Thanks to all for your help
thellier is offline  
 


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 18:54
Compiling GCC 3.x for WarpOS grelbfarlk Coders. C/C++ 2 28 November 2017 04:03
Help with gcc cross-compiling MartinW Coders. C/C++ 7 21 April 2017 13:22
Comments and suggestions markpjd Amiga websites reviews 0 14 May 2014 17:47
Tool to convert asm to gnu asm (gas) Asman Coders. Asm / Hardware 6 12 October 2013 12: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 14:43.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.06955 seconds with 13 queries