flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Multiline /* ... */ comments in FASM.

Author
Thread Post new topic Reply to topic
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 27 May 2007, 17:54
I've just added two little blocks of instructions to the 'PREPROCE.INC' file to allow multiline C-style comments (i.e. /* .... */):

Added fragments:
Code:
      symbol_character:
        cmp     al,3Bh
        je      ignore_comment

        ;
        ; Looking for '/*' symbols (begin of multiline comment block).  ; \
        ;                                                               ;  \
                                                                        ;  |
        ; Looking for '/'.                                              ;  |
        ;                                                               ;  |
        cmp     al, 2Fh                                                 ;  |
        jne     @f                                                      ;  |
        lods    byte [esi]                                              ;  |
                                                                        ;  |
        ; Looking for '*'.                                              ;  |
        ;                                                               ;  |
        cmp     al, 2Ah                                                 ;   \ Lines added by
        je      multiline_comment                                       ;   / Mikolaj Hajduk
                                                                        ;  |  27.05.2007.
        ; Reloading previous value of esi register if read pair differs ;  |
        ; from '/*'.                                                    ;  |
        ;                                                               ;  |
        dec     esi                                                     ;  |
        dec     esi                                                     ;  |
        lods    byte [esi]                                              ;  |
                                                                        ;  /
      @@:                                                               ; /

        cmp     al,5Ch
    
and
Code:
      ;                                                                 ; \
      ; Cutting off multiline comment block.                            ;  \
      ;                                                                 ;  |
      multiline_comment:                                                ;  |
        lods    byte [esi]                                              ;  |
        or      al, al                                                  ;  |
        jz      line_end                                                ;  |
                                                                        ;  |
        cmp     al, 1Ah                                                 ;  |
        je      line_end                                                ;  |
                                                                        ;   \ Lines added by
        ; Looking for '*/' symbols (end of multiline comment block).    ;   / Mikolaj Hajduk
        ;                                                               ;  |  27.05.2007.
                                                                        ;  |
        ; Looking for '*'.                                              ;  |
        ;                                                               ;  |
        cmp     al, 2Ah                                                 ;  |
        jne     multiline_comment                                       ;  |
                                                                        ;  |
        ; Looking for '/'.                                              ;  |
        ;                                                               ;  |
        lods    byte [esi]                                              ;  |
        cmp     al, 2Fh                                                 ;  |
        jne     multiline_comment                                       ;  /
        jmp     convert_line_data                                       ; /

      ignore_comment:
    
Attached source of changed 'PREPROCE.INC'. Copy it to the '/SOURCE' directory and recompile ALL sources of fasm (remember about DOS, Linux etc. versions).

[EDIT]Added version of 'PREPROCE.INC' with my & Mr_Silent's improvements.[/EDIT]


Description: Version with my & Mr_Silent's improvements.
Download
Filename: PREPROCE.INC
Filesize: 51.69 KB
Downloaded: 910 Time(s)

Description: First version (only my improvements).
Download
Filename: PREPROCE.INC
Filesize: 49.48 KB
Downloaded: 825 Time(s)



Last edited by MHajduk on 28 May 2007, 13:13; edited 3 times in total
Post 27 May 2007, 17:54
View user's profile Send private message Visit poster's website Reply with quote
Ehtyar



Joined: 26 Sep 2006
Posts: 51
Ehtyar 27 May 2007, 21:22
Oh that is just sexy, what else can i say. Thank you Mikolaj. For those not bothered to recompile fasm, the topic of multiline comments in fasm has been solved using macros here.

Ehtyar.
Post 27 May 2007, 21:22
View user's profile Send private message Reply with quote
Mr_Silent



Joined: 25 Apr 2006
Posts: 30
Mr_Silent 27 May 2007, 23:10
2 MHajduk: Good start, but needs polishing. First, it breaks line numbering:
Code:
/*

*/
dd some_udefined_value
    

it shows error on line 2 but actually it is line 4. The more comments - the greater disarray.
Second, there are (AFAIK) two places in convert_line routine where comments are checked, and you hooked only one. As result:
Code:
dd \    ; fine
0

dd \ /* error */
0
    

Anyways, good work.
Post 27 May 2007, 23:10
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 27 May 2007, 23:27
nice job, it going to be highlighted.

Someone could also provide diff file for future compatibility
Post 27 May 2007, 23:27
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Mr_Silent



Joined: 25 Apr 2006
Posts: 30
Mr_Silent 28 May 2007, 10:43
Tried to fix those issues I mentioned above.
I wonder how many bugs are still left Smile


Description:
Download
Filename: PREPROCE.INC
Filesize: 51.69 KB
Downloaded: 866 Time(s)

Post 28 May 2007, 10:43
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 28 May 2007, 10:47
Thanks to all of you for good words. Smile
Post 28 May 2007, 10:47
View user's profile Send private message Visit poster's website Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 28 May 2007, 11:27
Mr_Silent
I've just tested 'PREPROCE.INC' with your changes - also good work. Smile

[EDIT]I've added to the first post in this thread 'PREPROCE.INC' with your improvements.[/EDIT]
Post 28 May 2007, 11:27
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 06 Aug 2007, 06:31
Making this official would be my wish for 1.67.23 Wink
Post 06 Aug 2007, 06:31
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 06 Aug 2007, 06:40
NTOSKRNL_VXE wrote:
Making this official would be my wish for 1.67.23 Wink
My too. Very Happy
Post 06 Aug 2007, 06:40
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 06 Aug 2007, 08:44
There are some other reasons why it has not been done.
Post 06 Aug 2007, 08:44
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 06 Aug 2007, 10:46
Some more hints about them available ?
Post 06 Aug 2007, 10:46
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 31 Aug 2007, 05:22
Tomasz Grysztar wrote:
There are some other reasons why it has not been done.


/*
Like what? Just ignore /* or */ inside any string literals and behind normal ; comment lines. (Sorry, I know it's not quite that simple, just saying ...)
*/


Smile
Post 31 Aug 2007, 05:22
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 06 Apr 2009, 16:36
What's the status on official support of this? Just wondering
Post 06 Apr 2009, 16:36
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
rxantos



Joined: 19 Jul 2008
Posts: 41
rxantos 22 Jun 2009, 15:31
This is useful as it would allow to use doxygen to comment assembly sourcecode. Of course, you will still need to use @fn, @struct, @typedef in the comment, but at least you can have the comment at the same place as the code. Instead of a different tile.

I hope it makes it to be official.
Post 22 Jun 2009, 15:31
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 23 Jun 2009, 09:53
rxantos wrote:
I hope it makes it to be official.
Now everything depends on Tomasz Grysztar's decision. Wink
Post 23 Jun 2009, 09:53
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 19 Aug 2009, 09:35
Tomasz Grysztar wrote:
There are some other reasons why it has not been done.
Just out of curiosity (not to be rude or disrespect your authority), what are they?
Post 19 Aug 2009, 09:35
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 19 Aug 2009, 10:30
Azu wrote:
Tomasz Grysztar wrote:
There are some other reasons why it has not been done.
Just out of curiosity (not to be rude or disrespect your authority), what are they?
Azu, it seems to be the one of best protected secrets of our world. Laughing
Post 19 Aug 2009, 10:30
View user's profile Send private message Visit poster's website Reply with quote
Plue



Joined: 15 Dec 2005
Posts: 151
Plue 19 Aug 2009, 19:33
What is wrong with if 0 .. end if?
Post 19 Aug 2009, 19:33
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 19 Aug 2009, 21:03
Try to compile this and find out.

Code:
blah equ db 0

if 0
    blah equ db error
   macro foo bar{
         if bar eq 1
                 db 3
                else
                        dd 12345678
         end if
      }
      foo 1
end if

blah    
Post 19 Aug 2009, 21:03
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.