Path: chuka.playstation.co.uk!tjs From: tjs@cs.monash.edu.au (Toby Sargeant) Newsgroups: scee.yaroze.programming.gnu_compiler Subject: Re: Inline Assembler: ? Date: 14 Sep 1998 03:33:42 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 64 Message-ID: References: <6te334$45l1@chuka.playstation.co.uk> NNTP-Posting-Host: longford.cs.monash.edu.au X-Newsreader: slrn (0.9.4.3 UNIX) On 14 Sep 1998 11:48:18 +1000, Toby Hutton wrote: >"Carlos Pieterse" writes: > >> Does anyone know of a way to (un)comment certain lines, when you do >> assembler like that ? ( ; doesn't seem to work!) ; ends lines, rather makes comments (on most architectures) I think. >Just a complete guess - but // and /*...*/ will probably work. > >If you're embedding the asm in a C file, then the preprocessor will >definitely run over the file, and that's the stage where comments are >removed. Yes, but cpp is only run on the .c file, and because c style comments aren't pruned out of strings, they won't work. It turns out that while this is true, though, as does some preprocessing of its own: ~~~~~~~~~~~~~~~~~~~ as.info: There are two ways of rendering comments to `as'. In both cases the comment is equivalent to one space. Anything from `/*' through the next `*/' is a comment. This means you may not nest these comments. /* The only way to include a newline ('\n') in a comment is to use this sort of comment. */ /* This sort of comment does not nest. */ Anything from the "line comment" character to the next newline is considered a comment and is ignored. The line comment character is `;' for the AMD 29K family; `;' on the ARC; `;' for the H8/300 family; `!' for the H8/500 family; `;' for the HPPA; `#' on the i960; `!' for the Hitachi SH; `!' on the SPARC; `#' on the m32r; `|' on the 680x0; `#' on the Vax; `!' for the Z8000; `#' on the V850; see *Note Machine Dependencies::. On some machines there are two different line comment characters. One character only begins a comment if it is the first non-whitespace character on a line, while the other always begins a comment. The V850 assembler also supports a double dash as starting a comment that extends to the end of the line. `--'; ~~~~~~~~~~~~~~~~~~~ There are heaps of things I don't like about inline assembler via gcc. if you're only ever writing entire functions, I reccomend creating a .S file and putting the function in it. (the default make rule for .S.o passes the file through cpp, before running it through as, which is quite handy; c-style #defines and #includes, for example). I'm also thinking of making a set of m4 macros to make inline assembler much cleaner, at the expense of another step in the makefile. Is anyone interested? Can anyone share examples from a compiler they think does it well? Toby.