flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > how to declare data before by declaring it later in code ?

Author
Thread Post new topic Reply to topic
gens



Joined: 18 Feb 2013
Posts: 161
gens
title is a bit confusing as idk how to explain it
what i want is

some other macro in data section

...

printf "asdasdasd"
(c-like macro example)



in short, to declare stuff like strings in code macros but for the string to be declared in data

specifically i want it so it would be easier to do assert()/printf()-like functions, for loading shaders by name and so on


there was a... postpone(?) macro instruction added a few fasm versions ago
still, idk how i'd do this for multiple declarations

any simple way to do this ?
Post 19 Feb 2015, 17:36
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
EDIT: I knew there was something like this somewhere http://board.flatassembler.net/topic.php?t=15871 Question

You can ignore my original.../EDIT
Quote:

Is this what you mean? This works better if the data is at the end but here I've managed to force the code after the data with yet more postpone Embarassed I can't help but feel there's a cleaner way but I've not found it Sad
Code:
__strings equ

CODE fix postpone {
DATA fix }

macro @string name,str
{
        match any,__strings \{ __strings equ __strings,name,str \}
        match    ,__strings \{ __strings equ           name,str \}
}

macro @strings_ [name,str]
{
        name db str,0
}

macro @strings
{
        postpone
        \{
               match args,__strings \\{ @strings_ args \\}
        \}
}

data_section:

        @strings
CODE
code_section:

        xor eax,eax
DATA
        @string mystr,"blah"
CODE
        mov esi,mystr

        xor eax,eax
DATA
        @string mymsg,"iouoiu"
CODE
        mov edi,mymsg
DATA            
Post 19 Feb 2015, 20:23
View user's profile Send private message Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens
y, that is what i was thinking about

i think Tomasz's str.inc looks like what i need
it is a bit over my head to understand it properly, so il' come back if something goes wrong

thx
Post 19 Feb 2015, 21:10
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 YouTube, Twitter.

Website powered by rwasa.