flat assembler
Message board for the users of flat assembler.

Index > Windows > Data sections from macro?

Author
Thread Post new topic Reply to topic
Ehtyar



Joined: 26 Sep 2006
Posts: 51
Ehtyar 10 May 2007, 10:10
Hi all.
I'm really sorry if this has been mentioned elsewhere, but after reading all the material in the docs about macros, and all the macro FAQs i could find, I'm out of ideas. What I'm looking to do is insert labels into the initialized and/or uninitialized data sections from a macro. The main problem I'm having at the moment is that if i create (un)initialized data within the macro, i cannot write to it because it's in the code section (i know i could make the code section readable, but that's not particularly practical). I created the following macro as an example of what i would like to try:
Code:
macro Msg string
{
      buff db 200 dup ? ; Put in udata section
    fmt db "%s", 0 ; Put in idata section
     cinvoke wsprintf, buff, fmt, string
 invoke MessageBox, HWND_DESKTOP, buff, NULL, MB_OK
}
    

Any help would be greatly appreciated.

Thanks, Ehtyar.
Post 10 May 2007, 10:10
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 11 May 2007, 09:48
look for "idata" and "udata" macros
Post 11 May 2007, 09:48
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Ehtyar



Joined: 26 Sep 2006
Posts: 51
Ehtyar 11 May 2007, 20:55
I found them a while back...but they're not really what I'd call practical, particularly if you intend to redistribute your code, very messy. Is there a cleaner way, dare i say something similar to masm?

Ehtyar.
Post 11 May 2007, 20:55
View user's profile Send private message Reply with quote
Ehtyar



Joined: 26 Sep 2006
Posts: 51
Ehtyar 17 May 2007, 22:01
Well, for anyone after a solution for this same kinda problem, I'm just using HeapAlloc, ugly but it works. Just push the handle as many times as you will need it, and pop it off as you do.

Ehtyar.
Post 17 May 2007, 22:01
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 20 May 2007, 15:41
so what you want is to merge all ".data" sections into single section in resulting object file.

FASM doesn't allow this, it is lower level assembler with different design. There probably isn't any better solution than idata Sad

BTW: What's not practical about idata/udata?
Post 20 May 2007, 15:41
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Ehtyar



Joined: 26 Sep 2006
Posts: 51
Ehtyar 20 May 2007, 21:15
vid: the extra times it is necessary to call it. HeapAlloc will do for the moment, i like my macros to be self-contained. Thank you for the suggestion though Smile

Ehtyar.
Post 20 May 2007, 21:15
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 20 May 2007, 23:40
you don't "call" idata, however you meant it.

Code:
macro Msg string { 
        udata \{
          buff db 200 dup ? ; Put in udata section 
        \}
        idata \{
          fmt db "%s", 0 ; Put in idata section 
        \}
        cinvoke wsprintf, buff, fmt, string 
        invoke MessageBox, HWND_DESKTOP, buff, NULL, MB_OK 
}
...
IncludeIData
IncludeUData    
Post 20 May 2007, 23:40
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Ehtyar



Joined: 26 Sep 2006
Posts: 51
Ehtyar 21 May 2007, 21:46
I'm terribly sorry vid, just what word would you like me to use?

Ehtyar.
Post 21 May 2007, 21:46
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 21 May 2007, 23:25
you can use ... use :]

anyway, it isn't really the best way to declare separate buffer for every macro invokation. you should have single buffer and single format string, and refer them from macros
Post 21 May 2007, 23:25
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.