Page 1 of 1

X?NN in future version?

Posted: Mon Feb 22, 2021 9:52 am
by Boub65
Hello @thomasokken,

When progamming, I often find myself testing X against a register...

So naturally I do something like :
RCL NN
X?Y
GTO xx
and then I find myself always adding :
Rv OR X<>Y (to get either the stack or X back)
...

I think that's why the instructions set "X?NN" was added to the X functions CX : you save 2 instructions and increase readability!

Thomas any chance this instructions make it to Free42/DM42?

Sincerely,
Boubker.

Re: X?NN in future version?

Posted: Mon Feb 22, 2021 1:10 pm
by Thomas Okken
Yes, that's certainly possible. I've never liked those specific functions, though, I think I'd prefer something more generic: X=? <param> and 0=? <param>, plus corresponding functions for ≠, <, >, ≤, and ≥. That would cover the CX versions: X=NN? would be equivalent to X=? IND ST Y, and so on.

Re: X?NN in future version?

Posted: Mon Feb 22, 2021 4:43 pm
by whuyse
I never liked the X=NN? functions either - your suggestion, on the other hand, looks awesome!
Werner

Re: X?NN in future version?

Posted: Mon Feb 22, 2021 9:48 pm
by ferni123
Indeed, those type of functions could be interesting.

In case it helps, although not ideal, a way to implement those functions with the user code could be the following.

1) Introduce in the Alpha register the name of the variable or number of the register to check against X-register

2) Run XEQ "X=?" where the function is listed below

LBL "X=?"
FUNC 00
ASTO ST Y
RCL IND ST Y
X=Y?
RTNYES
RTNNO

The variant for comparison with numbered registers would be

LBL "X=NN?"
FUNC 00
ANUM
RCL IND ST X
RCL ST Z
X=Y?
RTNYES
RTNNO


What do you think?

Re: X?NN in future version?

Posted: Mon Feb 22, 2021 11:37 pm
by Boub65
In X=? IND ST Y you still have to modify the stack by puting NN in Y...
Whereas in X=NN? the stack/alpha is untouched... that's the whole point of using X?NN instructions...

Re: X?NN in future version?

Posted: Tue Feb 23, 2021 12:15 am
by Thomas Okken
Boub65 wrote:
Mon Feb 22, 2021 11:37 pm
In X=? IND ST Y you still have to modify the stack by puting NN in Y...
Whereas in X=NN? the stack/alpha is untouched... that's the whole point of using X?NN instructions...
No, the 41CX X=NN? functions compare X to the register pointed to by Y. That is exactly the same as X=? IND ST Y in the functions I'm proposing.
The difference is that X=? <param> is more flexible. If you want to compare X to register 06, that's X=? 06. If you want to compare X to the named variable "FOO", that's X=? "FOO". If you want to compare X to the register or variable pointed to by register 00, that's X=? IND 00. And so on.

Re: X?NN in future version?

Posted: Tue Feb 23, 2021 8:45 am
by Boub65
Ok Thomas I understand now what you meant by X=? <param>
Great then !

You are right! your proposal is much more flexible and your solution will provide either X=? 06 or X=? "FOO" which is exactly what I am looking for! A test without touching the stack

will X=? IND "FOO" be also available? I suppose!

PS: I had a flase understanding of X?NN that is, you are all right, useless as is...