flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How cast new macro from another macros !?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1807
Roman 09 Sep 2014, 07:27
Let's do magic things ! Smile
I have three macros.

Code:
macro Msg chTxt {invoke MessageBox,0,'Msg:',chTxt,0}

macro DoProc chProc {Call chProc}

macro SumFloat chA,chB {mov eax,chA
                                    movd xmm1,eax
                                    mov eax,chB
                                    movd xmm2,eax
                                    addss xmm1,xmm2 
                                    }
    

I want do like this !
Code:
CastNewMacro NameNewMacro,SumFloat 10.9,11.2,DoProc FloatToTxt,Msg FloatNum
    


Then in any place of code i write NameNewMacro and i get 3 macros !
This maybe help full to create new awesome macros !!!
Post 09 Sep 2014, 07:27
View user's profile Send private message Reply with quote
evk1



Joined: 18 Jun 2014
Posts: 24
evk1 09 Sep 2014, 18:47
Hi Roman,
If I understand you correctly, you needs something like it:
Code:
macro CastNewMacro name,[arg]{
  common
    macro name\{
  forward
      arg
  common
    \}}    

But this macro has a bit different syntax:
Code:
CastNewMacro NameNewMacro,<SumFloat 10.9,11.2>,<DoProc FloatToTxt>,<Msg FloatNum>    

If you want to use macro which can accept your syntax, you should use more complex solution:
Code:
macro CastNewMacro name,[arg]{
  common
    macro name\{
  forward
      arg
  common
    \}}

macro CastNewMacro name,[arg]{
  common
    CastNewMacro@actions equ
  forward
    match macroname firstarg,arg\{
      CastNewMacro@actions equ CastNewMacro@actions>,<macroname firstarg
      CastNewMacro@argIsHandled equ\}
    match =CastNewMacro@argIsHandled,CastNewMacro@argIsHandled\{
      CastNewMacro@actions equ CastNewMacro@actions,arg\}
    restore CastNewMacro@argIsHandled
  common
    match >=,args,CastNewMacro@actions>\{CastNewMacro <name>,args\}
    match ,CastNewMacro@actions\{macro name\\{\\}\}}    

But your variant has one serious shortcoming. You can not use macros which takes no arguments in macro definitions.

By the way you can define macros which takes some arguments in your code using these macros.
Code:
macro DisplaySomething anything{display anything,13,10}
CastNewMacro <DisplaySomethingTwice any>,DisplaySomething any,DisplaySomething any    

_________________
Sorry for my English
Post 09 Sep 2014, 18:47
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1807
Roman 10 Sep 2014, 04:56
Thank you evk1
Cool macro !
Post 10 Sep 2014, 04:56
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.