flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Commenting out garbage: /* blah */ and skip blah endskip

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386
.
.

2 suggestions, one of them is old (sorry for pointing again), one new:

1. /* blah */

1.67.22 hack: http://board.flatassembler.net/topic.php?t=7115 (from 2007-May, almost 2 years ago)

I wrote:

> Making this official would be my wish for 1.67.23

Tomasz wrote:

> There are some other reasons why it has not been done.

Are they still valid ? The evil -D hack intruded into FASM in the meantime Shocked

The reason why I need it "badly" is here (posted 2008-Mar, 1 year ago) - disassembled opcodes in the source.

http://board.flatassembler.net/topic.php?p=73435#73435

2. Add directives skip and endskip

Very high priority directives for skipping large amount of garbage. I frequently have such garbage in my sources (porting from C Laughing ), if works very badly in such cases. This solution IMHO is 99.99999999999% fool-proof (AFAIK no programming language has an "endskip" keyword, nor it is a standard English word, nor some popular variable/label/comment string), superior to "comment" directive of MASM (if I guess correctly how it works there at all), and would allow anything inside the comment block, including "fix", unbalanced "if" / "endif" , unbalanced "/*" junk, just discarding everything until the "magic" word endskip is encountered Smile
Post 07 Mar 2009, 10:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16901
Location: In your JS exploiting you and your system
revolution
'end skip', with the space, would be more in keeping with the other block assembly directives (if, while, repeat).
Post 07 Mar 2009, 10:51
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16901
Location: In your JS exploiting you and your system
revolution
An option without this modification above is to use:
Code:
match +,-{
  stuff goes here
}    
The only change needed to "stuff goes here" is to make sure there are no bare closing curly brackets ('}'). Replace all closing curly brackets with a backslash-curly ('\}'). Most editors have good search and replace that can do this easily.
Post 07 Mar 2009, 11:32
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386
revolution wrote:
An option without this modification above is to use:
Code:
match +,-{
  stuff goes here
}    
The only change needed to "stuff goes here" is to make sure there are no bare closing curly brackets ('}'). Replace all closing curly brackets with a backslash-curly ('\}').


Thanks. Still, my skip and endskip or ( end skip ) solution would tolerate unbalanced curly brackets as well of course Smile

Quote:
Most editors have good search and replace that can do this easily.


Here the FASM IDE's do leave space for improvements. Wink

More: http://board.flatassembler.net/topic.php?p=112295#112295

EDIT : link to newer topic


Last edited by DOS386 on 23 Mar 2010, 09:37; edited 1 time in total
Post 07 Mar 2009, 12:40
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2145
Location: Estonia
Madis731
Actually I'm not against you - I also would like to have multiline comments, but your disassembly problem can be worked around:
1) Select the HEX-codes with FASMs very nice feature called Alt+Ins (a.k.a. 'vertical select')
2) Cut
3) Move to the end of the assembly-code and paste
4) Ctrl+H, replace ' 0000' with '; 0000'

The result:
Code:
      cmp eax,0x400        ; 00000377  81F800040000
      jnz near 0x388       ; 0000037D  0F8505000000
      call 0x31d           ; 00000383  E895FFFFFF  
      leave                ; 00000388  C9          
      ret                  ; 00000389  C3          
      push ebp             ; 0000038A  55          
      mov ebp,esp          ; 0000038B  89E5        
      sub esp,0x0          ; 0000038D  81EC00000000
      nop                  ; 00000393  90          
      mov eax,[ebp+0x8]    ; 00000394  8B4508      
      test eax,eax         ; 00000397  85C0        
      jnz near 0x3b6       ; 00000399  0F8517000000
      mov eax,[0x3030]     ; 0000039F  8B0530304000
      cmp eax,0x20000      ; 000003A5  81F800000200
      jnl near 0x3b6       ; 000003AB  0F8D05000000
      jmp 0x428            ; 000003B1  E972000000  
      mov eax,[0x3030]     ; 000003B6  8B0530304000
    


This example even fights agains the /* and */ construct, because you can't easily make the source commented with this. Very Happy Only regex would be a way out of this Razz

I've got one idea, though:
1) ...with Ctrl+H replace ' 0000' with '/* 0000'
2) copy the '/' and '*'-symbols separately and vertically to the end of the code

The result:
Code:
      cmp eax,0x400        /* 00000377  81F800040000  */
      jnz near 0x388       /* 0000037D  0F8505000000  */
      call 0x31d           /* 00000383  E895FFFFFF    */
      leave                /* 00000388  C9            */
      ret                  /* 00000389  C3            */
      push ebp             /* 0000038A  55            */
      mov ebp,esp          /* 0000038B  89E5          */
      sub esp,0x0          /* 0000038D  81EC00000000  */
      nop                  /* 00000393  90            */
      mov eax,[ebp+0x8]    /* 00000394  8B4508        */
      test eax,eax         /* 00000397  85C0          */
      jnz near 0x3b6       /* 00000399  0F8517000000  */
      mov eax,[0x3030]     /* 0000039F  8B0530304000  */
      cmp eax,0x20000      /* 000003A5  81F800000200  */
      jnl near 0x3b6       /* 000003AB  0F8D05000000  */
      jmp 0x428            /* 000003B1  E972000000    */
      mov eax,[0x3030]     /* 000003B6  8B0530304000  */
    
Post 07 Mar 2009, 16:22
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386
Madis731 wrote:
Actually I'm not against you - I also would like to have multiline comments, but your disassembly problem can be worked around


NO. I of course need the right side for "ordinary" comments.

Code:
/* 00000377  81F800040000 */     cmp eax,0x400 ; End of data ?
/* 0000037D  0F8505000000 */     jnz near 0x388  ; NO
/* 00000383  E895FFFFFF */       call 0x31d ; Finalize it
/* 00000388  C9 */               leave 
/* 00000389  C3 */               ret 
/* 0000038A  55  */              push ebp 
/* 0000038B  89E5 */             mov ebp,esp 
/* 0000038D  81EC00000000 */     sub esp,0x0  ; Very efficient compiler  
/* 00000393  90 */               nop 
/* 00000394  8B4508 */           mov eax,[ebp+0x8] ; "pSomeFunnyVariable"
/* 00000397  85C0 */             test eax,eax  ; CMPNTQ EAX, 0
/* 00000399  0F8517000000 */     jnz near 0x3b6 ; YES, it's empty
/* 0000039F  8B0530304000 */     mov eax,[0x3030] 
/* 000003A5  81F800000200 */     cmp eax,0x20000 ; 128 KiB
/* 000003AB  0F8D05000000 */     jnl near 0x3b6 
/* 000003B1  E972000000 */       jmp 0x428 ; Give up !!!
/* 000003B6  8B0530304000 */     mov eax,[0x3030] ; This sucks ....
    


Quote:
example even fights agains the /* and */ construct, because you can't easily make the source commented with this.


Trivial tool, not FASM IDE Wink

revolution wrote:
make sure there are no bare closing curly brackets ('}'). Replace all closing curly brackets with a backslash-curly ('\}').


The problem of all those macro/matcho hacks is that most programming languages do use it: C, PASCAL, and last but not least FASM itself.

Code:
 #include <stdio.h>
 
 int main(void)
 {
    printf("Hello, world!\n");
    return 0;
 }    
Post 08 Mar 2009, 08:38
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
DOS386 wrote:
.
.

2 suggestions, one of them is old (sorry for pointing again), one new:

1. /* blah */

1.67.22 hack: http://board.flatassembler.net/topic.php?t=7115 (from 2007-May, almost 2 years ago)

I wrote:

> Making this official would be my wish for 1.67.23

Tomasz wrote:

> There are some other reasons why it has not been done.

Are they still valid ? The evil -D hack intruded into FASM in the meantime Shocked

The reason why I need it "badly" is here (posted 2008-Mar, 1 year ago) - disassembled opcodes in the source.

http://board.flatassembler.net/topic.php?p=73435#73435

2. Add directives skip and endskip

Very high priority directives for skipping large amount of garbage. I frequently have such garbage in my sources (porting from C Laughing ), if works very badly in such cases. This solution IMHO is 99.99999999999% fool-proof (AFAIK no programming language has an "endskip" keyword, nor it is a standard English word, nor some popular variable/label/comment string), superior to "comment" directive of MASM (if I guess correctly how it works there at all), and would allow anything inside the comment block, including "fix", unbalanced "if" / "endif" , unbalanced "/*" junk, just discarding everything until the "magic" word endskip is encountered Smile
I think this is a bad idea.
It would be better to have "skip X" start and "X" end so it doesn't matter what is in the block, you can just use something not in it as the X. Smile
Post 01 Apr 2009, 23:19
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2800
Location: dank orb
bitRAKE
Azu wrote:
It would be better to have "skip X" start and "X" end so it doesn't matter what is in the block, you can just use something not in it as the X. Smile
Hopefully "X" is not limited to a single byte, or else UTF-8 encoded files could be a problem. If a non-first byte (of a multi-byte encoded character) matched "X" then the block might terminate prematurely.
Post 02 Apr 2009, 00:58
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
bitRAKE wrote:
Azu wrote:
It would be better to have "skip X" start and "X" end so it doesn't matter what is in the block, you can just use something not in it as the X. Smile
Hopefully "X" is not limited to a single byte, or else UTF-8 encoded files could be a problem. If a non-first byte (of a multi-byte encoded character) matched "X" then the block might terminate prematurely.

Nonono not limited to anything.
Post 02 Apr 2009, 03:06
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386
Azu wrote:
I think this is a bad idea. It would be better to have "skip X" start and "X" end so it doesn't matter what is in the block, you can just use something not in it as the X.


ONe char ? Bad idea. all chars are occupied Sad

Quote:
Hopefully "X" is not limited to a single byte, or else UTF-8 encoded files could be a problem.


Indeed. Something like:

Code:
skip mygarbage

#include <stdio.h>
 
 int main(void)
 {
    printf("Hello, world!\n");
    return 0;
 }

mygarbage

; FASM example of writing 16-bit DOS .COM program

format binary as "COM"
use16
org $0100

   mov  ah, 9
   mov  dx, txhello
   int  $21
   mov  ah, $4C
   int  $21

txhello: db "Hello world!$"
    

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 05 Apr 2009, 03:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16901
Location: In your JS exploiting you and your system
revolution
How about we use the MIME format for sources:
Code:
MIME-version: 1.0
Content-type: multipart/mixed; boundary="DOS386garbage"

--DOS386garbage
Content-type: asm/UTF8

; FASM example of writing 16-bit DOS .COM program

format binary as "COM"
use16
org $0100

   mov  ah, 9
   mov  dx, txhello
   int  $21
   mov  ah, $4C
   int  $21

txhello: db "Hello world!$" 

--DOS386garbage
Content-type: C/ASCII

#include <stdio.h>
 
 int main(void)
 {
    printf("Hello, world!\n");
    return 0;
 }
--DOS386garbage--    
Advantage: more flexible, each program can take the section it wants and compile it.

Wink
Post 05 Apr 2009, 04:43
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
DOS386 wrote:
Azu wrote:
bitRAKE wrote:
Azu wrote:
It would be better to have "skip X" start and "X" end so it doesn't matter what is in the block, you can just use something not in it as the X. Smile
Hopefully "X" is not limited to a single byte, or else UTF-8 encoded files could be a problem. If a non-first byte (of a multi-byte encoded character) matched "X" then the block might terminate prematurely.

Nonono not limited to anything.


ONe char ? Bad idea. all chars are occupied Sad
Bad reading skills.
Post 05 Apr 2009, 09:10
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386
Azu wrote:
DOS386 wrote:
Azu wrote:
Hell_Killer wrote:
bitRAKE wrote:
Azu wrote:
It would be better to have "skip X" start and "X" end so it doesn't matter what is in the block, you can just use something not in it as the X. Smile
Hopefully "X" is not limited to a single byte, or else UTF-8 encoded files could be a problem. If a non-first byte (of a multi-byte encoded character) matched "X" then the block might terminate prematurely.
Nonono not limited to anything.

Indeed
ONe char ? Bad idea. all chars are occupied Sad
Bad reading skills.
At least excellent quoting skills Shocked
Post 07 Apr 2009, 01:43
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
DOS386 wrote:
Hell_Killer wrote:
At least excellent quoting skills Shocked
Confused
Post 07 Apr 2009, 03:45
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 875
Location: Colombia
pelaillo
DOS386 wrote:
At least excellent quoting skills Shocked

First laugh of the day! Thanks Wink
Post 07 Apr 2009, 13:44
View user's profile Send private message Yahoo Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16901
Location: In your JS exploiting you and your system
revolution
Azu, when quoting his own post, wrote:
Hell_Killer wrote
Hmm?

Joining the dots ... Azu == Hell_Killer_SS Question

Freudian slip?
Post 07 Apr 2009, 13:52
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
revolution (apparently also plagued with the inability to read) wrote:
Azu wrote:
DOS386 wrote:
Hell_Killer wrote:
At least excellent quoting skills Shocked
Hmm?

Joining the dots ... Azu == Hell_Killer_SS Question

Freudian slip?
I'm starting to wonder if you people are just acting dumb on purpose as some kind of practical joke -.-


In case not; I was quoting DOS386, hence the "DOS386 wrote:", rather then "Azu wrote:".

I'm pretty sure it is the case though. You had to have gone out of your way on purpose to fuck up the quotes like that. Fixed it for you anyways.
Post 07 Apr 2009, 14:23
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16901
Location: In your JS exploiting you and your system
revolution
Oh no, I don't act dumb, I am dumb. But just the same I also like a good practical joke and you have seem to have your broken funny bone.
Post 07 Apr 2009, 14:35
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
Sorry, I just find it extremely annoying when multiple people deliberately misinterpret me for no reason, without making it clear whether they really are confused or just doing it on purpose..
Post 07 Apr 2009, 22:38
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2800
Location: dank orb
bitRAKE
It is best to repeat yourself Azu than to assume malice - so many here are not native speakers of English, and I think we are all learning to communicate better -- I know I am. Quoting doesn't work if the mis-communication persists. Rephrase and expound on your ideas, or draw a picture (ASCII art, lol).
Post 08 Apr 2009, 02:49
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2019, Tomasz Grysztar.

Powered by rwasa.