flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > [fasmg] empty params, eqtype |
Author |
|
Tomasz Grysztar 15 Apr 2017, 06:59
Jin X wrote: 1. How to check empty parameters of macro, like in 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 x86.parse_operand @src,op2 if @src.type = 'imm' & @src.imm = 0 xor op1,op1 else mov op1,op2 end if end macro |
|||
15 Apr 2017, 06:59 |
|
Jin X 15 Apr 2017, 07:57
Thanks!
|
|||
15 Apr 2017, 07:57 |
|
Tomasz Grysztar 28 May 2017, 13:04
Tomasz Grysztar wrote: 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. For example to check if a macro parametr "op" is a valid expression and has a value that is an absolute number and is equal to zero, a simple "IFONLY (op) = 0" would suffice. The parentheses would ensure that tricky arguments like "1 | 0" would not pass through. |
|||
28 May 2017, 13:04 |
|
revolution 28 May 2017, 13:09
Why not "if valid ..."
Code: if valid <expression> Code: if valid <something> & <something> = 0 |
|||
28 May 2017, 13:09 |
|
Tomasz Grysztar 28 May 2017, 13:25
revolution wrote: Why not "if valid ..." |
|||
28 May 2017, 13:25 |
|
revolution 28 May 2017, 13:43
I suppose there could be a special separator construct:
Code: if valid op && op = 0 Code: op equ 1) | (0 if valid (op) && (op) = 0 op equ 1) && (0 if valid (op) && (op) = 0 |
|||
28 May 2017, 13:43 |
|
Tomasz Grysztar 28 May 2017, 14:36
But then if value already contains this special separator, a part of free-form text would be interpreted as a separate expression - again not the expected behavior. If what we need is to check if something is a valid expression without causing an error, then it this text contains our "special separator" it is then able to create an error anyway and the entire purpose of such construction is compromised.
You could try to invent some clever separators that "nobody is ever going to use in actual code", but even if it worked in practical applications it still would be wrong in principle. The only really safe way is to do it like MATCH does (it is not coincidence that MATCH uses "pattern, text" order. PS This also shows that my idea of IFONLY directive, even though initially sounded interesting, is still not what I was looking for. I may have to stick to IFEXPR anyway. |
|||
28 May 2017, 14:36 |
|
zhak 28 May 2017, 17:34
I do it as
Code: if lengthof `param > 0 . . . end if |
|||
28 May 2017, 17:34 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.