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
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix 10 Jun 2005, 13:11
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



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 10 Jun 2005, 13:15
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 10 Jun 2005, 13:25
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 10 Jun 2005, 20:33
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



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 10 Jun 2005, 22:01
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



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 11 Jun 2005, 09:07
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 11 Jun 2005, 12:40
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



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 11 Jun 2005, 12:52
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 11 Jun 2005, 13:15
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



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 11 Jun 2005, 16:14
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 11 Jun 2005, 17:32
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



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 11 Jun 2005, 17:36
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 11 Jun 2005, 18:16
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 13 Jun 2005, 19:25
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



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 13 Jun 2005, 19:48
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
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 13 Jun 2005, 22:34
Hello everyone,
Will the old macro syntax be supported as well? maybe you can rename the macro folder oldmacros or something for compatibility. Two other requests, (1) could make an exit macro for the '.while' and '.repeat' macros, and (2) I posted this in the IDE forum but apparently nobody is looking so I'll post it here, Would it be to much trouble to add a 'block tab left' and a 'block tab right' to the edit menu, maybe in the options menu you can set the amount of spaces to tab over as well.
MadMatt
Post 13 Jun 2005, 22:34
View user's profile Send private message Reply with quote
halyavin



Joined: 21 Aug 2004
Posts: 42
halyavin 14 Jun 2005, 09:54
I need separate IncludeIGlobals and IncludeUGlobals macros.
Previously I use this:
Code:
IncludeIGlobals
endofcode: 
IncludeUGlobals
end_of_program:
    

What kglobals.inc I need now?
Post 14 Jun 2005, 09:54
View user's profile Send private message Visit poster's website Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 14 Jun 2005, 10:40
Yep, I think you, Privalov, should first add an obselete flag to each topic, or even better, make an obsolete section on this board. And I think it's not your response to move/reedit them all, but rather tell each moderator to move obsolete topics from his section into an own, obsolete section. Anyway, it will be hard work whatever you do.
Just think of all the work needed for all those people working on bigger projects in fasm, like Fresh or MenuetOS. Not quiet to mention the updating problems I got...

Luckily this only applies to the preprocessor, especially macro bodies, which usually doesn't make the most part of a code.

_________________
MCD - the inevitable return of the Mad Computer Doggy

-||__/
.|+-~
.|| ||


Last edited by MCD on 14 Jun 2005, 14:54; edited 1 time in total
Post 14 Jun 2005, 10:40
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8346
Location: Kraków, Poland
Tomasz Grysztar 14 Jun 2005, 14:11
halyalvin: I have updated the macros above.
Post 14 Jun 2005, 14:11
View user's profile Send private message Visit poster's website Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 14 Jun 2005, 14:53
WTH does "halyalvin:" mean?

upps, missed this strange nick Shocked Confused


Last edited by MCD on 15 Jun 2005, 08:23; edited 1 time in total
Post 14 Jun 2005, 14:53
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  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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.