![]() |
Extended TVM-solver for the WP34s - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: Extended TVM-solver for the WP34s (/thread-189903.html) |
Extended TVM-solver for the WP34s - fhub - 08-06-2011 I've now finally finished my extended TVM-program. :-) The first version of such a TVM-solver I've written in the good old HP-41 days, and since then ported it to many other different calculators (Sharp PC-1500, HP-48, TI-92+ ...).
I call it 'extended' because it has 2 additional parameters NP and NI (in English PF and CF for payment/compound frequency) which allows to set different periods for payments and compounding. It has 256 steps and is in *.wp34s format, so it can be compiled with the WP34S assembler - and a quite detailled description is included. Let me know if there's any interest - I could either post it directly here in the forum or upload the file to my website. Franz
Edited: 6 Aug 2011, 11:12 a.m.
Re: Extended TVM-solver for the WP34s - Walter B - 08-06-2011
Quote:For sure there's interest! I'd suggest uploading your file to SourceForge where the WP 34S lives. If you agree, please send it to any member of the development team, and we'll put it in for you :-)
Walter
Re: Extended TVM-solver for the WP34s - fhub - 08-06-2011 Quote:Well Walter, I prefer a place where I have access to. What if I would like to change anything? Or what if a bug has to be fixed - although that's very unlikely because my programs never have bugs. ;-) I've sent it now to Marcus ... Of course feel free to add my 'Extended TVM-Solver' to your project site at Sourceforge if you want, but first make sure that it will meet your high quality standards for WP34s programs ... :-) Franz
Edited: 8 Aug 2011, 8:28 a.m. after one or more responses were posted
Re: Extended TVM-solver for the WP34s - Marcus von Cube, Germany - 08-06-2011 I'm sure it will meet our standards. :-)
WP 34S features are still emerging and so it may be necessary to adapt existing software. Remember the recent discussion about labels beyond A to D. We are willing to keep the included programs in sync with the current feature set. If we find any discrepancy between used and available features we will happily adapt the code included in the package, including yours.
Re: Extended TVM-solver for the WP34s - Paul Dale - 08-06-2011 Quote: Ask and I'll give you subversion access.
Quote: The program looks good. Only two very minor things to consider changing. Alpha registers are special so the saving and restoring the value into K at steps 13 and 15 isn't the best -- it will prevent using the statistical distributions and this financial package together. I'd suggest using L for this since that has been destroyed anyway rather than a grabbing another numeric register. Damn, CLSTK wipes out L so that won't work :-( The other is the relevance of some of the error messages -- "bad mode" is used everywhere else to indicate that the device is in integer/real mode and the operation selected is only valid in real/integer mode. Like I said, fairly minor. There are also a couple of SKIP statements that SKIP to a RTN. Why not just replace them with a RTN. e.g. Lines 78 and 84. Also, we're in the process of rethinking the extra labels again so there will likely be further changes in this area. Anyway, a good library routine to have. - Pauli
Edited: 6 Aug 2011, 8:08 p.m.
Re: Extended TVM-solver for the WP34s - Paul Dale - 08-06-2011 How about this to avoid using K:
010 LBL 00 // return after input or calculation Costs one step and saves using one register. This also avoids zeroing the I register which CLSTK does.
Edited: 6 Aug 2011, 8:20 p.m.
Re: Extended TVM-solver for the WP34s - fhub - 08-07-2011 Quote:Haha, using L is exactly what I also tried first. Quote:Well, it's the best error message I found for this case. ;-) Trying to use a 'final' value (FV) for an 'infinite' number of periods (N) is something that could also be seen as "being in a bad mode". :-) Quote:That's just my tidiness: I like to have a 'logical' program structure, and one thing that belongs to this is that a procedure of function has exactly one entry point and one exit point. So it's easier to see where the end of a subroutine is: just look for the next RTN - with several RTNs this is a bit confusing.
And for your other suggestion to replace this register K usage:
Franz
Re: Extended TVM-solver for the WP34s - fhub - 08-07-2011 Quote:Well, I've now changed it (a 2nd time) to: 010 LBL 00 // return after input or calculationNow it uses R09 instead of K - this register is only used internally and is always re-initialized before any new calculation, so using it here won't hurt (and all following line numbers don't change with this method).
Edited: 7 Aug 2011, 5:37 a.m.
Re: Extended TVM-solver for the WP34s - Walter B - 08-07-2011
Quote:Hmmmh, my understanding of tidiness at the end of a routine is having the result in X, and the other levels containing what was therein before calling said routine. Finishing a routine with CLSTK or FILL is a strategy of "burnt soil" IMHO ;-)
Walter
Re: Extended TVM-solver for the WP34s - fhub - 08-07-2011 Quote:Yes, in a strict sense you're right, Walter. :-)
But this would require saving the stack before and restoring it after any calculations. SaveStack:But this would cost another few bytes in the (always too small) RAM ... ;-)
BTW, the 2 routines above together with SwapStack:would be a nice enhancement of the 34s commands: S-SAVE, S-REST and S-SWAP (or S-STO, S-RCL and S-SWP) like the similar R-commands, won't it? :-) (SaveStack and SwapStack work even in SSIZE8 mode, only RestoreStack needs some modifications for SSIZE8) Franz
Edited: 7 Aug 2011, 7:17 a.m.
Re: Extended TVM-solver for the WP34s - Paul Dale - 08-07-2011 What about STOS and RCLS ?? We don't have a swap stack command but it doesn't seem all that useful to me.
Re: Extended TVM-solver for the WP34s - fhub - 08-07-2011 Quote:Well, you seem to have overlooked my comment "(unless you're using still other registers Rnn)". ;-) Quote:You can never have enough stack manipulation commands ... :-) Such a SwapStack command would be like a 'quad' x<>y (compared to the existing 'cpx' x<>y) Franz
Edited: 7 Aug 2011, 8:53 a.m.
Re: Extended TVM-solver for the WP34s - fhub - 08-07-2011 Quote:I just had another idea: What if these commands would accept A as destination (STOS A and RCLS A)? Of course this should only use 4 stack registers (storing XYZT and recalling ABCD) even in SSIZE8 mode - this would then (almost) exactly do what I've intended with my above SaveStack and RestoreStack: in SSIZE4 it saves and restores XYZT, and in SSIZE8 it would just act as XYZT->ABCD (for STOS A) and ABCD->XYZT (for RCLS A).
Edited: 7 Aug 2011, 9:21 a.m.
Re: Extended TVM-solver for the WP34s - Walter B - 08-07-2011 Well Franz, you've got 100 general purpose registers - use four of them at a nice address :-)
Re: Extended TVM-solver for the WP34s - fhub - 08-07-2011 Quote:100? My other calculators let me use thousands registers ... ;-) Re: Extended TVM-solver for the WP34s - fhub - 08-09-2011 A short note, Marcus: I guess your changes of the shortcut labels are now permanent, so maybe it would be a good idea to also fix the TVM-solver code, because with the current build it doesn't work anymore as expected. LBL G, H and I (in lines 047, 054 and 061) should be changed to LBL 21, 22 and 23 resp.
And there's a small typo in the description at th beginning: And maybe the 3 occurences of 'FIN' could be changed to 'TVM', but that's just a matter of taste and I let this be your decision. ;-) Franz
Edited: 9 Aug 2011, 5:57 a.m.
Re: Extended TVM-solver for the WP34s - Update! - fhub - 08-09-2011 BTW, I've found a nice trick for the problem to clear the stack but retain the X register (which was in discussion about my previously used method): RCL- XOf course no big deal, but saves one byte again ... ;-)
PS: Once again I forgot something: since now there's this new error message for SLV, I've also changed this message in the program.
The updated current version of TVM can be found here:
Edited: 9 Aug 2011, 7:22 a.m.
Re: Extended TVM-solver for the WP34s - Update! - Marcus von Cube, Germany - 08-09-2011 An updated version of your code is now in the pre-compiled library. :-)
I have yet to check the latest ZIP package for the documentation changes.
Re: Extended TVM-solver for the WP34s - Update! - fhub - 08-09-2011 Quote:Yes, you should better use this new ZIP, because it contains a few corrections.
You only have to add your 'Intro' (=Vorspann) ... :-)
Edited: 9 Aug 2011, 8:10 a.m.
Re: Extended TVM-solver for the WP34s - Update! - Marcus von Cube, Germany - 08-09-2011 Franz,
Quote:
Any reason for this? The program should work fine in the library space.
Re: Extended TVM-solver for the WP34s - Update! - fhub - 08-09-2011 Quote:Well, I've made some 'strange' experiences while testing the program, and since I have no explanation for this I thought it would be safer to have it in RAM.
The problem was the following:
So I believe that manually starting or excuting a program that ends with a RTN (or doing a GTO..) sets the program-counter back into the RAM, and so the program in the flash-ROM is no longer accessable (unless you chose it again). Franz
Edited: 9 Aug 2011, 11:59 a.m.
Re: Extended TVM-solver for the WP34s - Update! - Marcus von Cube, Germany - 08-09-2011 I'll check it with Pauli. Thanks for the info. As long as you stick to the hot keys, everything is fine from the library space.
Re: Extended TVM-solver for the WP34s - Update! - fhub - 08-09-2011 I just saw another small issue: when you go to program mode and view the listing of a flash program, then the first step starts with 002 (and also all other line numbers are one too high).
And for the other problem above - I think it's just the way RTN is implemented: And this is the point: maybe it should not always return to the top of the programspace in RAM, but to the top of the 'currently selected' programspace, i.e. to the top of the Flash when this Flash was the last being used.
Edited: 9 Aug 2011, 1:23 p.m.
Re: Extended TVM-solver for the WP34s - Update! - Marcus von Cube, Germany - 08-09-2011 Regarding the listing issue I need to check it for myself.
You have fully understood the RTN problem. I've started a discussion with Pauli what the best way to treat this would be. Your proposal is one possible option.
Re: Extended TVM-solver for the WP34s - Walter B - 08-09-2011 Honestly, what do you want to do with more than 100 general purpose registers in such a calculator? Will be difficult to keep track of them already :-/
Re: Extended TVM-solver for the WP34s - fhub - 08-09-2011 Quote:Well, as soon as you would like to deal with matrices, 100 registers are almost nothing. Re: Extended TVM-solver for the WP34s - Walter B - 08-09-2011 Quote:You're right in principle, but
Edited: 9 Aug 2011, 5:40 p.m.
Re: Extended TVM-solver for the WP34s - fhub - 08-09-2011 Yes, I agree with you in (almost) all points - matrix math is definitely "one shoe number too large" (as we say in German ;-)) for the 34s. But I'm using it on the HP48GX and the TI92+ without problems, and especially on the latter it really makes fun - but of course not 100x100 monsters. :-)
Re: Extended TVM-solver for the WP34s - Update! - fhub - 08-09-2011 Quote:Yes, but - after thinking more about it - this is also working only because my hotkey routines don't end with a RTN but with a STOP command. If they had a RTN at the end then after the first call of such a routine the program counter would be out of the flash again and every further hotkey usage would fail.
So it's indeed really a problem for every program called or used directly from the flash space. :-(
|