flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > macro code injection

Author
Thread Post new topic Reply to topic
gandalf



Joined: 27 Feb 2009
Posts: 31
gandalf
Is it possible to inject macro code into other macros?
I'd like to do something like this:

Code:
macro test1 name
{
      \local name
}

macro test2
{
 test1 loc1                      ; local loc1
        loc1 equ nop
}
    
Post 08 Mar 2009, 09:59
View user's profile Send private message Reply with quote
gandalf



Joined: 27 Feb 2009
Posts: 31
gandalf
For now, I emulate local with restore.
Post 08 Mar 2009, 10:25
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
Have you tried it? You would probably get a faster answer by trying it for yourself.
Post 08 Mar 2009, 10:27
View user's profile Send private message Visit poster's website Reply with quote
gandalf



Joined: 27 Feb 2009
Posts: 31
gandalf
revolution wrote:
Have you tried it? You would probably get a faster answer by trying it for yourself.


???
Post 08 Mar 2009, 11:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
But you went to all the effort to make a nice post with code tags and everything. And yet you didn't test it? I thought it was rather odd to make such an effort and stop short of taking a few seconds to run it though the assembler.

So my question still stands did you test it? What result did you get? Did it work?
Post 08 Mar 2009, 12:00
View user's profile Send private message Visit poster's website Reply with quote
gandalf



Joined: 27 Feb 2009
Posts: 31
gandalf
revolution wrote:
So my question still stands did you test it? What result did you get? Did it work?


So you weren't kidding.
I did test it.
It didn't work.
Post 08 Mar 2009, 13:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
I think I misunderstand your question.

Macro code can be instantiated into another macro. Which it appears is what you are doing in the first post. So I thought you had already worked out that is can be done.

But now you say it can't be done so I am confused?
Post 08 Mar 2009, 13:32
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7801
Location: Kraków, Poland
Tomasz Grysztar
The problem here is that macro processor doesn't recognize "local" keyword generated this way, because macro processor's special directives are processed before passing the line to standard line preprocessor (which evaluates the macro). It is explained in the Understanding fasm article, but in manual in section about order of processing I have perhaps forgot to mention it - I'm adding it to my TODO list for documentation now.

In short:: it won't work this way, and it is because of design, not a bug in implementation.
Post 08 Mar 2009, 14:29
View user's profile Send private message Visit poster's website Reply with quote
gandalf



Joined: 27 Feb 2009
Posts: 31
gandalf
Here's a simple workaround (for a similar situation):

Code:
macro test1 mode, [args]
{
  common
      \macro test2 [args2]
       \{
            mode
                args2
       \}
    test2 args
  purge test2
}

test1 forward, <mov ax,1>, <mov ax,2>
test1 reverse, <mov ax,1>, <mov ax,2>
    
Post 08 Mar 2009, 16:27
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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.