flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > about using < and > in macros

Author
Thread Post new topic Reply to topic
Blank



Joined: 28 Feb 2012
Posts: 13
Location: Ukraine
Blank
I'm interesting how works these braces in macros when they are used separetely.


Examples from standard includes:
proc32.inc:
Code:
macro proc [args] {                   ; define procedure
  common
              match name params, args> \{
                        define@proc name,<params
         \}
}
    

struct.inc:
Code:
; taken from 'struct' macro
   macro union \{ fields@struct equ fields@struct,,union,<
            sub@struct equ union
        \}
    macro struct \{
               fields@struct equ fields@struct,,substruct,<
             sub@struct equ substruct
    \}

;
; taken from 'ends' macro
;
       match any, sub@struct \{
              fields@struct equ fields@struct>
 \}

    




I presume(Correct me if I'm wrong) that in second code listing fields of struct are glued in <...>

But what in first listing?
Is there another tricky ways to use braces?
Post 10 Mar 2012, 13:35
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
Blank
In the first example both inequality signs are also joined together while the match-macroblock is expanded: the first token from the args is assigned to the token name and the rest, including the greater-than sign, is assigned to params.

Therefore after the match-macroblock expansion the second argument of the macro define@proc always starts with the less-than sign and ends with the greater-than sign.

P.S. A common suggestion for macro expansion tracing is to use the prepsrc tool from the fasm package (the tool can be compiled from the tools/win32 subdirectory). I prefer to use the automated way for engaging of such tools (including the fasm compiler itself) by using the following nppexec plugin script for notepad++:
Code:
NPP_SAVE
ENV_SET Include = [path to fasm dir]\Include;[path to a dir with my custom includes]\MyMacros
cd $(CURRENT_DIRECTORY)
[path to fasm dir]\fasm.exe -m 1572864 -s  "$(CURRENT_DIRECTORY)\$(NAME_PART).fas" "$(FULL_CURRENT_PATH)"
[path to fasm dir]\prepsrc.exe "$(CURRENT_DIRECTORY)\$(NAME_PART).fas" "$(CURRENT_DIRECTORY)\$(NAME_PART)_p.txt"
NPP_OPEN "$(CURRENT_DIRECTORY)\$(NAME_PART)_p.txt"
NPP_SENDMSG WM_COMMAND IDM_LANG_ASM    
Post 10 Mar 2012, 16:59
View user's profile Send private message Reply with quote
Blank



Joined: 28 Feb 2012
Posts: 13
Location: Ukraine
Blank
l_inc,
Of course! How am I couldn't guessed! It's coooool Very HappyVery HappyVery Happy!!!!
P.S: Thanks a lot for a prepsrc and plugin script - it would be useful!
P2.S: It seems 'prepsrc' works like 'fasmpre', but directly with source, rather than symbol dump.
Post 10 Mar 2012, 18:58
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.