flat assembler
Message board for the users of flat assembler.

Index > Main > [fasmg] Single line C style macros (expression level macros)

Author
Thread Post new topic Reply to topic
BismuthGlass



Joined: 08 Mar 2022
Posts: 4
BismuthGlass
Sometimes it is useful to use macros to dress up some common elements in my code. For instance, back in nasm, I used several single line macros to define C strings, access stack, etc.

Code:
%define _csln(s) db s, 0xd, 0xa, 0
example:
msg_hello db _csln("Hello world!")    


Another example is simplifying stack access:

Code:
%define stack(x) rbp - %[stkname] %+ _size + %[stkname] %+ . %+ x
example:
lea rdx, stack(v1)
    


Is there an equivalent to this in fasmg?[/code]
Post 11 Apr 2022, 20:44
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7992
Location: Kraków, Poland
Tomasz Grysztar
Post 11 Apr 2022, 21:42
View user's profile Send private message Visit poster's website Reply with quote
BismuthGlass



Joined: 08 Mar 2022
Posts: 4
BismuthGlass
This is perfect, thank you.
Post 11 Apr 2022, 23:04
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 GitHub, YouTube, Twitter.

Website powered by rwasa.