flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Macroinstructions > Need a recursive macro

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 570
Need a recursive macro

Code:
matchloop ab
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 ts
  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: 14462
Location: Eta Argus
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: 570

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: 14462
Location: Eta Argus
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: 570
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: 570
Recursive macro in fasmg

Code:
macro fun ab
  if (a)=0
    repeat 1 t:b
      display `t1310
    end repeat
  else
    fun (a)-1, (b)*(a)
  end if
end macro
fun 101

macro mov op1op2
  display 'mov ', `op1',', `op21310
end macro
macro mov op1op2
  if `op1 eq 'ip'
    jmp op2
  else
    mov op1op2
  end if
end macro
    
mov axcx



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: 570
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.