4

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)?

Ankush
  • 821
  • 1
  • 8
  • 12
  • 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 '17 at 00:54
  • The [GNU assembler](http://microelectronics.esa.int/erc32/doc/as.pdf) seems to use `;` for ARM, not `@`. – Doc Brown Nov 22 '17 at 07:25
  • 1
    I'd guess that `#` was part of the AT&T syntax which the gnu assembler wanted to be compatible with for x86? – CodesInChaos Nov 22 '17 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 '17 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 '22 at 13:26
  • Checking [the current version](https://sourceware.org/binutils/docs/as.pdf), `@` definitely functions as a line comment character for ARM now. `#` *might* also be one, but there are some caveats I don't completely understand yet. – AJM Jul 21 '22 at 14:21
  • If you want to replace the systems own assembler, you need to be compatible with its syntax. – Thorbjørn Ravn Andersen Jul 27 '22 at 10:59

1 Answers1

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.

Mecki
  • 1,818
  • 12
  • 17