flat assembler
Message board for the users of flat assembler.

flat assembler > Compiler Internals > suggestion /*Comments*/ (final rev.8 - over for me)

Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium

I found a bug (completely stupid) in the algorithm.
I modified the code of "convert_symbol:" in file "PREPROCE.INC" .
This to remove a "call" from it. Rolling Eyes Rolling Eyes
That said ... the algorithm worked perfectly before this change !
but modifying the code of "convert_symbol", I have changed the algorithm ... I had not seen it !
I can fix this in my code, no problem,
but there is useless to simplify the code to a place,
if it's to complicate it to another location..
Thus ... I return to the original code of "PREPROCE.INC, (my first love Razz ).
That's what happens when one tries to do too much !

No problem, this huge stupidity will be fixed in revision 7. Wink (soon)


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



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
sorry for this stupid error in version 6.
This version 7 is stable, and works fine.
and includes a checking of syntax of control word "init"

This command "INIT" is fun but in fact it has little utility.
The "IDLE" word control is powerful enough to prevent the rare cases
where multiline comments are a problem.
I think that eventually, this command has no really rationale.
Allow to change the symbols start/end is fun, but in practice, it's absurd.

The only case which has really been a problem is found in a macro created by Baldr
(I think especially for me Wink )
A macro a little bit artificial, in the words of Baldr.
And this case, almost unique, was solved without problem with the idle control.

Watch how this engine works, it's quite nice.
Code:
;Ouadji - Multiline Comments for FASM
;developed based on the first work of mikhajduk.
;=================================================
Multiline_Core: ;(7.1 - tuning of ".syntax:")

             cmp     al,"\"
           je      .BS.Core
            cmp     al,byte [@S_]
               je      .presumed
           cmp     al,"/"
            je      .presumed
           ret
                 
.presumed:      push    ebx
         mov     bx,[@S_]
            cmp     word [esi-1],bx
             pop     ebx
         je      .SL.Core
            cmp     word [esi-1],"/*"
         je      .SL.Core
            ret
;----------------------------------------------------------
.SL.Core:     pushad
              mov     ebp,esp
             xor     edi,edi
             inc     esi

             call    Search_absolute_end_comment
         jmp     .wayout
;----------------------------------------------------------
.BS.Core: pushad
              mov     ebp,esp
             xor     edi,edi
             xor     edx,edx

.BS.engine:
              call    Search_to_the_right
         jc      .wayout
             call    Search_absolute_end_comment
         jmp     .BS.engine
;----------------------------------------------------------

.wayout:   add     [esp+24h],edi ;<---line numbering
                mov     [esp+04h],esi ;<---hide comments

             cmp     edx,2
               popad
               jb      .direct

         dec     esi     ;closed (BS or SL)
          cmp     al,"\"
           jne     .final
              dec     esi
         ret

.direct: cmp     al,"\"       ;open or code (BS or SL)
            jne     .final
              mov     byte[esi-1],al
              ret

.final:          mov     [esp],eax
           mov     eax,[back_]
         xchg    eax,[esp]
           ret

;====================================================
Search_to_the_right:

            cmp     edx,2
               je      .failed
             xor     edx,edx

         mov     ecx,100h
            mov     ebx,-1

.loop_scan:   lods    byte [esi]

              call    Prohibited
          jz      .abortChar

              cmp     al,20h
              je      .nextScan
           cmp     al,09h
              je      .nextScan

               push    eax
         mov     ax,[@S_]
            cmp     word [esi-1],ax
             pop     eax
         je      .found
              cmp     word [esi-1],"/*"
         je      .found

          call    CRLF_
               jc      .firstTwo
           cmp     al,";"
            jne     .abortChar

.fasm:            lods    byte [esi]
          call    Prohibited
          jz      .abortChar
          call    CRLF_
               jnc     .fasm

.firstTwo:     inc     ebx
.nextScan:   loopz   .loop_scan
          jz      out_error

;----------------------------------------------------------

.two_crlf:      sub     edi,2   ;"edi" always >=2!
             sub     esi,4
               mov     word [esi],0A0Dh
            stc
         ret

.abortChar:      dec     esi
         or      edi,edi
             je      .failed
             dec     edi
         sub     esi,2
               mov     word [esi],0A0Dh
.failed:        stc
         ret

.found:          inc     esi   ;cy=0 from "je"
             ret

;====================================================
Search_absolute_end_comment:

            call    AccessRight
         jc      .done

           mov     ecx,1
               mov     ebx,20000h

.loopScan:        lods    byte [esi]

              call    Prohibited
          jz      out_error
           call    CRLF_
               jc      .gonext
             call    Nestings
            jecxz   .done     ;end_comment found!

.gonext:       sub     ebx,1
               jnc     .loopScan
           jmp     out_error

.done:             ret

;====================================================
Nestings:       push    edi
         movzx   eax,word[esi-1]
             mov     edi,+1
              cmp     ax,[@S_]
            je      .core
               neg     edi
         cmp     ax,[@E_]
            je      .core
               pop     edi
         ret     

.core:              add     esi,2
               shl     eax,8                   
            or      eax,22000022h
               cmp     dword[esi-4],eax
            je      .quoted
             xor     eax,("'..'" xor '".."') ;(")<=>(')  ;here,tks baldr!
            cmp     dword[esi-4],eax
            je      .quoted

         add     ecx,edi
             dec     esi
.quoted:     pop     edi
         ret

;====================================================
CRLF_:          cmp     al,0Dh
              je      .next
               cmp     al,0Ah
              je      .next
               clc
         ret
.next:               xor     al,(0Ah xor 0Dh) ;here,tks baldr!
           cmp     al,byte [esi]
               jne     .done
               inc     esi
.done:               inc     edi
         stc
         ret                     
;====================================================
AccessRight:
               cmp     byte [esi],"i"
            je      .confirm

.noCode:    cmp     [Gate],0
            jne     .back

.open:         mov     ax,[@S_]
            cmp     word [esi-2],ax
             jne     .back
               xor     edx,edx
             ret               ;nocy! (xor=clc)

.back:            mov     edx,2
               stc
         ret
.confirm:    
            mov     ecx,9
@@:                mov     al,byte [esi+ecx]
           call    Prohibited
          loopnz  @B
          jz      .noCode   ;ok=nz,bad=z

          call    IDLE_Code
           jc      .done
               call    INIT_Code
           jc      .done

           ;call   .mynextcode
         jnc     .noCode
.done:           ret

;====================================================
IDLE_Code:      cmp     dword [esi-2],'/*id'
              jne     .done
               cmp     dword [esi+2],'le!!'
              jne     .done

.idleCore:     add     esi,6
               not     [Gate] ;open<=>close gate
             mov     edx,1
               stc
         ret

.done:           clc   ;ok=cy(+edx),bad=nocy
         ret

;====================================================
INIT_Code:      push    esi
         cmp     dword [esi-2],'/*in'
              jne     .done
               cmp     dword [esi+2],'it!!'
              jne     .done

.initCore:     call    .syntax
             mov     [esp],esi
           mov     [@SE_],eax
          mov     edx,1
               pop     esi
         stc
         ret

.done:           pop     esi
         clc   ;ok=cy(+edx),bad=nocy
         ret
;--------------------------------------
.syntax:  cld
         push    edx

             mov     ecx,4
               add     esi,10
              mov     ah,(4*4)
            mov     edx,[esi-4]
         mov     ebx,init_syntax

.S.check:    rol     edx,8
               mov     al,dl
               xlat    byte[ebx]
           sub     ah,al
               or      al,al
               jne     @F
          mov     dl,"?"
@@:             loop    .S.check
            or      ah,ah
               jne     .fail.char
;--------------------------------------
               mov     eax,edx
             bswap   eax
         cmp     ax,dx
               jnz     .problem
            mov     eax,edx
             pop     edx
         ret

.problem:        xchg    ah,al
               cmp     ax,dx
               jz      .fail.inv
;--------------------------------------
.fail.seq:  mov     eax,3
               jmp     out_info
.fail.inv:      mov     eax,2
               jmp     out_info
.fail.char:     mov     [invalid.sequence],edx
              mov     eax,1
               jmp     out_info

;====================================================
Prohibited:        cmp     al,1Ah
              je      .done
               or      al,al
.done:             ret     ;z=pb. nz=ok

;====================================================
out_error:     mov     esp,ebp
             add     [esp+24h],edi
               popad
               mov     dword [esp],global_error
            jmp     assembler_error

out_info:    mov     esp,ebp
             add     [esp+24h],edi
               mov     [esp+1Ch],eax
               popad
               mov     eax,[message_list + eax*4]
          mov     [esp],eax
           jmp     assembler_error
;====================================================
;variables
;----------
Gate   dd 0
back_  dd ?
@S_    dw "/*"
@E_    dw "*/"

virtual at @S_
@SE_    dd ?
end virtual

init_syntax db 1 dup (\
\; 1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;1
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\ ;2
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4,\ ;3
4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\ ;4
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4,\ ;5
4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\ ;6
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 0,\ ;7
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;8
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;9
0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,\ ;A
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;B
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;C
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;D
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;E
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) ;F

;messages
;--------
global_error db 'error multiline comments',0
message_1    db 'INIT : invalid characters : '
invalid.sequence dd ?
db 0
message_2    db 'INIT : char ok but seq reversed',0
message_3    db 'INIT : char ok but seq prohibited',0

message_list:
;-----------
dd global_error
dd message_1
dd message_2
dd message_3
;====================================================
    


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


Last edited by ouadji on 21 Sep 2010, 20:30; edited 4 times in total
Post 15 Mar 2010, 23:04
View user's profile Send private message Send e-mail Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
ouadji: so, is there a description of rules for your /* */ usage?
Post 16 Mar 2010, 01:11
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium

rules ? only one :where you want, how you want.
"start" or "stop", inside a comment must be between quotes.
/*idle!! disable/enable multiline comment.
/*init!!xyyx changes start/stop
xyyx : identical, but reversed.
backslash effect jumps over comment.
Code:
endless possibilities ...

/*TEXT*/ mov eax,ebx

mov eax,/*
TEXT
*/ebx

;but also ....

db \ /*


/* 
0

mov /*TE... quoted "/*" or '*/' ...XT*/eax,/*TE
/*
TEXT
*/
XT*/ebx /*TEXT*/

db 0,1\ /*TEXT*/
/*
TEXT
*/
/*TEXT*/,2

struc array /*comment*/ [arg] /*hello*/ {
common
   match n def, /*comment*/ arg \{
/*comment*/ rept 1 %:1 \\{ /*comment*/ . def  \\}
/*comment*/ rept n-1 %:2 \/*v*/\/*v*/{ .\\#_/ comment 
                 */\\#% def \\}
     \}
/*comment*/ }
Smile

    

obviously, put comments anywhere is absurd.
it's only to shows the power of engine.

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



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium

rev 7.2
no change of use, but a code "more beautiful" and optimized.
about "search and management of codes"
old name in rev.7 :AccessRight
new name : Access_Settings
Code:
Access_Settings:
            cmp     word[esi-2],"/*"
          jne     .noCode
             call    .search_code
                jnc     .noCode ;"Z"
              ret     ;back to "Search_absolute_end_comment"

.noCode:    cmp     [Gate],0
            jne     .back

           mov     ax,[@S_]
            cmp     word [esi-2],ax
             jne     .back
               xor     edx,edx
             ret     ;nocy! (xor=clc)

.back:              mov     edx,2
               stc
         ret

;====================================================
.search_code:
               cld
         push    edi esi
             xor     edx,edx

.sc_:                mov     edi,[code_addr + edx]
               or      edi,edi
             jz      .zCode
              mov     ecx,100h
       repz cmpsb
               mov     al,[esi-1]
          call    Not_Legal ;new name of "Prohibited" in rev.7.0
            jz      .zCode
              cmp     byte[edi],0
         jz      .codefound
          add     edx,4
               mov     esi,[esp]
           jmp     .sc_

.zCode:         pop     esi edi
             ret     ;back to "Z" above (no code cy=0)
;-------------------------------------------
.codefound:  dec     esi
         pop     edi edi ; it's correct 2xedi
               call    dword [proc_addr + edx] 
            ret     ;"Y" (back to "Z" above)
;====================================================
IDLE_Code: not     [Gate] ;open<=>close gate
             mov     edx,1
               stc
         ret     ;back to "Y" above
;====================================================
INIT_Code: call    .syntax
             mov     [@SE_],eax ;"X"
           mov     edx,1
               stc
         ret     ;back to "Y" above

.syntax:        mov     ecx,4
               mov     dh,(4*4)
            mov     ebx,init_syntax

.S_check:    lods    byte[esi]
           mov     dl,al
               call    Not_Legal
           jz      .fail.seq
           xlat    byte[ebx]
           or      al,al
               jnz     @F
          mov     dl,"?"
@@:             xchg    al,dl
               ror     eax,8
               sub     dh,dl
               loop    .S_check
            jnz     .fail.char

;--------------------------------------
           mov     edx,eax
             bswap   edx
         cmp     ax,dx
               jnz     .seq_rev
            ret     ;----------> syntax ok (back to "X" above)
;--------------------------------------
.seq_rev:     xchg    dh,dl
               cmp     ax,dx
               jz      .fail.rev
;--------------------------------------
.fail.seq:  mov     eax,3
               jmp     out_info
.fail.rev:      mov     eax,2
               jmp     out_info
.fail.char:     mov     [invalid.sequence],eax
              mov     eax,1
               jmp     out_info
;=====================================
;changes in "Var_multi.INC"
code_addr:
dd code_a
dd code_b
dd 0
proc_addr:
dd IDLE_Code
dd INIT_Code

code_list:
code_a: db "idle!!",0FFh,0
code_b: db "init!!",0FFh,0
    


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



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium

Final revision 8, perfect code, perfect result !
I read again all messages and discussions about this subject.
Half of fasm users would like a solution.

I feel that my solution bothers and disturbs. There is no doubt.
Maybe the solutions "from outside" are not welcome, or unwanted.
I think so, it's a pity !


over for me
Code:
;Ouadji - Multiline Comments for FASM - Rev.8
;developed based on the first work of mikhajduk.
;====================================================
Multiline_Core:  
/*
               cmp     esi,[echo_]
         mov     [echo_],esi     ;redundant address
          je      .echo           ;jne>>je (~30x)
necessary in theory, but ineffective.
Because 93% of jumps are "jne". (the time-saver is negative)   
*/

               cmp     al,"\"  ;<---real start
               je      .Core_
              cmp     al,"/"
            je      .maybe
              cmp     al,byte [@S_]
               je      .maybe
.echo:            ret
                 
.maybe:         dec     esi
         bts     [omega],1
           cmp     word [esi],"/*"
           je      .Core_
              push    ebx
         mov     bx,[@S_]
            cmp     word [esi],bx
               pop     ebx
         je      .Core_
              btr     [omega],1
           inc     esi
         ret
;----------------------------------------------------------
.Core_:
           pushad
              mov     ebp,esp
             xor     edi,edi

.engine_:
                call    Search_to_the_right
         jc      .wayout
             call    Search_absolute_end_comment
         jz      \
.engine_

;====================================================
.wayout:     add     [esp+24h],edi ;<---line numbering
                mov     [esp+04h],esi ;<---hide comments

             popad
               push    ebx
         mov     ebx,[omega]
         mov     [omega],0

.action:   cmp     ebx,0000b
           je      .@0000
              cmp     ebx,0010b
           je      .@0010
              cmp     ebx,0110b
           je      .@0110

;-------------------------------------------

.@0100:           dec     esi
.@0110:              dec     esi
.@0000:              mov     byte [esi-1],al
             pop     ebx
         ret

.@0010:          mov     ebx,[back_]
         mov     [esp+4],ebx
         pop     ebx
         ret
;====================================================
Search_to_the_right:

                mov     ecx,100h
            mov     ebx,-1
              mov     edx,esi

.loop_scan:  lods    byte [esi]

              call    Not_Legal
           jz      .abortChar

              cmp     al,20h
              je      .nextScan
           cmp     al,09h
              je      .nextScan

               mov     ax,word [esi-1]
             cmp     ax,"/*"
           je      .found
              cmp     ax,[@S_]
            je      .found

          call    CRLF_
               jc      .firstTwo
           cmp     al,";"
            jne     .abortChar

.fasm:            lods    byte [esi]
          call    Not_Legal
           jz      .abortChar
          call    CRLF_
               jnc     .fasm

.firstTwo:     inc     ebx
.nextScan:   loopz   .loop_scan
          jz      out_error

;----------------------------------------------------------

.two_crlf:      dec     edi   ;"edi" always >=2!
               dec     esi
.notfirst:   dec     edi
         sub     esi,3
               mov     word [esi],0A0Dh
            stc
         ret

.abortChar:      or      edi,edi
             jne     .notfirst
           mov     esi,edx
             stc
         ret

.found:          inc     esi     ;cy=0 from "je .found"
            ret             ;here,ax=[esi-2]
;====================================================
Search_absolute_end_comment:

           call    Settings
            jc      .done

           mov     ecx,1
               mov     ebx,20000h

.loopScan:        lods    byte [esi]

              call    Not_Legal
           jz      out_error
           call    CRLF_
               jc      .gonext
             call    Nestings
            jecxz   .done     ;end_comment found!

.gonext:       sub     ebx,1
               jnc     .loopScan
           jmp     out_error

.done:             test    [omega],0110b
               ret
;====================================================
Nestings:   push    edi
         movzx   eax,word[esi-1]
             mov     edi,+1
              cmp     ax,[@S_]
            je      .core
               neg     edi
         cmp     ax,[@E_]
            je      .core
               pop     edi
         ret     

.core:              add     esi,2
               shl     eax,8                   
            or      eax,22000022h
               cmp     dword[esi-4],eax
            je      .quoted
             xor     eax,("'..'" xor '".."') ;here,tks baldr!
            cmp     dword[esi-4],eax
            je      .quoted

         add     ecx,edi
             dec     esi
.quoted:     pop     edi
         ret
;===================================================
CRLF_:               cmp     al,0Dh
              je      .next
               cmp     al,0Ah
              je      .next
               clc
         ret
.next:               xor     al,(0Ah xor 0Dh) ;here,tks baldr!
           cmp     al,[esi]
            jne     .done
               inc     esi
.done:               inc     edi
         stc
         ret                     
;====================================================
Settings:      cmp     ax,"/*"       ;ax=word[esi-2]
             jne     .noCode
             call    .search_code
                jnc     .noCode
             ret

.noCode: bt      [Gate],0
            jc      .refused
            cmp     ax,[@S_]
            jne     .refused
            ret

.refused:        or      [omega],0100b
               stc
         ret
;====================================================
.search_code:
           cld
         push    edi esi
             xor     edx,edx

.search:     mov     edi,[code_addr + edx]
               or      edi,edi
             jz      .zCode
              mov     ecx,100h

          repz  cmpsb
               mov     cl,[esi-1]
          cmp     cl,1Ah
              je      .zCode
              or      cl,cl
               jz      .zCode
              cmp     byte[edi],0
         jz      .codefound
          add     edx,4
               mov     esi,[esp]
           jmp     .search

.zCode:              pop     esi edi   ;from "jz"=nocy=nocode
          ret
;-------------------------------------------
.codefound:  dec     esi
         pop     edi edi
             call    dword [proc_addr + edx]   ;address proc code
                ret
;====================================================
IDLE_Code:  btc     [Gate],0 ;open<=>close gate
           stc
         ret
;====================================================
INIT_Code:  call    .syntax
             mov     [@SE_],eax
          stc
         ret
                 
.syntax:        mov     ecx,4
               mov     dh,(4*4)
            mov     ebx,init_syntax

.S_check:    lods    byte[esi]
           call    Not_Legal
           jz      .fail.seq
           mov     dl,al
               xlat    byte[ebx]
           or      al,al
               jnz     @F
          mov     dl,"?"
@@:             xchg    al,dl
               ror     eax,8
               sub     dh,dl
               loop    .S_check
            jnz     .fail.char

;--------------------------------------
           mov     edx,eax
             bswap   edx
         cmp     ax,dx
               jne     .seq_rev
            ret     ;-------------------->syntax ok
;--------------------------------------
.seq_rev:  xchg    dh,dl
               cmp     ax,dx
               je      .fail.rev
;--------------------------------------
.fail.seq:  mov     eax,3
               jmp     out_info
.fail.rev:      mov     eax,2
               jmp     out_info
.fail.char:     mov     [invalid.sequence],eax
              mov     eax,1
               jmp     out_info
;====================================================
Not_Legal:     cmp     al,1Ah
              je      .done
               or      al,al
.done:             ret     ;z=pb. nz=ok
;====================================================
out_error: mov     esp,ebp
             add     [esp+24h],edi
               popad
               mov     dword [esp],global_error
            jmp     assembler_error

out_info:    mov     esp,ebp
             add     [esp+24h],edi
               mov     [esp+1Ch],eax
               popad
               mov     eax,[message_list + eax*4]
          mov     [esp],eax
           jmp     assembler_error
;====================================================
;variables for Core_multi.INC
;----------------------------
omega  dd 0
Gate   dd 0
back_  dd ?
echo_   dd 0
@S_    dw "/*"
@E_    dw "*/"

virtual at @S_
@SE_    dd ?
end virtual
;------------------------------------------------------------------------------
init_syntax db 1 dup (\
\; 1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;1
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\ ;2
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4,\ ;3
4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\ ;4
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4,\ ;5
4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\ ;6
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 0,\ ;7
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;8
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;9
0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,\ ;A
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;B
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;C
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;D
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ ;E
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) ;F
;------------------------------------------------------------------------------
message_list:
dd global_error
dd message_1
dd message_2
dd message_3

global_error db 'error multiline comments',0
message_1    db 'INIT : invalid characters : '
invalid.sequence dd ?
db 0
message_2    db 'INIT : char ok but seq reversed',0
message_3    db 'INIT : char ok but seq prohibited',0
;------------------------------------------------------------------------------
code_addr:
dd code_a
dd code_b
dd 0
proc_addr:
dd IDLE_Code
dd INIT_Code

code_list:
code_a: db "idle!!",0FFh,0
code_b: db "init!!",0FFh,0
;====================================================
    
Code:
from PREPROCE.INC

.....
convert_line_data:
.....
 jz convert_separator
        cmp ah,27h
  cmp ah,22h
  je convert_string
;======================================
        mov [back_],convert_line_data
       call Multiline_Core ;---------------> n°1a
;======================================
   mov byte [edi],1Ah
  scas word [edi]
     xchg al,ah
  stos byte [edi]
     mov ebx,characters
  xor ecx,ecx
convert_symbol:
  lods byte [esi]
;======================================
  mov [back_],convert_symbol
  call Multiline_Core ;---------------> n°1b
;======================================
   stos byte [edi]
     xlat byte [ebx]
     or al,al
    loopnzd convert_symbol
      neg ecx
     cmp ecx,255
 ja name_too_long
    mov ebx,edi
 sub ebx,ecx
 mov byte [ebx-2],cl
found_separator:
 dec edi
     mov ah,[esi-1]
convert_separator:
    xchg al,ah
  cmp al,20h
  jb control_character
        je convert_line_data
symbol_character:
       cmp al,3Bh
  je ignore_comment
;======================================
        mov [back_],convert_line_data
       call Multiline_Core ;---------------> n°2a 
;======================================
  cmp al,5Ch
  je backslash_character
      stos byte [edi]
     jmp convert_line_data
control_character:
.....
.....
group_backslashes:
 lods byte [esi]
     cmp al,5Ch
  jne backslashed_symbol
;======================================
   call Multiline_Core ;---------------> n°2b
;======================================
   stos byte [edi]
     inc byte [ecx]
      jmp group_backslashes
backslashed_symbol:
.....
.....
    


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



Joined: 04 Mar 2008
Posts: 563
Location: Germany
ouadji wrote:
over for me

Ok, pause button, trink something fresh Cool considering
(if not yet discussed) the reasons why it was
not implemented.

ouadji wrote:
I feel that my solution bothers and disturbs.

Not me, surely.

I have not read the code-fragment, but you could try to explain to a simple
person like me in few lines, 3,4 or 5, the design of your fragment,
and how it works on the preexistent code. If you succeed i will implement
it in my local fasm. And if i compile something with it i will attach,

... copyright is Tomasz la la la,

...commented with the commentor engine, fragment of
ouadji from Belgium.
No kidding now.

But if you fail, Twisted Evil ... dont worry because this is a low-level-emotion forum, and after all nothing important will ever change...
for a while...

But I am really curious. Forge up something hi--hi -hi-emotional
to show me teorethically that it is not a superficial
(oberflächig bis zum Unsinn, meine ich, typisch HLL) modification.

After 127 active replies on this thread, considering the
fragment in ~320 lines without comments, there is a passive bug
~ every second line (if my mod-brain works).

But i cannot state it because, as i said, read i no code didnt.

i hope it helps, Very Happy
Cheers,
hopcode

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 20 Mar 2010, 23:14
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
Quote:

I have not read the code-fragment, but you could try to explain to a simple
person like me in few lines, 3,4 or 5, the design of your fragment,
and how it works on the preexistent code. If you succeed i will implement
it in my local fasm. And if i compile something with it i will attach,

multiline/block comment for fasm. (C-style)
it has already been explained extensively in all the previous messages of this topic.
If you want to try it, here is the compiled version.
it is impossible to explain the operation of this engine in a few lines.
Code:
endless possibilities ...
comments... as you want, wherever you want.
/*comment*/
control words : /*idle!! and /*init!!xyyx (see previous messages)
Nestings comments allowed.

/*TEXT*/ mov eax,ebx 

mov eax,/* 
TEXT 
*/ebx 

;but also .... 

mov /*TEXT*/eax,/*TE 
/* 
TEXT 
*/ 
XT*/ebx /*TEXT*/ 

db 0,1\ /*TEXT*/ 
/* 
TEXT 
*/ 
/*TEXT*/,2 

struc array /*TEXT*/ [arg/*TEXT*/] /*TEXT*/ { 
common 
        match n def, /*TEXT*/ arg \{ 
/*TEXT*/ rept 1 %/*TEXT*/:1 \\{ /*TEXT*/ . def  \\} 
/*TEXT*/ rept n-1 %:2 \/*TEXT*/\/*TEXT*/{ .\\#_/* comment  
                        */\\#% def \/*TEXT*/\} 
        \} 
/*TEXT*/ }

Place comments anywhere is absurd !!
It's just to show the power of the engine.
    
Quote:

to show me teorethically that it is not a superficial
clic here

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


Last edited by ouadji on 21 Sep 2010, 20:27; edited 3 times in total
Post 21 Mar 2010, 00:52
View user's profile Send private message Send e-mail Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1904
ouadji wrote:
Final revision 8, perfect code, perfect result !
I read again all messages and discussions about this subject.
Half of fasm users would like a solution.


The latest RAR does not have the PREPROCE.INC - could you please include this file too (the only one modified source file ?).
Post 21 Mar 2010, 01:01
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium

yes, PREPROCE.INC is the only modified file.


version 9 in progress,
to be able to place also the control words inside comments themselves
it is almost finished.

_________________
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 21 Mar 2010, 01:13
View user's profile Send private message Send e-mail Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
in the meanwhile i read
Quote:
version 9 in process...
it is almost finished.


Quote:
clic here

erm... let me see one moment...elaboratink..sputnink...
Ready:

YES=8
tom tobias
MCD
Matrix
f0dder
mike.dld
Kain
Octavio
PopeInnocent

NO=6
Frank
Madis731
rea
JohnFound
THEWizardGenius
r22

PROPOSAL / CREATIVE =5
vbVeryBeginner
vid
UCM
Pirata Derek
kake_zinger

The fact is that the YES-people, apart f0dder, are not so active-posters like the sum of NO-people and YES-but-creative.

ouadji wrote:
...it is impossible to explain the operation of this engine in a few lines...
please dont tell it so ! Consider this: If Tomasz, from the 2004, the age of the poll-thread above till now
has not yet pronounced his YES to the block commentor feature, nothing will be impossible on this world !!!

Ok..Ok..., i will give a try. I am open to the future. Very Happy
And (almost forgotten) thanks for your code.

Cheers, Very Happy
hopcode

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 21 Mar 2010, 01:48
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Wow, that's awesome, way too much work for me though Smile. If you just want simple /* to */ without all the other things you added try the attached. Very simple, but it works(I did it all in the last 30 min Smile.
Code:
convert_line_data:
    cmp     edi,[memory_end]
    jae     out_of_memory
       lods    byte [esi] ; EVERY byte goes through this
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Begin My addition
        cmp     al, '/' ; if it's a '/' then I need to check if it's got a '*' behind it
        je      multilinecomment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End 
  cmp     al,20h ; all of the comment will be seen by Fasm as 0x20s after I overwrite it
      je      convert_line_data
    

[crap load of code]
Code:
multilinecomment:
        pushad                           
        lodsb
        cmp al, '*'                              ; chech if next char is '*'
        jne multilinecomment_done                ; if it isn't, i'm done
        mov word[esi - 2], '  '                  ; block out '/*' with spaces
        multilinecomment_not_done:
                mov byte [esi - 1], ' '          ; if i'm here, the last char needs to be blocked out(I realize the original '*' gets overwritten twice though)
                lodsb                            ; get the next char
                cmp al, '*'                      ; check if it's a '/'
                jne multilinecomment_not_done
                cmp byte[esi], '/'               ; is the next char a /
                jne multilinecomment_not_done
                mov dword [esi - 3], '    '
        multilinecomment_done:
        popad
        jmp convert_line_data
    

All mine does is overwrite the /**/ and the stuff in between with 0x20, so the when I restore esi, Fasm processes it as spaces. What do you think?


Description: Altered preproce.inc
Download
Filename: preproce.inc
Filesize: 46.47 KB
Downloaded: 274 Time(s)

Post 21 Mar 2010, 05:47
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1904
ouadji wrote:
version 9 in progress, to be able to place also the control words inside comments themselves it is almost finished.


Please include complete source or all modified or added source files then (FASMW.ASM & Co).


Last edited by DOS386 on 23 Mar 2010, 08:02; edited 1 time in total
Post 21 Mar 2010, 07:19
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium

Quote:

Please include complete source or all modified or added source files
a) PREPROCE.INC in the only modified file.
in PREPROCE.INC, 4 calls to "Multiline_Core"
b) the code of Multiline_Core is above. (PREPROCE_8.INC too)
Quote:

fromTyler:

Wow, that's awesome, way too much work for me though . If you just want simple /* to */ without all the other things you added try the attached. Very simple, but it works(I did it all in the last 30 min
Does your code work with all previous examples of this topic ?

As I said ,"over for me", too much inertia to change.
And after much thoughtful, ";" and "macro" are the best solutions. Razz



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



Joined: 04 Mar 2008
Posts: 563
Location: Germany
ouadji wrote:
As I said ,"over for me"...

Ok, if the code is buggy i dont know, every code is buggy. I have not yet tested it; that makes no difference. But this
Quote:
And after much thoughtful, ";" and "macro" are the best solutions.
Please, why so a turn ? ouadji, please...
Why confirming me again that i was right with my opinion about this forum ?...
There is no good, no open future in this way.
Ok,Very Happy
i do you the last proposal. You could implement it in the
Scintilla lexer. Look there or try it for assembler lexer...
I am sure of this: You come here again to tell me that a theorethical explanation of the design of your code is
possible and simple in 3,4 or 5 lines.

You know, i am a simple person
Cheers, Very Happy
hopcode

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 21 Mar 2010, 10:11
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Should quotes be closed, Fasm just crashed because I made it skip strings(I didn't close the quotes), or should quotes be ignored?
Here's the problem
Code:
/*"*/ ; will loop until finding the next ", but the quotation mark happens to be outside the comment, causing an infinite loop
    

That's easily fixable, I just need to know if I skip ""s. So that this will assemble
Code:
/*
mov ax, "*/"
*/
    

Quote:

Does your code work with all previous examples of this topic ?

No. Mine works with what is necessary, imposing a few logical constraints in order to keep simplicity, like, one must put a space in between any directive or opcode and the beginning of the comment.
Code:
org/*stuff
*/0x100 /*DOESN'T WORK*/

org /*stuff
*/0x100 /*DOES WORK*/
    

I didn't fix this because it's pointless and I didn't want to put a checker in convert_symbol function. I'm actually not sure if the above works with the code I gave, I've been toying with it since then. One helpful thing is that I have a Fasm that can do the most useful kind of block comments
Code:
/*
code...
*/
    

Honestly, this is all I foresee using block comments for(debugging without drastically modifying code or putting 100 ;s). I'm working on the having to put a space after the directives.
Post 21 Mar 2010, 10:22
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
Quote:

if the code is buggy i dont know, every code is buggy...
my code ? buggy ? ... Shocked
no, my code is perfect. Wink
Quote:

Please, why so a turn ? ouadji, please...
sorry but I fed up!


@Tylrer :
all the problems you mention were part of my first attempts.
My current code has fixed all that and is very powerful.
Code:
/*"*/ 
    

no problem with mine.
i search "/*" or '/*' not only " or '

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 21 Mar 2010, 10:35
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7322
Location: Kraków, Poland
As it seems that my official opinion about this subject is not really easy to find out on this forums (well, it was so long ago, that perhaps this board did not even exist at the time). Well, there is some mention about my position made by Tom Tobias, but that's about all.

Thus I'm going to recapitulate: no, I don't plan to implement such feature (and even if I were, it would be likely MASM/TASM-style COMMENT directive, which was a line-based one, not any C-style comments that can be inserted in the middle of a line). The reasons for my decision are quite nicely summarized by this post from JohnFound.

As for quickly commenting large block of code, there was a plan that such a feature of editor (insert/remove semicolons from the beginnings of lines in the selected text) would be implemented as a plugin for fasmw (by the way, there are other editors that have such feature already and can be used with fasm). However the plugin system for fasmw is something like a Duke Nukem Forever project. I started it at the same time, when I was writing fasmw itself, but never actually came near to finishing it. I still hope I manage to release it someday.

And as for the topic of other people contributing something to fasm, check out this thread.
Post 21 Mar 2010, 12:39
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium

thank you Tomasz for your reply.

I fully understand your opinion and I respect it.
Quote:

... likely Tasm-style (line-based) ...
like this :
Code:
code
...
COMMENT 
*
text
text
*
...    ; no insertion in the middle of a line
code
    

once again, I respect your view.

However, this doesn't meet the needs of users.
Of course, I speak of users who would like a extended functionality about this.
In this case, it is better to do nothing and keep what currently exists.(";")
This would complicate Fasm with a feature that, indeed, would respect the asm spirit,
but which in practice would be almost useless.

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



Joined: 04 Sep 2009
Posts: 295
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
I entered some modifications into the code. Now it should work. Try out.


Description:
Download
Filename: MULTILN.RAR
Filesize: 6.99 KB
Downloaded: 385 Time(s)

Post 09 Apr 2010, 16:37
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  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.