flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > retrieve size of a label

Author
Thread Post new topic Reply to topic
yoshimitsu



Joined: 07 Jul 2011
Posts: 96
yoshimitsu
Hi there,
sorry I'm kinda braintarded atm,
but how do I achieve the following?

Code:
macro xyz p
{
  if p is dword ptr
    mov eax,p
  else if p is byte ptr
    mov al,p
  end if
}

xyz [_abc]
xyz [_def]

_abc dd ?
_def db ?    
Post 23 Mar 2012, 21:57
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
yoshimitsu
I don't think, fasm provides a documented way to check the label size. However you could use the following workaround:
Code:
macro xyz p 
{
 local tmp
   virtual
             not p
               load tmp byte from $$
       end virtual
 if tmp = $f7
                mov eax,p
   else if tmp = $f6
           mov al,p
    end if
}

xyz [_abc]
xyz [_def] 

_abc dd ? 
_def db ?    

Note, that you'll get a compilation error, if p is not bound to a specific size.
Post 24 Mar 2012, 17:02
View user's profile Send private message Reply with quote
yoshimitsu



Joined: 07 Jul 2011
Posts: 96
yoshimitsu
smart, I'm kinda too close-minded to think of such a trick, thanks :P
Thought there might be sth like "p eqtype dword ptr" or similiar, though, but thanks :)
Post 24 Mar 2012, 19:29
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.