HP Forums
HP-25/SR-56 Identical Conditionals - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP-25/SR-56 Identical Conditionals (/thread-17574.html)



HP-25/SR-56 Identical Conditionals - Matt Agajanian - 10-11-2021 10:43 PM

Hi all.

Was there a reason why the 25 and SR-56 had the same conditionals set?


RE: HP-25/SR-56 Identical Conditionals. - Gene - 10-12-2021 12:44 AM

I suspect not, since they were made by competitors... unless TI decided to copy the ideas of the HP-25 team.

But the SR-56 had the independent "t" or test register while the HP-25 had dedicated conditional tests of X against 0 and X against Y. The SR-56 simply compared the displayed value (X) using =, not =, >= and <, to the value of the "t" register, which may have held a zero or non-zero value.


RE: HP-25/SR-56 Identical Conditionals. - Dave Britten - 10-12-2021 01:52 PM

(10-12-2021 12:44 AM)Gene Wrote:  I suspect not, since they were made by competitors... unless TI decided to copy the ideas of the HP-25 team.

But the SR-56 had the independent "t" or test register while the HP-25 had dedicated conditional tests of X against 0 and X against Y. The SR-56 simply compared the displayed value (X) using =, not =, >= and <, to the value of the "t" register, which may have held a zero or non-zero value.

The TI offers a bit of insight into the design of the 25 here. On the TI, you've got two tests and their inverses. Same on the 25, despite being spread over 4 keys instead of two (and having two comparison targets: Y or 0). So presumably this design saved ROM space, which there wasn't a whole lot of on the 25.


RE: HP-25/SR-56 Identical Conditionals. - Gene - 10-12-2021 03:05 PM

Certainly saved ** program steps ** to do it the HP-25 way.

The HP-25 could have done tests only against Y and if you wanted to test against zero, you simply did a 0 X<>Y test sequence. However, that would really have eaten into the 49 merged steps.

The SR-56, having 100 unmerged steps, which is admittedly more actual memory in practice than the HP-25, did not suffer as much of a hit doing a 0 X<>t test sequence.

That said, I prefer the HP-25 arrangement.


RE: HP-25/SR-56 Identical Conditionals. - Valentin Albillo - 10-12-2021 04:29 PM

.
Hi, Gene:

(10-12-2021 03:05 PM)Gene Wrote:  The SR-56, having 100 unmerged steps, which is admittedly more actual memory in practice than the HP-25, [...]

This has been discussed here a decade or two ago. 100 unmerged steps aren't necessarily "more actual memory" than 49 fully-merged ones, in practice, only marginally if at all.

What results in "more actual memory" in practice is that the SR ("Slide Rule", LOL !) 56 has subroutine capability and this really, really saves steps, a lot in many frequent cases. Think Runge-Kutta 4th order, which requires four calls to f(x,y), or even just Newton's method to solve f(x)=0, which requires two calls to f(x), or Hallery's method, which requires three. As soon as f(x) or f(x,y) isn't trivial, you'll be saving both programming complexity and steps by the truckload.

I remember back then (45 years ago !), that I was *very* tempted to sell my HP-25 and buy the SR-56 (despite me strongly disliking anything algebraic vs. RPN) just because of that subroutine capability, that I saw as essential and upping the calculator to a higher level. Fortunately the HP-67 was introduced, with several levels of subroutines (and lots more) and that saved me from falling for AOS. The horror, the horror !

Also, the SR-56 had some looping construct (DSZ, IIRC), but that was far less important to me.

Best regards.
V.


RE: HP-25/SR-56 Identical Conditionals. - Gene - 10-12-2021 05:54 PM

Agreed, Valentin. Was careless with my shorter response. Thanks for expanding!

Gene


RE: HP-25/SR-56 Identical Conditionals. - Matt Agajanian - 10-12-2021 06:13 PM

(10-12-2021 03:05 PM)Gene Wrote:  Certainly saved ** program steps ** to do it the HP-25 way.

The SR-56, having 100 unmerged steps, which is admittedly more actual memory in practice than the HP-25, did not suffer as much of a hit doing a 0 X<>t test sequence.

That said, I prefer the HP-25 arrangement.

And, you can even cut that down to just one step! Remember that 2nd CP (in Learn mode, definitely not in run mode) cleared the T register.


RE: HP-25/SR-56 Identical Conditionals. - Matt Agajanian - 10-12-2021 06:20 PM

(10-12-2021 04:29 PM)Valentin Albillo Wrote:  .
Hi, Gene:

(10-12-2021 03:05 PM)Gene Wrote:  The SR-56, having 100 unmerged steps, which is admittedly more actual memory in practice than the HP-25, [...]


Also, the SR-56 had some looping construct (DSZ, IIRC), but that was far less important to me.

Best regards.
V.

Yes, both the SR-56 and 52 had two looping constructs: 2nd DSZ (decrement and skip on zero) and INV 2nd DSZ (decrement and skip on non-zero).


RE: HP-25/SR-56 Identical Conditionals. - Valentin Albillo - 10-14-2021 01:16 AM

(10-12-2021 06:20 PM)Matt Agajanian Wrote:  Yes, both the SR-56 and 52 had two looping constructs: 2nd DSZ (decrement and skip on zero) and INV 2nd DSZ (decrement and skip on non-zero).

The latter seems pretty dumb to me.

V.


RE: HP-25/SR-56 Identical Conditionals. - Dave Britten - 10-14-2021 11:38 AM

(10-14-2021 01:16 AM)Valentin Albillo Wrote:  
(10-12-2021 06:20 PM)Matt Agajanian Wrote:  Yes, both the SR-56 and 52 had two looping constructs: 2nd DSZ (decrement and skip on zero) and INV 2nd DSZ (decrement and skip on non-zero).

The latter seems pretty dumb to me.

V.

I've had the occasional situation on an HP where it would be nice to decrement a counter and execute the next instruction only if the counter is now zero, but it's not super common. You can usually get around it with a GTO or some test that will always be false, but it's not quite as clean.


RE: HP-25/SR-56 Identical Conditionals. - Valentin Albillo - 10-14-2021 12:38 PM

(10-14-2021 11:38 AM)Dave Britten Wrote:  
(10-14-2021 01:16 AM)Valentin Albillo Wrote:  The latter seems pretty dumb to me.

I've had the occasional situation on an HP where it would be nice to decrement a counter and execute the next instruction only if the counter is now zero, but it's not super common. You can usually get around it with a GTO or some test that will always be false, but it's not quite as clean.

Then post a non-contrived example which shows its usefulness and cleanness, please.

V.


RE: HP-25/SR-56 Identical Conditionals - Dave Britten - 10-14-2021 04:18 PM

(10-14-2021 12:38 PM)Valentin Albillo Wrote:  
(10-14-2021 11:38 AM)Dave Britten Wrote:  I've had the occasional situation on an HP where it would be nice to decrement a counter and execute the next instruction only if the counter is now zero, but it's not super common. You can usually get around it with a GTO or some test that will always be false, but it's not quite as clean.

Then post a non-contrived example which shows its usefulness and cleanness, please.

V.

I don't have a specific example on the tip of my tongue, but the general pattern usually ends up being something like this on an HP:

Code:

LBL 1 //loop start
...do some things...
DSZ 4 //decrement counter
GTO 0
GTO 9 //exit loop
LBL 0
...do some more things...
GTO 1 //loop end
LBL 9
...post-loop instructions...

i.e. when you need to decrement a counter and break out of the loop when the counter reaches its end, but you need to do this in the middle of the loop body. On a TI you can replace the exit test with something like INV 2nd DSZ 04 9' to break out of the loop when the counter hits 0. Slightly more elegant, but it's a small victory with how much less elegant a lot of programming constructs are on the TI-59/58. Wink


RE: HP-25/SR-56 Identical Conditionals - Valentin Albillo - 10-14-2021 04:49 PM

(10-14-2021 04:18 PM)Dave Britten Wrote:  
(10-14-2021 12:38 PM)Valentin Albillo Wrote:  Then post a non-contrived example which shows its usefulness and cleanness, please.

V.

I don't have a specific example on the tip of my tongue, but the general pattern usually ends up being something like this on an HP:

LBL 1 //loop start
...do some things...
DSZ 4 //decrement counter
GTO 0
GTO 9 //exit loop
LBL 0
...do some more things...
GTO 1 //loop end
LBL 9
...post-loop instructions...

i.e. when you need to decrement a counter and break out of the loop when the counter reaches its end, but you need to do this in the middle of the loop body. On a TI you can replace the exit test with something like INV 2nd DSZ 04 9' to break out of the loop when the counter hits 0. Slightly more elegant, but it's a small victory with how much less elegant a lot of programming constructs are on the TI-59/58. Wink

Excuse me but in your example you use "DSZ 4". At face value, I read this as "Decrement and Skip if Zero (Register 4)".

But I asked for an example of "DSNZ", i.e., "Decrement and Skip if Not Zero" ...

What gives ? Can you supply a non-contrived example using DSNZ, as asked, to see its usefulness and cleanness, please ?

Regards.
V.


RE: HP-25/SR-56 Identical Conditionals - Dave Britten - 10-14-2021 05:00 PM

(10-14-2021 04:49 PM)Valentin Albillo Wrote:  Excuse me but in your example you use "DSZ 4". At face value, I read this as "Decrement and Skip if Zero (Register 4)".

But I asked for an example of "DSNZ", i.e., "Decrement and Skip if Not Zero" ...

What gives ? Can you supply a non-contrived example using DSNZ, as asked, to see its usefulness and cleanness, please ?

Regards.
V.

Well, I did provide an example, but it was in the format seen on a TI where you can actually do this. But if we imagine an HP with a DSNZ function, you could replace the original loop early exit:

Code:

...loop body...
DSZ 4
GTO 0
GTO 9 //exit loop
LBL 0
...rest of the loop body...

...with this:

Code:

...loop body...
DSNZ 4
GTO 9 //exit loop
...rest of the loop body...

It's not a super frequent occurrence, but it does come up for me now and then. I suspect in the case of TI, they figured they've got this unmerged INV prefix instruction already, so might as well make it have an effect on as many other instructions as makes sense. In the case of a calculator with merged steps, it's probably more difficult to argue for giving it space in the opcode table.


RE: HP-25/SR-56 Identical Conditionals - Valentin Albillo - 10-14-2021 06:02 PM

(10-14-2021 05:00 PM)Dave Britten Wrote:  Well, I did provide an example, but it was in the format seen on a TI where you can actually do this. But if we imagine an HP with a DSNZ function, you could replace the original loop early exit:

...loop body...
DSZ 4
GTO 0
GTO 9 //exit loop
LBL 0
...rest of the loop body...

...with this:

...loop body...
DSNZ 4
GTO 9 //exit loop
...rest of the loop body...


Look, Dave, what you've given above is not an example of actual non-contrived code using the DSNZ function, you've just given an Owner's Handbook-style code bit picturing what it does.

I don't mean to play games with you, what I want is some sample code which does something non-contrived that shows the alleged "usefulness" and "cleanness" afforded by this DSNZ instruction, let's say similarly to how a simple implementation of the factorial function does clearly demonstrate the usefulness of the regular DSZ instruction.

Can you provide it, yes or no ?

Thanks and regards.
V.


RE: HP-25/SR-56 Identical Conditionals - Dave Britten - 10-14-2021 07:51 PM

(10-14-2021 06:02 PM)Valentin Albillo Wrote:  Look, Dave, what you've given above is not an example of actual non-contrived code using the DSNZ function, you've just given an Owner's Handbook-style code bit picturing what it does.

I don't mean to play games with you, what I want is some sample code which does something non-contrived that shows the alleged "usefulness" and "cleanness" afforded by this DSNZ instruction, let's say similarly to how a simple implementation of the factorial function does clearly demonstrate the usefulness of the regular DSZ instruction.

Can you provide it, yes or no ?

Thanks and regards.
V.

Have you never needed to write a "for" or "while" loop where you break in the middle of the loop body instead of at the physical end of it? That's where this sort of thing would come in handy now and then.

For the sake of example, here's a cumulative (lower tail) binomial distribution program for 15C. Store n in R1, P in R2, and X in R3, then GSB A.

Code:
LBL A
0
STO 4
STO 5
RCL 2
1
STO+ 3
RCL- 2
/
STO 6   // P/(1-P)
LST x
RCL 1
y^x     // B(n, 0, P) = (1-P)^n
LBL 1
STO+ 5  // Add to cumulative probability
/**** LOOP EXIT TEST ****/
DSE 3   // Decrement loop counter
GTO 0
GTO 9   // Break from loop if counter was zero
LBL 0
/**** END OF LOOP EXIT ****/
RCL 1   // Calculate B(n, r+1, P)...
RCL 4   // B(n, r+1, P) = 
-       //     B(n, r, P) * (n-r)/(r+1) * P/(1-P)
RCL 4
1
+
STO 4
/
RCL* 6
*       // Done calculating next term
GTO 1   // Do another loop
LBL 9
RCL 5   // Display total
RTN

With a hypothetical DSNE (decrement and skip if not less than or equal), the loop exit condition could be shortened by removing the extra GTO and LBL:

Code:
LBL A
0
STO 4
STO 5
RCL 2
1
STO+ 3
RCL- 2
/
STO 6   // P/(1-P)
LST x
RCL 1
y^x     // B(n, 0, P) = (1-P)^n
LBL 1
STO+ 5  // Add to cumulative probability
/**** LOOP EXIT TEST ****/
DSNE 3   // Decrement loop counter
GTO 9   // Break from loop if counter was zero
/**** END OF LOOP EXIT ****/
RCL 1   // Calculate B(n, r+1, P)...
RCL 4   // B(n, r+1, P) = 
-       //     B(n, r, P) * (n-r)/(r+1) * P/(1-P)
RCL 4
1
+
STO 4
/
RCL* 6
*       // Done calculating next term
GTO 1   // Do another loop
LBL 9
RCL 5   // Display total
RTN



RE: HP-25/SR-56 Identical Conditionals - Valentin Albillo - 10-14-2021 09:33 PM

(10-14-2021 07:51 PM)Dave Britten Wrote:  
(10-14-2021 06:02 PM)Valentin Albillo Wrote:  I don't mean to play games with you, what I want is some sample code which does something non-contrived that shows the alleged "usefulness" and "cleanness" afforded by this DSNZ instruction, let's say similarly to how a simple implementation of the factorial function does clearly demonstrate the usefulness of the regular DSZ instruction.

Can you provide it, yes or no ?

[...]
With a hypothetical DSNE (decrement and skip if not less than or equal),
[...]


Now you resort to moving the goalpost. I'm talking about the DSNZ instruction here, not the DSNE instruction, their uncle or any other relatives.

Can you post a simple example that shows the alleged "usefulness" and "cleanness" afforded by this DSNZ instruction, yes or no ?

And please, no "cumulative (lower tail) binomial distribution"-like programs, just something simple, on the level of a factorial program or something equally simple. Simple does it.

If you can't deliver what is asked, well, the world doesn't end but I'm not asking again, I'll simply rest my case that this DSNZ instruction is pretty dumb, as no simple proof-of-concept program can be produced to demonstrate its supposed virtues, period.

Again, thanks and regards.
V.


RE: HP-25/SR-56 Identical Conditionals - Dave Britten - 10-14-2021 09:36 PM

(10-14-2021 09:33 PM)Valentin Albillo Wrote:  
(10-14-2021 07:51 PM)Dave Britten Wrote:  [...]
With a hypothetical DSNE (decrement and skip if not less than or equal),
[...]


Now you resort to moving the goalpost. I'm talking about the DSNZ instruction here, not the DSNE instruction, their uncle or any other relatives.

Can you post a simple example that shows the alleged "usefulness" and "cleanness" afforded by this DSNZ instruction, yes or no ?

And please, no "cumulative (lower tail) binomial distribution"-like programs, just something simple, on the level of a factorial program or something equally simple. Simple does it.

If you can't deliver what is asked, well, the world doesn't end but I'm not asking again, I'll simply rest my case that this DSNZ instruction is pretty dumb, as no simple proof-of-concept program can be produced to demonstrate its supposed virtues, period.

Again, thanks and regards.
V.

The only reason I have DSNE there is because the 15C has DSE rather than DSZ, and that was the model I had handy to quickly knock this together. It would work exactly the same if you replace that instruction with DSNZ in the example - it's just counting down toward zero.

Please get over yourself, INV DSZ is no more stupid/redundant than including LOG when the calculator already has LN available.