flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Macroinstructions > LOCAL directive and generated names

Author
Thread Post new topic Reply to topic
DimonSoft



Joined: 03 Mar 2010
Posts: 83
Location: Belarus
LOCAL directive and generated names
Is there any way (in classic FASM) to use local directive inside macros to define macro-generated names?

For example, is it possible to write a macro which, when used like this…

Code:
defineLocals a(bc), d(efg)


… would generate code equivalent to…

Code:
local a_ba_cd_ed_fd_g


?

I know how to parse such parameters and tell the difference between names and “subnames”. The problem is with using something like

Code:
local some # thing



Thanks.
Post 10 Jul 2017, 08:40
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6633
Location: Kraków, Poland
Normally LOCAL is processed with higher priority than operators like #, so to get it working you need nested macros. Either you can define external wrapper that would parse parameters and generate this line:

Code:
__defineLocals a_ba_cd_ed_fd_g

and then use LOCAL directive inside the internal "__defineLocals" macro.

The other option is to use nested single-use macro with escaping, like:

Code:
macro defineLocals parameters&
{
    ; ...
    rept 1
    \{
        \local prefix#suffix
        ; ...
    \}
}

Post 10 Jul 2017, 09:16
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 83
Location: Belarus

Tomasz Grysztar wrote:
Normally LOCAL is processed with higher priority than operators like #, so to get it working you need nested macros. Either you can define external wrapper that would parse parameters and generate this line:

Code:
__defineLocals a_ba_cd_ed_fd_g

and then use LOCAL directive inside the internal "__defineLocals" macro.

The other option is to use nested single-use macro with escaping, like:

Code:
macro defineLocals parameters&
{
    ; ...
    rept 1
    \{
        \local prefix#suffix
        ; ...
    \}
}



Got it, thanks. A few more questions if you don’t mind.

1. Am I right that the scope of local-definitions is the closest macro/struc/rept containing the local directive?
2. So, I need to save the generated unique name to a “more global” symbolic constant to use it later, right?
3. Is there any easy way (that I can’t see) to extend the defineLocals macro so that it could be used like:

Code:
defineLocals a_ba_ca_d  ; Defines all of them and creates a_b?XX and a_c?XX macros

macro a_d?XX params
{
  ...
}

where a_d?XX could be written by something as simple as a_d?
Post 11 Jul 2017, 20:42
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 83
Location: Belarus
Solved the problem. Turned out to be quite easy even though my solution implied that the answers to the first two questions were “yes”.
Post 17 Jul 2017, 12:15
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.