flat assembler
Message board for the users of flat assembler.

Index > Main > Redefining the syntax (flat assembler 1.61)

Goto page Previous  1, 2, 3, 4, 5  Next

Do you like the proposed changes (read below)?
Yes
96%
 96%  [ 24 ]
No
4%
 4%  [ 1 ]
Total Votes : 25

Author
Thread Post new topic Reply to topic
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
Why not create a new directive similar to fix except using the proposed changes? I understand about wanting cleanliness but how can we break backwards-compatibility?
However, I will agree if you give me a good reason. Would it be easy or hard to modify existing code to work with the new syntax change? I will vote no but I may change my mind if it isn't difficult to modify existing code. I think we should be backwards compatible if possible, but cleanliness is important too.
Post 09 Jun 2005, 18:35
View user's profile Send private message AIM Address Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
Read carefully everything that was posted so far (including the referenced threads) - I think all the explanations are already there.

What have I done is actually fixing the FIX directive to work exactly as it was defined in the manual. Breaking backward compatibility is acceptable when it is a bugfix, isn't it? Wink
Post 09 Jun 2005, 20:31
View user's profile Send private message Visit poster's website Reply with quote
Aster!x



Joined: 16 Jul 2004
Posts: 26
Aster!x
Privalov wrote:
.if eax = 4



Why not ==
?
Post 10 Jun 2005, 00:15
View user's profile Send private message Reply with quote
Chewy509



Joined: 19 Jun 2003
Posts: 297
Location: Bris-vegas, Australia
Chewy509
Privalov wrote:
Breaking backward compatibility is acceptable when it is a bugfix, isn't it? Wink

Of course it is. Smile
Post 10 Jun 2005, 03:29
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
With 1.61.12 another tiny new features come, extending the possible applications of STRUC directive. First is the new RESTRUC directive which exactly the same what PURGE, but for the structure macroinstructions.

The second new feature is that inside the structure macroinstruction the symbol consisting of single dot gets now replaced with the name of structure instance, and if preprocessor detects that this feature was used somewhere inside the structure, it doesn't generate the main label for structure automatically, allowing to do this definition in customized way. As an example, the structure macro from the manual improved with this new feature:
Code:
    struc db [data]
     {
      common
       . db data
       .size = $ - .
     }    

So with such structure macro defined, this code:
Code:
msg db 'Hello!',13,10    

will define the "msg.size" constant in addition to defining byte-labelled data in usual way. And also "sizeof.#. = $ - ." could be used to define constant like "sizeof.msg".
Post 10 Jun 2005, 12:57
View user's profile Send private message Visit poster's website Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Is it posiible to have 'Args' got all parameters in next code:

macro try [arg]
{
match Name : Args , arg
\{
show Name
show Args
\}
}

macro show [text]
{
forward
display `text,13,10
}

try AnyName : SubName1,SubName2
Code:

 It takes only 'SubName1' value.
 Regards.    

_________________
Flat Assembler is the best!
Post 10 Jun 2005, 13:11
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
You forgot the "common" keyword. Macro by default works as if it had "forward" in the beginning, so the match is peformed for each of the arguments separately, and only the first one actually matches.
Post 10 Jun 2005, 13:15
View user's profile Send private message Visit poster's website Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Thanks a lot. Stupid mistake.
Regards.
Post 10 Jun 2005, 13:25
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
just great work! I have been missing struc's "." feature for a long time. Also i thought you will make big mess with new features but it looks clear now.

BTW, what is "fix" good for now? (except altering macrosyntax to other keywords)

BTW2: I don't understand why the Include*Global in IncludeAllGlobals needs to be fixed (eg. why can't you use directly __Include*Global)
Post 10 Jun 2005, 20:33
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
Quote:
what is "fix" good for now? (except altering macrosyntax to other keywords)

Actually only for altering macrosyntax now.
Post 10 Jun 2005, 22:01
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
My first try to simulate MASM syntax with the new macro features allows to assemble such code:
Code:
RECT struct
  left   dd ?
  top    dd ?
  right  dd ?
  bottom dd ?
RECT ends

Demo proc a:BYTE, b:DWORD

     local c:WORD,d:RECT

        movzx     eax,[a]
        mov       [d.left],eax

        ret
Demo endp

Demo2 proc

      local d:DWORD

        mov     eax,[d]

Demo2 endp    

Here are the macros:
Code:
macro struct name
 { fields@struct equ name
   struc db val \{ fields@struct equ fields@struct,.,db,val \}
   struc dw val \{ fields@struct equ fields@struct,.,dw,val \}
   struc du val \{ fields@struct equ fields@struct,.,du,val \}
   struc dp val \{ fields@struct equ fields@struct,.,dp,val \}
   struc df val \{ fields@struct equ fields@struct,.,df,val \}
   struc dd val \{ fields@struct equ fields@struct,.,dd,val \}
   struc dq val \{ fields@struct equ fields@struct,.,dq,val \}
   struc dt val \{ fields@struct equ fields@struct,.,dt,val \} }

macro define@struct name,[field,type,default]
 { common struc name field \{
    match any, fields@struct \\{ fields@struct equ fields@struct,.,name,<field> \\}
    match , fields@struct \\{ label .
   forward
     match any, field \\\{ .#field type field \\\}
     match , field \\\{ .#field type default \\\}
   common \\} \}
   virtual at 0
    name name
    sizeof.#name = $ - name
   end virtual }

macro ends
 { restruc db,dw,du,dp,df,dd,dq,dt
   match fields,fields@struct \{ fields@struct equ
                                 define@struct fields \} }

struc struct
 { struct .
   name@struct equ . }

struc ends
 { match =.,name@struct \{ ends \} }

fields@struct equ

macro proc [params]
 { common
    match name arg,params
    \{ if used name
       name:
       defargs@proc arg \}
    match =all@args, all@args
    \{ if used params
       params:
       all@args equ \}
    local ..current,..size
    all@vars equ
    ..current = 0
    if ..ret | ..size
     push ebp
     mov ebp,esp
     if ..size
      sub esp,..size
     end if
    end if
    macro local [var]
    \{
       virtual at ebp-..size+..current
       match varname:vartype,var
       \\{
           macro label . \\\{ deflocal@proc .,: \\\}
           struc db val \\\{ deflocal@proc .,db val \\\}
           struc dw val \\\{ deflocal@proc .,dw val \\\}
           struc dp val \\\{ deflocal@proc .,dp val \\\}
           struc df val \\\{ deflocal@proc .,df val \\\}
           struc dd val \\\{ deflocal@proc .,dd val \\\}
           struc dt val \\\{ deflocal@proc .,dt val \\\}
           struc dq val \\\{ deflocal@proc .,dq val \\\}
           varname vartype
           purge label
           restruc db,dw,dp,df,dd,dt,dq
       \\}
       ..current = $-(ebp-..size)
       end virtual \}
    macro ret
     \{ ..size = (((..current-1) shr 2)+1) shl 2
        if ..ret | defined ..size
          leave
        end if
        if ..ret
         retn ..ret
        else
         retn
        end if \} }

macro defargs@proc [arg]
 { common
   virtual at ebp+8
   if ~ arg eq
   forward
     local ..arg,current@arg
     match argname:type, arg
      \{ current@arg equ argname
         label ..arg type
         argname equ ..arg
         if ( type in <pword,qword> )
           dq ?
         else
           dd ?
         end if \}
     match =current@arg,current@arg
      \{ current@arg equ arg
         arg equ ..arg
         ..arg dd ? \}
   common
     all@args equ current@arg
   forward
     restore current@arg
   common
     end if
     ..ret = $ - (ebp+8)
    end virtual }

macro deflocal@proc name,def
 { match any, all@vars \{ all@vars equ all@vars,name \}
   match ,all@vars \{ all@vars equ name \}
   local ..var
   name equ ..var
   ..var def }

struc byte { common . db ? }
struc word { common . dw ? }
struc dword { common . dd ? }
struc pword { common . dp ? }
struc qword { common . dq ? }
struc tword { common . dt ? }
struc dqword { common label . dqword
                   dq ?,? }

macro endp
 { purge return
   purge enter
   match all,all@args \{ restore all \}
   restore all@args
   match all,all@vars \{ restore all \}
   end if }

struc proc [params]
 { common proc . params
   name@proc equ . }

struc endp
 { match =.,name@proc \{ endp \} }

BYTE fix byte
WORD fix word
DWORD fix dword
PWORD fix pword
QWORD fix qword
TWORD fix tword
DQWORD fix dqword    


Last edited by Tomasz Grysztar on 11 Jun 2005, 14:23; edited 2 times in total
Post 11 Jun 2005, 09:07
View user's profile Send private message Visit poster's website Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
Wow, great work. I see that latest changes introduced lots of new possibilities and power to compiler.
But I got confused with all this new stuff, and can't understand how does it all work. Maybe someone who got it, would write some article, when the syntax would be finally redefined for 100% ??

And is it possible to change above macroses so that they would allow defining structure values in compile time? Eg.:
Code:
rect  RECT    100, 200, 300, 400
point POINT   100, 200    
I would change it if I could Sad
Post 11 Jun 2005, 12:40
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
They already are.

Edit: I have corrected them to handle nesting better, like:
Code:
POINT struct
  x dd ?
  y dd ?
POINT ends

RECT struct
  left   dd ?
  top    dd ?
  right  dd ?
  bottom dd ?
RECT ends

WINDOWPLACEMENT struct
  length           dd ?
  flags            dd ?
  showCmd          dd ?
  ptMinPosition    POINT
  ptMaxPosition    POINT
  rcNormalPosition RECT 0,0,100,100 ; default values may be specified aswell
WINDOWPLACEMENT ends

some WINDOWPLACEMENT sizeof.WINDOWPLACEMENT,0,0,<0,0>,<100,100>,<10,10,50,50>    


Last edited by Tomasz Grysztar on 11 Jun 2005, 14:02; edited 2 times in total
Post 11 Jun 2005, 12:52
View user's profile Send private message Visit poster's website Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
Oh, sorry I made a mistake because I copied only macro definitions then added my rect RECT 100, 200, 300, 400 and the compiler displayed "Illegal instruction". Sorry for abusing you with such stupid thing and thanks for reply

I guess the best way to understand new syntax is to practice so I'll try it and learn it (I hope Smile)
Post 11 Jun 2005, 13:15
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
As for writing the article, I'm working on the extended manual sections not only about the new features, but also about their interactions with the existing ones and generally about mixing many features to solve particular problem.

But since the syntax change has been established there will be one more important thing to do - update all the old threads that contains solutions that either have to be done differently or can be done much simpler now, so people searching the board won't get any obsolete stuff. It would be greated if someone could help me with doing this (at least with finding the threads that should get some updated info).
Post 11 Jun 2005, 16:14
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
privalov, i think you should develop new system to hold such information, not this forum. Maybe some HOW-TO-DO area on FASM site, wher you will have it all in form question-solution(s). Threads have many disadvantages, it's hard to find them, hard to maintain them, lot of unneeded posts, posts become irrelevant after edits etc.
Post 11 Jun 2005, 17:32
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
But those threads are there and I think we should do something with them, no matter whether some better resources are made - just so they won't confuse people. The simplest solution is just to remove all that gone obsolete, and I will do it eventually.

Also there are also ones listed in the "Macroinstruction FAQ", which is also a kind of how-to-do reference you mentioned.
Post 11 Jun 2005, 17:36
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
but very few of them. by the way, when you recheck old threads then please note all important of them somewhere so we have more complete list, thanks.
Maybe i'll help when i get back to school (dial-up 's dial-up)
Post 11 Jun 2005, 18:16
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
Privalov,
Sorry for bothering you again Embarassed But it is next time I have problems with changed preprocessor - new iglobal and uglobal macros can't handle new structures proprely... is there any way to fix it?
Post 13 Jun 2005, 19:25
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
I've cleaned them up, try it:
Code:
macro iglobal { IGlobals equ IGlobals,
                macro __IGlobalBlock { }

macro uglobal { UGlobals equ UGlobals,
                macro __UGlobalBlock { }

endg fix }

macro IncludeIGlobals { macro IGlobals dummy,[n] \{ __IGlobalBlock
                                                    purge __IGlobalBlock \}
                        match I, IGlobals \{ I \} }


macro IncludeUGlobals { macro UGlobals dummy,[n] \{ \common \local begin, size
                                                     begin = $
                                                     virtual at $
                                                    \forward
                                                     __UGlobalBlock
                                                     purge __UGlobalBlock
                                                    \common
                                                     size = $ - begin
                                                     end virtual
                                                     rb size \}
                        match U, UGlobals \{ U \} }

macro IncludeAllGlobals { IncludeIGlobals
                          IncludeUGlobals }    


Last edited by Tomasz Grysztar on 14 Jun 2005, 14:12; edited 2 times in total
Post 13 Jun 2005, 19:48
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 Previous  1, 2, 3, 4, 5  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-2020, Tomasz Grysztar.

Powered by rwasa.