X?NN in future version?

Post here to share useful tips and tricks, to ask questions about using your DM42 or to report software-related problems
Post Reply
Boub65
Posts: 231
Joined: Tue Sep 12, 2017 4:34 pm
Location: Rabat, Morocco

X?NN in future version?

Post 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.
Sincèrement, Sincerely, 73,
Boubker

DM15L, DM41L, DM42 #00855 (domes upgraded), DM41X #00707
HP48SX (with dark screen), HP42s, HP32SII (1990 with fraction bug), HP41C/CV
TI-89 titanium, CASIO fx-cg50 and Numworks (to play with micropython)
Thomas Okken
Posts: 1107
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: X?NN in future version?

Post 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.
whuyse
Posts: 198
Joined: Thu Dec 21, 2017 1:23 pm

Re: X?NN in future version?

Post by whuyse »

I never liked the X=NN? functions either - your suggestion, on the other hand, looks awesome!
Werner
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L
ferni123
Posts: 36
Joined: Tue Aug 08, 2017 11:24 am

Re: X?NN in future version?

Post 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?
Boub65
Posts: 231
Joined: Tue Sep 12, 2017 4:34 pm
Location: Rabat, Morocco

Re: X?NN in future version?

Post 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...
Sincèrement, Sincerely, 73,
Boubker

DM15L, DM41L, DM42 #00855 (domes upgraded), DM41X #00707
HP48SX (with dark screen), HP42s, HP32SII (1990 with fraction bug), HP41C/CV
TI-89 titanium, CASIO fx-cg50 and Numworks (to play with micropython)
Thomas Okken
Posts: 1107
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: X?NN in future version?

Post 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.
Boub65
Posts: 231
Joined: Tue Sep 12, 2017 4:34 pm
Location: Rabat, Morocco

Re: X?NN in future version?

Post 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...
Sincèrement, Sincerely, 73,
Boubker

DM15L, DM41L, DM42 #00855 (domes upgraded), DM41X #00707
HP48SX (with dark screen), HP42s, HP32SII (1990 with fraction bug), HP41C/CV
TI-89 titanium, CASIO fx-cg50 and Numworks (to play with micropython)
Post Reply