To Privalov.
Help me, please!

Again there is a problem:



macro argtest arg
{
if arg eq +arg | arg+0 eq arg 0
display 'non-quoted argument'
else
display 'quoted argument'
end if
}
argtest 'a' ; quoted argument (ok)
argtest <'a','b','c'> ; quoted argument (ok)
argtest 0FFFFFFFFh ; non-quoted argument (ok)
argtest -1 ; quoted argument (!?)
Posted on 2003-01-10 09:25:45 by tserk
It doesn't work with "+1" either, and it's obvious why when you analyze it (looking into documentation). You can use "(-1)" instead, but it's not elegant solution. Well... maybe it's time to implement some additional operators for conditional expressions, like "if quoted arg"? If you think it's a good idea, please tell me what operators would you like to have implemented (and with what names) - if I like it, I'll implement it. :)

I mean that all fasm users can give their opinions here.
Posted on 2003-01-10 10:00:44 by Tomasz Grysztar
I think it's a great idea! (I would prefere the 'quoted' keyword the most....)

Regards,
POW
Posted on 2003-01-10 11:29:53 by POW
But how should it behave with syntax like "if quoted 'a','b','c'"? Or even "if quoted 'a',13,10"? If it had to be logical, it should return false with these cases; and if it has to check only the first symbol after, what should we do with the rest? Ignore always?
Well, this is a kind of problems I always had during the fasm development. Sooner or later I found the solution for each one, but this time I'm asking you to give some ideas. And curious to what it would lead us... ;)


After rethinking it I'm sure that value of "quoted 'a','b','c'" should be false. So there should be another check for the multiple arguments, for example "pushd" macro from "win32ax.inc" would look like:


macro pushd [arg]
{ common local ..count
..count = 0
forward ..count = ..count+1
common
if ..count-1 | quoted arg
local ..continue
call ..continue
db arg,0
..continue:
else if _#arg in <_addr arg,_ADDR arg>
; this part unchanged
else
push arg
end if }

Posted on 2003-01-10 11:52:59 by Tomasz Grysztar

Well... maybe it's time to implement some additional operators for conditional expressions, like "if quoted arg"? If you think it's a good idea, please tell me what operators would you like to have implemented (and with what names) - if I like it, I'll implement it. :)


Maybe, additional operator "numeric"? (if numerical arg...)?



if numerical arg ...
if ~ arg
....
end if
else if arg+0 eq arg 0
...
end if


PS Maybe, also "effective address" instead "arg+0 eq arg 0", and "register".
So:
1 number;
2 eaddress;
3 quoted;
4 register.

PPS To Privalov: on You discretion :)
Thanks once again for that FASM 1.43, stable and effective tool!
Posted on 2003-01-11 01:10:20 by tserk
I have a new, different, and IMO better idea: only one operator - I haven't yet decided how to call it - maybe "eqtype", "samekind" or "eqkind". To check whether argument is quoted you could use


if arg eqtype ""

To check whether it's numerical expression:


if arg eqtype 0

To check whether it's some register followed by a comma and some effective address:


if arg eqtype eax,[0]

etc. etc.
It shouldn't be too hard to implement (I have already designed the right algorithm in my mind). What do you think about it? And what name would you propose for such operator?
Posted on 2003-01-11 03:50:11 by Tomasz Grysztar
Ohhh... Yessss! :alright:

PS
I Love FASM for the academical style.
"eqtype" operator in this style too, IMHO.
Thanks
Posted on 2003-01-11 04:02:04 by tserk
Once you head down the slipperly slope of adding some argument classification functions, it can get pretty wild. For example, why not have predicates like the following?

isReg
isReg8
isReg16
isReg32
isRegMMX
isRegSSE
isRegFPU
isConst
isString
isNumeric
isFloat
isMemory
isStatic
isNear
isFar
.
.
.

The list goes on and on.
All of these predicates (boolean functions) are useful in their own right when doing extensive macro processing. Of course, it's also nice to have full string handling and
pattern matching functions available in your macro language as well. Then, of course,
you may as well support other types of compile-time statements beyond conditional assembly (if) and macro invocation (compile-time procedures). Why not while loops?
Etc.

MASM provides a decent core of string operations, though their use is nearly incomprehensible to the average programmer (and it's nearly impossible to read them and figure out the intent of the original programmer). HLA provides a wide set of compile-time functions you can use to do tests like this, but at great expense in compiler size and complexity (not to mention affecting the size of the manual). Still, the compile-time language facilities of HLA let you do some incredible things. FASM would benefit greatly by having a little more of this available.
Randy Hyde
Posted on 2003-01-11 17:06:10 by rhyde
Well, I think the "eqtype" operator is the best solution - with this finally all the complex macros in the latest includes package will become more "elegant" and reliable. More detailed checks would be made using the "in" directive (like "if arg in <segregs>", with "segregs equ cs,ds,es,fs,gs,ss" definition).
About HLL features: we (I mean community of this board) have made many of them just as a sets of macros. fasm's macro facility is very low-level and therefore allows to construct many HLL features, so fasm itself doesn't have to implement them and can stay not bloated too much.
Posted on 2003-01-11 17:28:58 by Tomasz Grysztar
It is said - it is done!

In the new version of fasm (1.44 beta 1):

invoke MessageBox,0,<'Eqtype operator',13,10,'works fine!'>,'eqtype test',0

all right! :alright: :alright:

PS one of variants of pushd macro is used:


macro pushd [arg]
{
common
local .string
.string = 0
forward
if arg eqtype ''
.string = 1
end if
common
if .string
local .continue
call .continue
db arg,0
.continue:
else if ( _#arg in <_addr arg,_ADDR arg> ) & ( arg eqtype [0] )
lea edx,arg
push edx
else
pushd arg
end if
}
Posted on 2003-01-13 02:56:46 by tserk