flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Append "epilog" for "constant" (EQU)

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 06 Jan 2017, 19:31
Hi,

I have defined the following:

FUNCTION_NAME EQU FunctionPoly

I want to create something like the following but using "FUNCTION_NAME":

public FunctionPoly_Handler

So, I have tried different approaches like:

Code:
public FUNCTION_NAME_Handler
public FUNCTION_NAME#_Handler
public #FUNCTION_NAME#_Handler
etc.
    


But all of them are incorrect. Is that possible?

Thanks![/b]
Post 06 Jan 2017, 19:31
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 06 Jan 2017, 19:35
You need to use MATCH to extract the value of FUNCTION_NAME into a parameter, then the value of parameter can be concatenated with #:
Code:
match name, FUNCTION_NAME {
    public name#_Handler
}    
Post 06 Jan 2017, 19:35
View user's profile Send private message Visit poster's website Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 06 Jan 2017, 20:05
Hi Tomasz,

Thanks again! That works as expected!

The problem is that I'm using it inside a macro and I don't get it to work. I have tried the following:

Code:

FUNCTION_NAME EQU FunctionPoly1

macro POLY_FUNCTION
{
   match name, FUNCTION_NAME \{
   public name#_handler
   proc name#_handler param1
   \}

        mov     eax, eax 
        ret

    endp
}

; Testing the waters....

POLY_FUNCTION

mov     eax, FunctionPoly1_handler ; FASM ERROR: undefined symbol 'FunctionPoly1_handler'.

mov     eax, name_handler ; it assembles correctly!!!

    


When the "match" is inside the macro, it does not get defined as expected. If I put the "match" ouside the "macro" it works fine. How can I make it work from inside the macro?

Thanks!
Post 06 Jan 2017, 20:05
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 06 Jan 2017, 20:17
You need to escape the "#" operator the same way as you escape the "{" and "}", otherwise it is processed by the outer macro.
Post 06 Jan 2017, 20:17
View user's profile Send private message Visit poster's website Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 07 Jan 2017, 01:19
Thanks a lot! I have it working as expected now Very Happy
Post 07 Jan 2017, 01:19
View user's profile Send private message Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 08 Jan 2017, 07:41
Hi,

I have done some changes. When I put in the above example:

Code:
...
public name#_handler 
...
    


It's processed correctly and generates "public Function1Poly_handler"

But if I put the following:

Code:
...
public name#_handler as '_name#_handler@8'

or 

public name#_handler as '_#name#_handler@8'
    


it seems to be processed as:

public Function1Poly_handler as '_name#_handler@8'

That is, the second part is not processed.

Any help?

Thanks!
Post 08 Jan 2017, 07:41
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.