INV DSZ in its natural habitat
|
10-15-2021, 01:56 PM
Post: #1
|
|||
|
|||
INV DSZ in its natural habitat
Yesterday there was some question as to whether or not the INV DSZ (decrement and skip if not zero) instruction present on some TIs was at all useful. I maintain that it's useful in any situation where you decrement a counter and break out of the middle of a loop, rather than at the end of the loop body.
I put together a little example by way of a cumulative binomial distribution program. First, a BASIC version for the 71B that makes the algorithm a little easier to read: Code: 0001 DESTROY ALL To use it, run the program, enter the number of trials N, the probability of success in a single trial P, and the number of successful trials X. The program will show the cumulative lower tail binomial probability, i.e. probability of the number of successes being between 0 and X. Note line 90, where the program decrements a counter, and breaks out of the middle of the loop (lines 80 to 110) when the counter reaches zero. Now, here are printouts of both an HP 97 version, and a TI-59 version. On the HP version, you have to do something like using an extra LBL and GTO to invert the DSZ test behavior. On the TI-59, you can simply use INV DSZ directly. To run either of these, store N in R01, P in R02, X in R03, and press A. https://i.imgur.com/rxENjWN.jpg Ignoring the fact that the TI program is about twice the size of the HP one it's clear that this is a case where INV DSZ can be used to save a couple of steps, and make the program flow easier to read. |
|||
10-15-2021, 04:18 PM
Post: #2
|
|||
|
|||
RE: INV DSZ in its natural habitat
I assume these two statements are used to implement the following types of loop (expressed in C syntax), in which case both have their place.
Code: /* DSZ */ whereas Code: /* INV DSZ (or DSNZ) */ |
|||
10-15-2021, 04:24 PM
Post: #3
|
|||
|
|||
RE: INV DSZ in its natural habitat
Kind of. It's more akin to this, at least in my example:
Code: c = 10; |
|||
10-16-2021, 12:12 AM
Post: #4
|
|||
|
|||
RE: INV DSZ in its natural habitat
Dave,
Someone at TI found INV DSZ useful since it was used in steps 28-29 of their Battleship program in the SR-56 Application Library book, p. 188. Ross |
|||
10-18-2021, 06:38 PM
Post: #5
|
|||
|
|||
RE: INV DSZ in its natural habitat
INV DSZ/ISZ can be usefull in some cases. Here a size optimized code for the TI-62 to calculate the factoral:
Code: 00 * Usage example: 69 STO 0 RST R/S Calculator Benchmark |
|||
10-19-2021, 06:54 PM
Post: #6
|
|||
|
|||
RE: INV DSZ in its natural habitat
(10-18-2021 06:38 PM)xerxes Wrote: INV DSZ/ISZ can be usefull in some cases. Here a size optimized code for the TI-62 to calculate the factoral: Nice, didn't realize the lower-end machines had it too. I wonder if it works on the TI-65. |
|||
10-19-2021, 09:03 PM
Post: #7
|
|||
|
|||
RE: INV DSZ in its natural habitat
(10-19-2021 06:54 PM)Dave Britten Wrote: Nice, didn't realize the lower-end machines had it too. I wonder if it works on the TI-65. INV DSZ is also present on the TI-65, but I'm not sure, if the code works on the TI-65 too, because it based on the circular program execution ability of the TI-62. Calculator Benchmark |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)