flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Fasm 1.73 macro number how do ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
Code:
macro mM2 { mov eax,1 }

In code:
zz EQU 2
mM#zz
    

Get fasm error.

I expect get mM2
Post 23 Jul 2020, 15:55
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 821
Location: Belarus
DimonSoft
AFAIR, # doesn’t work outside macros.
Post 23 Jul 2020, 16:06
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
I try this but get Fasm error . Illegal instruction mM2
Code:
macro mM2 { mov eax,1 }
macro mMmm chTp {     
            zz EQU mM#chTp
            zz
            }
In code:
mMmm 2    


Last edited by Roman on 24 Jul 2020, 11:36; edited 1 time in total
Post 23 Jul 2020, 16:16
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 821
Location: Belarus
DimonSoft
Isn’t mM2 an illegal instruction?
Post 24 Jul 2020, 11:29
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
O! This work !
Code:
macro mM2 { mov eax,1 }
macro mMmm chTp {     
            mM#chTp           
            }
In code:
mMmm 2 
    


But not work if:
Code:
Rr EQU 2
mMmm Rr
    
Post 24 Jul 2020, 11:37
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
You misunderstand the rules for EQU. Macros arguments don't translate EQUs.

If you insist upon using EQU then use match to translate the EQU arguments.
Code:
macro mM2 { mov eax,1 }
macro mMmm chTp { mM#chTp }

mMmm 2

Rr EQU 2
match x,Rr{mMmm x}    
Post 24 Jul 2020, 12:34
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
I write this:
Code:
macro mM2 { mov eax,1 }
macro mMmm chTp {    
           match dst src, chTp \{
           mM#dst    \}
            }
In code:
 zz EQU 2
mMmm zz
    

Compile but nothing asm code get !
Empty ! I check in IDA Pro. Must be mov eax,1

What i do wrong ?
Post 24 Jul 2020, 13:08
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
That match fails because you asked for two parameters (dst and src) but only provided one (zz).
Post 24 Jul 2020, 13:15
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
Fasm get error illegal instruction mMdst:
Code:
macro mMmm chTp {    
           match dst, chTp \{
           mM#dst    \}
            }
    
      dds EQU 2
      mMmm dds
    
Post 24 Jul 2020, 13:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
You need to escape the #
Code:
mM\#dst    
Post 24 Jul 2020, 13:25
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
Thanks ! Work !
Its magic ! I got into a fairy tale Smile
Post 24 Jul 2020, 13:39
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 821
Location: Belarus
DimonSoft
PREPSRC should help a lot.
Post 24 Jul 2020, 15:57
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.