flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [SOLVED] Macroinstructions - argument is count or variable?

Author
Thread Post new topic Reply to topic
Kazyaka



Joined: 10 Oct 2011
Posts: 62
Location: Earth
Kazyaka 08 Jun 2012, 17:51
How can I check if an argument is count (e.g. 235 or -10.06) or variable (e.g. Val_1)?

Example:

Code:
macro Test Arg
{
if Arg is count
cmp eax, Arg
else
cmp eax, [i+Arg]
end if
}    


I hope u understand what I mean.


Last edited by Kazyaka on 09 Jun 2012, 17:04; edited 1 time in total
Post 08 Jun 2012, 17:51
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 08 Jun 2012, 22:36
One way is to pass two arguments, one which is used for type or handling of data.
For what exactly is it needed ?
What is variable "i" in your example ?
Post 08 Jun 2012, 22:36
View user's profile Send private message Send e-mail Reply with quote
Kazyaka



Joined: 10 Oct 2011
Posts: 62
Location: Earth
Kazyaka 09 Jun 2012, 08:25
Code:
i=imgbase    

ImageBase = 400000
Post 09 Jun 2012, 08:25
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1416
Location: Piraeus, Greece
Picnic 09 Jun 2012, 08:44
@Kazyaka, you may find useful eqtype operator to distinguish types.

detailed "eqtype" evaluation
determining the type of macro arguments

If they don't suit your needs, shutdownall approach is a fairly easy solution.
Post 09 Jun 2012, 08:44
View user's profile Send private message Visit poster's website Reply with quote
Kazyaka



Joined: 10 Oct 2011
Posts: 62
Location: Earth
Kazyaka 09 Jun 2012, 08:57
It won't help me because Val1 has the same eqtype as 42.

@shutdownall
It was only example. I can't use your solution in this example:
Code:
macro Test [Arg] 
{ 
if Arg is count 
cmp eax, Arg 
else 
cmp eax, [i+Arg] 
end if 
}
    


Now I think it is impossible. Sad
Post 09 Jun 2012, 08:57
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 09 Jun 2012, 16:05
With FASM macro engine, "impossible" can be only relative. Smile
Try with something like:
Code:
macro test_type  arg {
 if defined arg#0 & arg#0+1 = arg * 10+1
   display 1, 'constant', 13, 10
 else
   display 1, 'label', 13, 10
 end if
}

Start:

test_type 1234
test_type Start  
    


It will not work only if you test the label with some name "name" and you have defined label with name "name0" at the same address as the tested label.
Post 09 Jun 2012, 16:05
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Kazyaka



Joined: 10 Oct 2011
Posts: 62
Location: Earth
Kazyaka 09 Jun 2012, 17:03
@JohnFound

It really works! Thank you. Smile
Post 09 Jun 2012, 17:03
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.