Message board for the users of flat assembler.
> Macroinstructions > CALM question: check if 2 variables hold same sym value
fabbel 17 May 2023, 14:07
my mind is stuck - I keep stumbling on very basic issue it seems :
how can i check if 2 variables hold same (raw) symbolic value via CALM ?
Also, can i make the check case insensitive ?
I.E. assume i have :
define A foo
define B foobar
define C foo
define D FOO
How can I recognise A is holding same sym value as C and D ?
(don't need nor mandate foo/FOO itself to be defined or not - really should not matter)
help appreciated !
|17 May 2023, 14:07||
Tomasz Grysztar 17 May 2023, 14:13
There is no operation that would do this directly. You would have to manually split one of the values to convert it into MATCH pattern consisting of all literals. I guess I never encountered a problem that would require this kind of operation, that's why I never thought of this before.
|17 May 2023, 14:13||
fabbel 17 May 2023, 14:34
I reckon for case sensitive compare, i cud do sthg like
calminstruction test arg1, arg2
... handle case when diff...
... handle case when same...
test A, B
test A, C
... But was checking to see if there cud be some other / more efficient way
... Plus obv, does not work for case insensitive...
|17 May 2023, 14:34||
fabbel 17 May 2023, 14:41
Read same: in calminstruction
|17 May 2023, 14:41||
bitRAKE 17 May 2023, 17:22
I'm learning these things too; but here are some thoughts:
Case-insensitive matching only effect literals like MATCH =VALUE?, symbol; but the VALUE could be replaced by wrapping the calminstruction at a higher level.
Another way is to transform case insensitive values in a namespace:
... I use this to match symbolic options to a function - so the consumer can use any case.
define tester? define tester?.FOO? foo calminstruction test arg1, arg2 transform arg1,tester? transform arg2,tester? ...
Maybe this doesn't fix your use though?
[I would look at how fasmg supports registers for x86 implementation with algebraic terms - this prevents the need to stringify the arguments.]
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
|17 May 2023, 17:22||
< Last Thread | Next Thread >
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.