flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Label Macro

Author
Thread Post new topic Reply to topic
KronosRJ



Joined: 03 Jul 2005
Posts: 15
KronosRJ 14 Nov 2005, 14:03
Hi,

I noticed that in the proc macro Privalov redefines db , dw , dd , ... structures so that they get a new meaning inside the locals ... endl block.

I noticed that there is also a macro named label defined, and I suppose that this macro catches all label definitions so as to redefine them, so as not to have labels inside the procedures and also to create symbols for fake labels in local data.

I tried using a label macro inside some of my code, but it just did not work.

How do I use the mechanism Privalov used? What defines that any label thereafter will be treated as a macro execution, and that macro particularly?

Any help would be throughly appreciated.

I would post my macros here, but they are somewhat big (they include some OO macros and win32 exception handling macros also). If anybody feels the need of these to give a look at the problem, I will happily post them.
Post 14 Nov 2005, 14:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20523
Location: In your JS exploiting you and your system
revolution 15 Nov 2005, 01:40
Code:
macro label a,b,c { nop }    
Works for me. I think you should post you macros, or perhaps just a relavant subset of macros. Try to reduce the problem to a minimal set to highlight where the problem is.
Post 15 Nov 2005, 01:40
View user's profile Send private message Visit poster's website Reply with quote
KronosRJ



Joined: 03 Jul 2005
Posts: 15
KronosRJ 15 Nov 2005, 03:51
I wanted to do something like

Code:
struc MyClass{
   .m_pvTable dd ?
   .m_cRefs dd ?
}

MyProc QueryInterface , ... (my proc flags)...
MYLOCAL
   xpto MyClass
ENDLOCAL
    


I know that Privalov has already developed this solution, and it must work great...

I also know that this code inside the MYLOCAL ... ENDLOCAL will work with new structures on db , dw , dd , etc...
The thing is, the code inside MYLOCAL ... ENDLOCAL will also generate a xpto label, which I will need to capture and treat in a macro, otherwise this will 'break' my main label (ie any .label after MYLOCAL ... ENDLOCAL will not work; it will be xpto.label instead of QueryInterface.label).

I know fasm is working as expected (and as explained by Privalov). I just wanted to understand what mechanism tells the preprocessor to use the label macro to preprocess labels, instead of just placing the label there...

In my code, I tried copying the macro label, but it is not working (the db , dw , dd ... structures are working just fine - my problem is with the labels).

Code:
                                        macro label name \\\\{ deflocal a_strClass , a_strProc, t_strStack ,  . , : , \\\\}
                                        struc dp [val] \\\\{ \\\\common deflocal a_strClass , a_strProc , t_strStack , . , dp , val \\\\}                               
                                        struc dq [val] \\\\{ \\\\common deflocal a_strClass , a_strProc , t_strStack , . , dq , val \\\\}                               
                                        struc dt [val] \\\\{ \\\\common deflocal a_strClass , a_strProc , t_strStack , . , dt , val \\\\}                               
                                        struc dd [val] \\\\{ \\\\common deflocal a_strClass , a_strProc , t_strStack , . , dd , val \\\\}                               
                                        struc dw [val] \\\\{ \\\\common deflocal a_strClass , a_strProc , t_strStack , . , dw , val \\\\}                               
                                        struc db [val] \\\\{ \\\\common deflocal a_strClass , a_strProc , t_strStack , . , db , val \\\\}                               
    


I would like to remember you that, in the example above, the db , dw, dd ... structures are doing their job just fine... My problem is with the label macro...

Thanks for any clue you might give me.
Post 15 Nov 2005, 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: 20523
Location: In your JS exploiting you and your system
revolution 15 Nov 2005, 05:29
I think I see your problem. Look at the "struct" macro in the FASM package. That may answer your question as to how it all works. If you use the basic "struc" then it will fail to work the way you want.
Post 15 Nov 2005, 05:29
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8367
Location: Kraków, Poland
Tomasz Grysztar 15 Nov 2005, 10:00
That's right. "struct" uses the "label" to define its main label, so it can be then overriden by the "label" definition provided by "local". With "struc" it won't work.

This thread belongs to the "Macroinstructions", not "Compiler internals", thus I'm moving it.
Post 15 Nov 2005, 10:00
View user's profile Send private message Visit poster's website Reply with quote
KronosRJ



Joined: 03 Jul 2005
Posts: 15
KronosRJ 16 Nov 2005, 01:07
I took some time to understand you guys, but I finally did it...

My classes are based on strucs, not virtuals, and now I can do local variables as well...

THANK YOU!!!!!

U GUYS DA MEN!!!!
Post 16 Nov 2005, 01:07
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.