Author Topic: The symbol "\" in a comment.  (Read 10625 times)

Offline wyvern666

  • Jr. Member
  • *
  • Posts: 32
The symbol "\" in a comment.
« on: January 11, 2012, 06:11:19 PM »
Hi all.

I understand the use of "\" when writing code. But if this symbol is used after a ";comment" the next code line will be ignored by NASM. I dont know if this can be considered a bug or not, or if have been reported already in the past. It isn't an important thing, but i just wanted inform about it as i think after the ";" that symbol could be ignored... or maybe not?.

Anyway, i found that situation with this commented code:
Code: [Select]
...
someRoutine:
        PUSH    ebp                 ;save calling stack frame                  \
        MOV     ebp, esp          ;new stack frame over caller`s stack   | function prologue           
        SUB     esp, 8              ;8 bytes for local variables                /
...
In that case the "MOV" instruction will be ignored.

Thanks.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: The symbol "\" in a comment.
« Reply #1 on: January 11, 2012, 06:52:59 PM »
Yeah... the '\' character is treated as a line-continuation character if it appears last in a line. Nasm needs to "get" a line from the file before it can "parse" the line to see if there's a comment in it, so it isn't possible to ignore it after ';'. This is intentional behavior, although it's inconvenient if you're trying to do "ascii art" in a comment. If you don't want '\' to be treated as a line-continuation character, put something after it. Even a space will work, although that might be confusing. This broke some existing code when it was introduced, which we try to avoid, but we really needed a line-continuation character...

Best,
Frank


Offline wyvern666

  • Jr. Member
  • *
  • Posts: 32
Re: The symbol "\" in a comment.
« Reply #2 on: January 11, 2012, 09:05:39 PM »
Yes, i figured out that with even a space after the "\" all will be ok  ;D. Thanks for your answer Frank, as always.