flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Need a recursive macro

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 07 Aug 2016, 05:03
Code:
matchloop a, b
{ do something }    

I thought of this way but don't work because macros need to define before use. Is there any other way?
Code:
macro matchloop x& {
  local t, s
  macro t \{
    macro t \\{
      match x \\\{
        s
        t
      \\\}
    \\}
    t
  \}
  t
  macro s
}    
Post 07 Aug 2016, 05:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20623
Location: In your JS exploiting you and your system
revolution 07 Aug 2016, 05:07
Do you mean a recursive macro?

If so, you can see the "allow_nesting" macro in win32ax.inc for that. It basically redefines itself within itself to get the recursion.
Post 07 Aug 2016, 05:07
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 07 Aug 2016, 09:45
revolution wrote:
Do you mean a recursive macro?

If so, you can see the "allow_nesting" macro in win32ax.inc for that. It basically redefines itself within itself to get the recursion.

recursing need redefing in the macro, I know. I just don't know how to have the shelling code after the macro
Post 07 Aug 2016, 09:45
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20623
Location: In your JS exploiting you and your system
revolution 07 Aug 2016, 09:57
Please you explain more about what you are trying to do.
Post 07 Aug 2016, 09:57
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 07 Aug 2016, 13:52
Or let's say about
revolution wrote:
recursive macro
.
revolution wrote:
the "allow_nesting" macro in win32ax.inc
itself makes the macro recursive but a layer deeper. I want to make it able to write
Code:
recursive macro xxx {xxx }    
Post 07 Aug 2016, 13:52
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 22 Aug 2016, 14:22
Code:
macro fun a, b
  if (a)=0
    repeat 1 t:b
      display `t, 13, 10
    end repeat
  else
    fun (a)-1, (b)*(a)
  end if
end macro
fun 10, 1

macro mov op1, op2
  display 'mov ', `op1, ',', `op2, 13, 10
end macro
macro mov op1, op2
  if `op1 eq 'ip'
    jmp op2
  else
    mov op1, op2
  end if
end macro
    
mov ax, cx    

fasmg return wrote:
3628800
mov ax,cx

How does fasmg decide to use the present macro or the previous one?
Post 22 Aug 2016, 14:22
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 22 Aug 2016, 14:28
It seems to use the previous one when not first defined Sad
Post 22 Aug 2016, 14:28
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.