flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > another approach (like TASM)

Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 28 Feb 2010, 21:09
hi, Wink

Here is another way to solve this problem!
Multiline comment/block like TASM.


-----------------------------------------------------------------
Turbo Assembler - Reference Guide - Version 1.0
Starts a comment block
COMMENT delimiter [text]
[ text]
delimiter

COMMENT ignores all text between the first delimiter
character and the line containing the next occurrence of
the delimiter. delimiter is the first nonblank character
after the COMMENT directive.
-----------------------------------------------------------------


Here is another approach to the problem.
Multiline/block comment, like TASM syntax.

--> But, a little more powerfull that original TASM syntax.

not :
"between the first delimiter character and the line
containing the next occurrence of the delimiter.
but,
between the first delimiter character ,
and the next occurrence of the delimiter.

Here, the delimiters for the beginning and the end are the same (they must be the same).
Therefore, impossible to allow nested comments.
That said, if i had a lot of fun to build the previous solution (with nested comments allowed "/ * */"),
... the concept of nested comments is ... slightly absurd
Comment comments ! Razz

Code:
everything below compiles ... and much more.
---------------------------------------------------
you must think as if the comments did not exist !

COMMENT X comment X
X = delimiter = first nonblank char.

@Intercept dw 1 dup (\  
\  
COMMENT*targetA1*0, COMMENT*targetA2* 0,COMMENT*targetA3* 0,\
COMMENT
+
     a-
  b-
  c-
+ 
COMMENT*targetB1*0, COMMENT* ;fasm  * 0,COMMENT*targetB3* 0,\
COMMENT*targetC1*0, COMMENT*targetC2* 0,COMMENT*targetC3* 0,\
COMMENT*targetD1*0, COMMENT*targetD2* 0,COMMENT*targetD3* 0)

db 0,"z"COMMENT"comment"

db 0, COMMENT"d"\
"a",COMMENT"text""1",\ 
3,COMMENT'text''b',\         ;== db 0,"a","1",3,'b',2,"c"
COMMENT|text|2,\
"c"

decCOMMENT+comment+ esi  ; == dec esi

db 0,\COMMENT?comment?
COMMENT + co
mment +1        

COMMENT
. 
targetA3 : text 
targetB3 : text 
targetC3 : text 
targetD3 : text 
.

db "COMMENT"COMMENT"comment","COMMENT"
; == db "COMMENT","COMMENT"

movCOMMENT+ 25h,                                     
33h + eax,COMMENT!=   ; == mov eax,ebx
=!ebxCOMMENT-|abc|-

db "4"
db 0,\COMMENT *
a
b   ; fasm
c
*
1

db 0,\    ; 5
COMMENT+comment+
1
;very easy and fun to put comments  Razz 
    

_________________
I am not young enough to know everything (Oscar Wilde)- Image


Last edited by ouadji on 21 Sep 2010, 20:29; edited 1 time in total
Post 28 Feb 2010, 21:09
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 01 Mar 2010, 06:46
I don't see how that is any clearer than your previous /* version. Looks rather cluttered to me.
Post 01 Mar 2010, 06:46
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 01 Mar 2010, 07:35

Nothing more, indeed. It's just another way to solve this feature.
To build Fasm, Tomasz took as a starting point TASM,
and has kept spirit of it. This way is maybe more in keeping with FASM spirit.
Prefer one or the other is just a matter of personal choice.

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 01 Mar 2010, 07:35
View user's profile Send private message Send e-mail Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 01 Mar 2010, 09:58

Quote:
from myself Razz

the concept of nested comments is ... slightly absurd.

That said,
there is a great advantage to be allowed to place nested comments.
Be Able to easily deactivate a block of code itself commented.(if not, too)
Code:
@Intercept dw 1 dup (\  
\ 
/*targetA1*/ 0, /*targetA2*/0,\ 
; .....
/*targetD1*/ 0, /*targetD2*/0)


/* <-------- code off
@Intercept dw 1 dup (\  
\ 
/*targetA1*/ 0, /*targetA2*/0,\
; ..... 
/*targetD1*/ 0, /*targetD2*/0)
*/ <--------

PS : Yes revolution ... we can also do as below, but above, it's easier !
(especially if there are 200 lines to disable)
Wink
;@Intercept dw 1 dup (\  
;\ 
;/*targetA1*/ 0, /*targetA2*/0,\ 
;; ..... 
;/*targetD1*/ 0, /*targetD2*/0)
    


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 01 Mar 2010, 09:58
View user's profile Send private message Send e-mail Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael 01 Mar 2010, 13:58
Even when you comment out large piece of code the semicolon is still very convenient - my text editor has a capability to (un)comment a block by inserting/deleting the semicolon at the beginning of the line, so I only have to select the code and let the editor do the rest of the work. Multiline comments are, at least for me, utterly useless. Of course they will be great for Notepad users.
Post 01 Mar 2010, 13:58
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 01 Mar 2010, 17:34

I'm agree, it's not an essential feature.
Just a comfort of use, a user-friendly feature.
Obviously, it's not a feature I use all the time, but when I need it, it's very useful.
Especially for big project that take time, with a team development.
That said ..simply .. be able to work without it doesn't prohibit to make easier life.
In fact, It's a personal choice.


_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 01 Mar 2010, 17:34
View user's profile Send private message Send e-mail Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4047
Location: vpcmpistri
bitRAKE 02 Mar 2010, 17:47
Since FASM works at the byte level on the text the delimiter would be limited to byte values. For example, UTF-8 could leave bytes following the end of comment for some encodings. Not that this is a problem - just a corner case to note. MASM's multi-line comment ends at the end-of-line after the delimiter - I presume for this reason.

Editors with line formating tools are great. I often reverse line order and sort lines. Programmable editors make reformatting data into comments easy as well.
Post 02 Mar 2010, 17:47
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 02 Mar 2010, 18:58

thank you bitRAKE for your reply.

my English is not very good (sorry)
i hope i understood the meaning of your sentences.
Quote:

the delimiter would be limited to byte values
no. I detect the word "COMMENT" without problems, I could also, for the delimiter,
detect any sequence with multibyte.
Quote:

UTF-8 could leave bytes following the end of comment for some encodings
MASM's multi-line comment ends at the end-of-line after the delimiter.
I presume for this reason.
indeed it's not a problem.
Everything can be analyzed, everything can be detected,
I don't see particular difficulties here.
I think the solution used by MASM is the solution "of the facility".

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 02 Mar 2010, 18:58
View user's profile Send private message Send e-mail 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.