flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > CALM question: check if 2 variables hold same sym value

Author
Thread Post new topic Reply to topic
fabbel



Joined: 30 Oct 2012
Posts: 54
fabbel 17 May 2023, 14:07
Hi
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 !
tx
Post 17 May 2023, 14:07
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8263
Location: Kraków, Poland
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.
Post 17 May 2023, 14:13
View user's profile Send private message Visit poster's website Reply with quote
fabbel



Joined: 30 Oct 2012
Posts: 54
fabbel 17 May 2023, 14:34
I reckon for case sensitive compare, i cud do sthg like
calminstruction test arg1, arg2
transform arg1
stringify arg1
transform arg2
stringify arg2
check arg1=arg2
jyes same

... handle case when diff...

same
... handle case when same...

end calminstruction

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...
Post 17 May 2023, 14:34
View user's profile Send private message Reply with quote
fabbel



Joined: 30 Oct 2012
Posts: 54
fabbel 17 May 2023, 14:41
Read same: in calminstruction
Post 17 May 2023, 14:41
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3886
Location: vpcmipstrm
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:
Code:
define tester?
define tester?.FOO? foo

calminstruction test arg1, arg2
        transform arg1,tester?
        transform arg2,tester?
...    
... I use this to match symbolic options to a function - so the consumer can use any case.

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
Post 17 May 2023, 17:22
View user's profile Send private message Visit poster's website 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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.