flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How macro say what now section?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1701
Roman 01 Nov 2022, 11:06
Fasmw 1.73
I want in diferents section do my macro.

. Section code
MyMacro ;do Inc [myval]
. Section data
MyMacro ;do myval dd 0
. Section bss
MyMacro ;do myv rd 10
Post 01 Nov 2022, 11:06
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 658
Location: Ukraine
Overclick 01 Nov 2022, 15:38
Very simple
Variant 1:
Code:
macro MyMacro
{  .code
        Inc [myval]
    .data
        myval dd 0
    .bss
        myv rd 10
}    


Variant 2:
Code:
macro MyMacro
{  match =.code,cuRRentSection
        \{Inc [myval] \}
    match =.data,cuRRentSection
        \{myval dd 0 \}
    match =.bss,cuRRentSection
        \{myv rd 10 \}
}    


Variant 3: Stream to place you want.

All variants works for known supermacro in the list Wink
Post 01 Nov 2022, 15:38
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1701
Roman 01 Nov 2022, 18:22
Not work variant2
With SECTION '.data' DATA READABLE WRITEABLE executable

Ida pro not show Inc [myval]
Post 01 Nov 2022, 18:22
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 658
Location: Ukraine
Overclick 01 Nov 2022, 19:03
Oh you are right. Data label not expanded yet.
Try this trick for example:
Code:
macro MyMacro
{  match =.code,cuRRentSection
        \{
        if 0
                myval dd ?
        end if
        Inc [myval] \}
    match =.data,cuRRentSection
        \{myval dd 0 \}
    match =.bss,cuRRentSection
        \{myv rd 10 \}
} 
    

But anyway the first variant can completely cover any needs, just use extended subsections like .dataonce
Post 01 Nov 2022, 19:03
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 658
Location: Ukraine
Overclick 01 Nov 2022, 21:23
Something wrong with that "match", need some time/electricity to find why.
The best solution at the moment to use Variant 1 like this:
Code:
        macro MyMacro
{       ..dataonce      myval,  myval   dd 0
        ..bssonce       myv,    myv     rd 10
        Inc [myval]
}  
...
then you use the macro in .code section only and it will place that data in correct sections
...

.code
   MyMacro
    
Post 01 Nov 2022, 21:23
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 658
Location: Ukraine
Overclick 02 Nov 2022, 07:25
OMG Variant 2 was working just fine. All you need is to use your macro in each section manually as you asked for:
Code:
.bss
        MyMacro
.data
        MyMacro
.code
        MyMacro
    


Am working on addon for this sort of use.
Post 02 Nov 2022, 07:25
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 658
Location: Ukraine
Overclick 02 Nov 2022, 09:23
Ok addon is ready
Code:
        macro .endcurrent { }
        macro .current arg
        {       .endcurrent
                if 0
                match =arg,cuRRentSection
                \{      end if
                        if 1
                \}
                purge .endcurrent
                macro .endcurrent
                \{      end if 
                        purge .endcurrent
                        macro .endcurrent \\{ \\}
                \}
        }
    


How to use:
Code:
macro MyMacro
{       
        .current .data
                myval dd 13
        .current .code
                Inc [myval]
        .current .bss
                myv rd 10
        .endcurrent
}   

...

.bss
        MyMacro
.data
        MyMacro
.code
        MyMacro
    
Post 02 Nov 2022, 09:23
View user's profile Send private message Visit poster's website 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.