As far as I can tell from the documentation, NASM
doesn't support multiline comments. It's a big pain
using semicolons at the front of each line, especially
when doing paragraph realignment. Please add this support.
Microsoft uses "COMMENT *" for this purpose, which you
might want for compatibility reasons. But it's
unwieldy. Perhaps an uncommon character, such as ~
(tilde) at the start and end of the field would make
more sense.
Logged In: NO
%if 0 ; anything that expands/evaluates to 0 (=false) will
do
Put multi-line
comments here.
%endif
Logged In: YES
user_id=581255
Indeed that's true. It's just less readable, since IF 0 is
usually used to comment-out code. If I try to be more
elegant about it by defining a COMMENT macro containing %IF
0, NASM doesn't like it. So if you don't add multiline
comment support, then I'll just have to accept that,
although it's less elegant. Anyway, thanks for the suggestion.
Logged In: NO
Adding support for COMMENT would require adding support
for [COMMENT]. However, as of writing this the primitive
assembler directives only operate on a single line, not
multiple lines. Though one could use backslashes to con-
catenate multiple lines into one [COMMENT] directive,
doing so would be as unwieldy as having to prefix each
line of the multi-line comment with a semicolon. Also,
since primitive assembler directives must be terminated
with a closing square bracket, the multi-line comment
could not contain that particular character. Which would
make [COMMENT] just as "nasty" as Microsoft's COMMENT:
the user would have to carefully avoid some character...
Now, though one could implement a %COMMENT directive in
the preprocessor, doing so would not make much sense: it
would become unavailable whenever the -a option is used,
and thus it wouldn't be much better than %IF 0...%ENDIF.
Also, one could implement a Microsoft-like COMMENT %...%
in nasm.c's no_pp_getline() and preproc.c's read_line().
However, doing so would introduce additional complexity,
and it would slow down those two functions, just for the
sake of supporting COMMENT %...%. IMO not a good thing.
Just my two cents.
If you fear that %IF 0 could be mistaken for commented
code, then you could %DEFINE COMMENT 0, and then use it
like %IF COMMENT. That would make it a bit more obvious.
Logged In: YES
user_id=581255
I would think that the following would be simple to
implement, but I must admit that I haven't seen the source:
If CommentFlag=1
Ignore whole line
Else
If line starts with "~"
CommentFlag=CommentFlag XOR 1
Else
Parse line normally.
End if
End if
and when the end of the file is reached
If CommentFlag=1
Print "You failed to close a multiline comment somewhere."
End if
"~" is so rare, especially at the beginning of a line, that
this seems to be a safe bet.
I don't know how this would work with "-a", however, since I
don't really know what "preprocessing" means.
Yes, %IF COMMENT does look better. Good idea.