flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Nested macro calls

Author
Thread Post new topic Reply to topic
Smile



Joined: 07 May 2006
Posts: 6
Smile 08 May 2006, 21:05
Hi

Used compiler fasm-1.64

Code:
macro Parse string
{
 match char tail, string
 \{
  Parse tail ; extra characters on line 'parse+1'
 \}
}

Parse 1+1
    


What is wrong?
Post 08 May 2006, 21:05
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 08 May 2006, 21:59
In FASM 1.66 I get illegal instruction 'Parse+1' and it's OK because there is no previous macro definition named "Parse"
Post 08 May 2006, 21:59
View user's profile Send private message Reply with quote
Smile



Joined: 07 May 2006
Posts: 6
Smile 08 May 2006, 22:56
so i can not use recursion at all?
Post 08 May 2006, 22:56
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 08 May 2006, 23:12
In that way not, if you call a macro with the same name that the current macro you will call the previous definition.

2.3.3 Macroinstructions wrote:
macro mov op1,op2
{
if op1 in <ds,es,fs,gs,ss> & op2 in <cs,ds,es,fs,gs,ss>
push op2
pop op1
else
mov op1,op2
end if
}


"mov op1, op2" is not a recursive call, it calls the previous definition of that macro and since there is not one the MOV instruction is assembled.

Recursion is posible with some tricks, but, I can't remember...
[edit]Maybe you can get some info in win32ax.inc with the allow_nesting macro[/edit]
Post 08 May 2006, 23:12
View user's profile Send private message Reply with quote
dead_body



Joined: 21 Sep 2005
Posts: 187
Location: Ukraine,Kharkov
dead_body 09 May 2006, 07:21
Code:
macro Parse string 
{ 
 match char tail, string 
 \{ 
  ;here you must include macro Parse(it must be in another file)
  Parse tail ; extra characters on line 'parse+1'
  ;here purge it 
 \} 
} 

Parse 1+1    


read about this in documentation.

it is one of the way to do recursion.
Post 09 May 2006, 07:21
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 09 May 2006, 07:32
See the PARSECOND macro in the MACRO/IF.INC in fasmw package. It does some parsing without recursion, it uses IRPS instead.
As for sample recursion, you can find some in the JNCONDEL and other similar macros in the same file.
Post 09 May 2006, 07:32
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 09 May 2006, 09:48
Code:
macro Define_Parse {
  macro Parse \{  
    Define_Parse
    Parse
  \}
}
Define_Parse    

this is the idea


Last edited by vid on 09 May 2006, 12:31; edited 1 time in total
Post 09 May 2006, 09:48
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 09 May 2006, 12:14
vid: well said. Smile
Post 09 May 2006, 12:14
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 09 May 2006, 12:30
thanks, anyway it's stolen from your nested call macros Wink
Post 09 May 2006, 12:30
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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.