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 > [fasmg] empty params, eqtype

Author
Thread Post new topic Reply to topic
Jin X



Joined: 06 Mar 2004
Posts: 12
[fasmg] empty params, eqtype
1. How to check empty parameters of macro, like in fasm 1:

Code:
macro xx param
{
  if param eq
    ; empty
  else
    ; not empty
  end if
}


2. In fasm 1 I can make something like:

Code:
macro   movx    op1,op2
{
    if  op2 eqtype 0 & op2 = 0
        xor     op1,op1
    else
        mov     op1,op2
    end if
}

How can I do it on fasmg (check param for zero - even when param specified as const = 0)
Post 14 Apr 2017, 22:52
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6302
Location: Kraków, Poland
Re: [fasmg] empty params, eqtype

Jin X wrote:
1. How to check empty parameters of macro, like in fasm 1:

Code:
macro xx param
{
  if param eq
    ; empty
  else
    ; not empty
  end if
}


It can be done with MATCH in a similar way to how it was possible to check for empty value in the preprocessor of fasm 1:

Code:
macro xx param
  match ,param
    ; empty
  else
    ; not empty
  end match
end macro



Jin X wrote:
2. In fasm 1 I can make something like:

Code:
macro   movx    op1,op2
{
    if  op2 eqtype 0 & op2 = 0
        xor     op1,op1
    else
        mov     op1,op2
    end if
}

How can I do it on fasmg (check param for zero - even when param specified as const = 0)

Unfortunately fasmg's EQTYPE compares only the result types of valid expressions and there is currently no simple way to determine if argument is such expression, the only way is to MATCH all possible variants of arguments that are not. If you use the set of x86 macros that come with fasmg then you can utilize the "parse_expression" macro to do the work for you:

Code:
macro   movx op1,op2
        x86.parse_operand @src,op2
        if @src.type = 'imm' & @src.imm = 0
                xor op1,op1
        else
                mov op1,op2
        end if
end macro 

Nevertheless I recognize the need for a method to detect valid expressions, I thought about introducing an additional kind of conditional directive for this purpose and I may add one in the future.
Post 15 Apr 2017, 06:59
View user's profile Send private message Visit poster's website Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 12
Thanks! Wink
Post 15 Apr 2017, 07:57
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.