flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Argument count for macro instructions.

Author
Thread Post new topic Reply to topic
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 03 May 2004, 19:27
How would you get an argument count for a macro instruction?

Example:

Code:
macro myfunction,arg1,arg2,arg3,arg4 
{
     if argc=3
          push arg1
          push arg2
          push arg3
          call function1
     else if argc=4
          push arg1
          push arg2
          push arg3
          push arg4
          call function2
     end if
}    
Post 03 May 2004, 19:27
View user's profile Send private message Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 03 May 2004, 19:36
Code:
if arg4 eq
  ; three args
else
  ; four args
end if    
Wink
Post 03 May 2004, 19:36
View user's profile Send private message Visit poster's website Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro 03 May 2004, 19:37
Code:
macro myfunction,[arg]
{
common
     local count
     count = 0
forward
     count = count + 1
     push arg
common
     if count = 3
          call function1
     else if count = 4
          call function2
     end if
}
    

Or you could check if parameter isn't empty(if ~arg1 eq ) and inc count.
Post 03 May 2004, 19:37
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 03 May 2004, 19:45
Code:
macro mac [arg]
{
  argc = 0
forward
  if ~arg eq
    argc = argc+1
  end if
common
  ; now argc contains number of macro parameters
  (...)
}    
Post 03 May 2004, 19:45
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 03 May 2004, 21:50
Smile All right, thanks guys, I'll give each one a try. I wonder if this could be added as a feature to the macro command? Making ARGC a reserved variable and using it to hold the count? Question
Post 03 May 2004, 21:50
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 04 May 2004, 05:58
proably there's no reason for it, as it can be easily achieved using existing fearures Smile
Post 04 May 2004, 05:58
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.