Subject: Re: Making the (asm) world safe for modern cpp
To: None <tech-toolchain@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
Date: 09/19/2003 05:32:48
> (Hold me back Mama, I gotta wail.)
> [rant about C commenting syntax]
> [Explicit comment delimiters] are probably not truly required (in the
> sense of being required by the _machine_'s architecture) on sparc's
> and powerpc's.
Well, they're not truly required by the _machine_'s architecture on any
machine; assembler syntax is almost completely independent of the
hardware architecture. For example, if you place the instruction name
last, and require some kind of marker be attached to user-defined
symbols, the end of the instruction can be made unambiguous on any
machine. (It would look unconventional, but that's all.)
As for the SPARC, this is true only if you ignore assembler
pseudo-instructions like inc. SPARC assemblers generally support both
"inc %o0" and "inc %o0,3". There are also save and restore, which are
normally accepted without operands, implying "%g0,0,%g0".
But assembly languages that allow an expression as the last
(non-comment) piece of a line must either use self-delimiting
expression syntax or explicit comment delimiters:
addl3 iblen, 512, r8 The byte count of this piece is iblen
movc3 work, (r7), 256 + 512 - sizeof(int), but first we need
subl2 4, r8 to save the packet-so-far from work.
movc3 (r9), work, r8
On that second line, it's not clear where the comment starts, except to
a human who can understand the context (including the
whitespace-produced indendation) at a very high level of abstraction.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML firstname.lastname@example.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B