6

The GNU Assembler as uses different characters depending on the architecture to specify single-line comments, such as # on x86, ; on 29k, or @ on ARM. Moreover, regardless of platform, C-style comments are also supported (/* */).

Is there a technical reason for different comment styles on different architecture? The multi-line comment suggest no, as it works on any platform - however if there is no technical limitation on the characters that can be used for comments, why design the assembler to require different comment styles on different platforms (for single-line comments)?

7
  • 7
    I imagine it would be feel rather unnatural for programmers to change already accepted syntax for a popular instruction set architecture. Since assembly broadly has no standard syntax, these characters have been given different (and conflicting) meanings over the years, by the various manufacturers of instruction set architectures (who also published the original ISA & assembly documentation for their architectures).
    – Erik Eidt
    Nov 22, 2017 at 0:54
  • The GNU assembler seems to use ; for ARM, not @.
    – Doc Brown
    Nov 22, 2017 at 7:25
  • 2
    I'd guess that # was part of the AT&T syntax which the gnu assembler wanted to be compatible with for x86? Nov 22, 2017 at 10:39
  • @CodesInChaos This seems unlikely, because the as on the PDP-11 used ; for comments (in addition to / at the start of a line). You can see this in the UNIX V7 source code and in the original cc compiler written by dmr.
    – Ankush
    Nov 22, 2017 at 10:54
  • @DocBrown That's a rather old version of the as manual - it has 1998 as its last update date. Section 8.3 does indeed specify ; as the line comment character for ARM, but I think (from the error messages I'm getting) that as-on-ARM uses a different character for that now.
    – AJM
    Jul 21, 2022 at 13:26

1 Answer 1

2

The default assembler syntax of different platforms simply used different ways of commenting and to make existing code compile without extra modifications, the typical syntax has been adopted by GNU AS, too. Keep in mind that there is no standardization among assembler languages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.