EmbDev.net

Forum: ARM programming with GCC/GNU tools Line comment character for arm-elf-as?


von Bill B. (auldreekie)


Rate this post
useful
not useful
First, my UNDYING GRATITUDE for porting a recent version of the GNU ARM
toolchain to OS X.  The holy grail of being able to compile on my
primary machine without emulating anything or running a remote desktop
is finally within reach!

Second, my apologies for asking what must be a stupid question, but I
cannot figure out what the line-comment character is in arm-elf-as.  The
assembler respects # if it occurs BEFORE any source text on a line.  It
also respects anything enclosed in /* */.  But the other typical
line-comment characters -- !, ;, |, // -- trigger errors, and even #
doesn't work if it occurs after the source content has begin on that
line.

Not a showstopper of course, but mighty peculiar...?  I'm using the
toolchain under OS X 10.4.5.

Sorry if it's obvious -- I tried changing line-endings to DOS/CRLF &
back to UNIX/LF with no difference.  Are line comments no longer
considered good things?

Thanks, --Bill

von Bill B. (auldreekie)


Rate this post
useful
not useful
Found it -- it's the @ character.

Though I'm new to the GNU assembler I've used a few others, as well as
several macro and scripting languages, and this is the first time I can
remember seeing @ used as a line-comment char.  I'm curious if there was
any rationale for choosing @ over !, #, ;, or //.  But not THAT curious.

Thanks for reading!

von Bill B. (auldreekie)


Rate this post
useful
not useful
Doh!  # is used for immediate operands.  Maybe it's time for a vacation.

von Clifford S. (clifford)


Rate this post
useful
not useful
Bill Burgess wrote:
> Found it -- it's the @ character.
>
> Though I'm new to the GNU assembler I've used a few others, as well as
> several macro and scripting languages, and this is the first time I can
> remember seeing @ used as a line-comment char.  I'm curious if there was
> any rationale for choosing @ over !, #, ;, or //.  But not THAT curious.
>

It seems that the delimiter is target specific, presumably in order to
conform to the chip manufacturers syntax. However @ is not specified in
the manual!

The as manual has this to say:
http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_mono/as.html#SEC28,
it mentions nothing about ARM or @, but under Machine Dependencies,
(http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_mono/as.html#SEC155),
says that ; is the comment delimiter.

Confused?

Clifford

von Bill B. (auldreekie)


Rate this post
useful
not useful
Clifford Slocombe wrote:
> ...However @ is not specified in the manual! ... Confused?

Even more confused than that.  The "@" comment delimiter is indeed
specified for the ARM architecture in a GNU assembler manual -- but in a
version of the manual on Red Hat's web site, not FSF's.  From the link,
scroll down to section 8.3.2.1 "Special Characters":

http://sources.redhat.com/binutils/docs-2.10/as_8.html#SEC163

The Red Hat-hosted manual also lists -marm arguments going up to the
920, while the GNU site's manual only goes up to 8.  Evidently the gas
manual forked while FSF wasn't looking...?

von Bill B. (auldreekie)


Rate this post
useful
not useful
More time tracking this down...the most recent version of the binutils
documentation, last updated in May 2005, appears to be at

http://sourceware.org/binutils/docs-2.16/

How do we tell the folks at FSF to quit hosting their obsolete 1994
literature?  It's causing more harm than good.

von Clifford S. (clifford)


Rate this post
useful
not useful
Bill Burgess wrote:
> More time tracking this down...the most recent version of the binutils
> documentation, last updated in May 2005, appears to be at
>
> http://sourceware.org/binutils/docs-2.16/
>
> How do we tell the folks at FSF to quit hosting their obsolete 1994
> literature?  It's causing more harm than good.

Thanks for that. I'll update by documentation immediately.

Clifford

von Clifford S. (clifford)


Rate this post
useful
not useful
Bill Burgess wrote:
> http://sourceware.org/binutils/docs-2.16/

Is there a postscript or PDF of this version (or even an HTML tar-ball)
I wonder? - I'd like to have the documentation locally or printable.

Clifford

von Bill B. (auldreekie)


Rate this post
useful
not useful
Clifford Slocombe wrote:
> Is there a postscript or PDF of this version ... ?

A quick Google for binutils 2.16 texinfo pdf led me here:

http://www.delorie.com/djgpp/dl/ofc/current/v2gnu/bnu2161d.zip/

A nice collection of up-to-date PDF, HTML, DVI, and PS-formatted
documentation.

--Bill

von Varuzhan (Guest)


Rate this post
useful
not useful
In the WinARM20070505 examples for LPS2378 (maybe others too), Martin
Thomas refers
to GNU-as manual from binutils V 2.17 (in file crt0.s) for the character
@ for the
assembler line comments.
The same time his old files still use the more common C++ like comments
// and it
really works with the last version of the Gnu.
For me and, maybe many others, the // looks much usual and preferred,
than @. Does
anybody know why in the referenced manual the // is not mentioned and is
it reliable from the future upgrading point of view to use // ?

Great thanks in advance,
Varuzhan

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
Varuzhan wrote:
> In the WinARM20070505 examples for LPS2378 (maybe others too), Martin
> Thomas refers
> to GNU-as manual from binutils V 2.17 (in file crt0.s) for the character
> @ for the
> assembler line comments.
> The same time his old files still use the more common C++ like comments
> // and it
> really works with the last version of the Gnu.
> For me and, maybe many others, the // looks much usual and preferred,
> than @. Does
> anybody know why in the referenced manual the // is not mentioned and is
> it reliable from the future upgrading point of view to use // ?

The @ is the comment character for the arm-elf-as assembler as already
pointed you in the previous messages in this forum-thread. If you'd like
to use // and /* */ the C-preprocessor has to parse the source first.
Using the preprocessor also offers a lot more options
(#if/#ifdef/#include etc.). An assembler source-code gets automatically
parsed by the preprocessor if it has the files-extension .S (uppercase
S) instead of .s (lowercase s). Also see the documentation on the option
-x assembler-with-cpp.

There is not special reason why I used the "@-comment" in the LPC2378
examples. As you can see the file extension for the assembler-sources is
an uppercase S so // and /* */ can be used too. I just did a "search in
replace" to replace the comment-character used in the original NXP
example-code with @ (replace by // could have been done too).

I don't think there will be any problems with future versions of the
toolchain in this field. If you prefer the C-style comments just use
them and make sure the preprocessor parses the assembler-source first.

Hope this helps,
Martin Thomas

von Varuzhan (Guest)


Rate this post
useful
not useful
Martin Thomas wrote:
> Varuzhan wrote:
>> In the WinARM20070505 examples for LPS2378 (maybe others too), Martin
>> Thomas refers
>> to GNU-as manual from binutils V 2.17 (in file crt0.s) for the character
>> @ for the
>> assembler line comments.
>> The same time his old files still use the more common C++ like comments
>> // and it
>> really works with the last version of the Gnu.
>> For me and, maybe many others, the // looks much usual and preferred,
>> than @. Does
>> anybody know why in the referenced manual the // is not mentioned and is
>> it reliable from the future upgrading point of view to use // ?
>
> The @ is the comment character for the arm-elf-as assembler as already
> pointed you in the previous messages in this forum-thread. If you'd like
> to use // and /* */ the C-preprocessor has to parse the source first.
> Using the preprocessor also offers a lot more options
> (#if/#ifdef/#include etc.). An assembler source-code gets automatically
> parsed by the preprocessor if it has the files-extension .S (uppercase
> S) instead of .s (lowercase s). Also see the documentation on the option
> -x assembler-with-cpp.
>
> There is not special reason why I used the "@-comment" in the LPC2378
> examples. As you can see the file extension for the assembler-sources is
> an uppercase S so // and /* */ can be used too. I just did a "search in
> replace" to replace the comment-character used in the original NXP
> example-code with @ (replace by // could have been done too).
>
> I don't think there will be any problems with future versions of the
> toolchain in this field. If you prefer the C-style comments just use
> them and make sure the preprocessor parses the assembler-source first.
>
> Hope this helps,
> Martin Thomas

Dear Thomas,

Thank you very much, you make a really great work with the WinARM and
great support, much better than commercial.

Varuzhan

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.