The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

HP 34s: Three financial routines
Message #1 Posted by Miguel Toro on 12 Nov 2011, 7:42 p.m.

Hi,

I posted three financial routines for the HP 34s on the Articles section, to complement the existing TVM application :

- Cash flow analysis (corrected and improved by Dieter)

- Amortization

- Nominal / Effective interest rate conversion

As always, any suggestion is very welcome.

Regards,

Miguel

Edited: 12 Nov 2011, 7:43 p.m.

      
Re: HP 34s: Three financial routines
Message #2 Posted by Neil Hamilton (Ottawa) on 13 Nov 2011, 1:55 p.m.,
in response to message #1 by Miguel Toro

Hi Miguel,

I am really glad to see you using the preprocessor extension to the WP 34S assembler! That is gratifying. Your code is an excellent example of usage of the extension.

A couple of points that will help in certain cases:

1) Most importantly, if you are using this tool (wp34s_pp or the -pp switch in wp34s_asm), it is better to let the tool assign the local label names (eg: LBL 01) and use a symbolic label for the target of your SLV or XEQ statement. (Just as a reminder, and not that you violated this, but the preprocessor cannot handle duplicate local labels [ie: LBL 01]. It is usually (always?!) better to let the tool choose local labels to use itself.)

2) For ease of input you can recode most of the text strings by using double quotes. The tool will parse it and figure out the most efficient coding required. Several things, like spaces, are automatically recoded as the '[space]' equivalent. In some cases, the double quote technique will produce fewer steps than you would have gotten otherwise. Regardless of whether the output steps are identical or not, it is certainly easier to code the strings using double quotes.

3) You have a few cases where your use stretched to the tool to places it was not intended to go :-) In at least one case, you made use of a GTO with a 'soft' label (step 16 of 'CFE', for example) where it had been my intention that this technique designed for use with the pseudo JMP instruction. In a way I am glad that the GTO actually worked in this case but I don't think it was never tested (at least not extensively)! In this example, if you had used a JMP instead GTO, the tool would have decided that this could have been coded with a SKIP instruction. These JMP->SKIP promotions will save a few steps here and there because the tool would not be forced to inject a LBL for the soft-targetted GTO.

I have attached a 'diff' output between your code and a slightly modified version to show you what I mean. The first line of each diff pair is the original line(s) from your code and the second line(s) are how I modified it. I can send you the modified code as a whole if you'd like. Just let me know.

Not that the resulting compression make too much difference, but your code assembled to 317 words in total (228 steps) and my variation assembled to 314 words (again, in 228 steps). This is mostly the loss of the additional LBLs (I think).

Keep up the fine work!

280c280
<     [alpha]'CF'
---
>                 "CF"
282,283c282
<     [alpha] [^]
<     [alpha] n
---
>                 "[^]n"
287c286
<     GTO endloop
---
>                 JMP endloop
311,312c310
<     [alpha]'CF'
<     [alpha] =
---
>                 "CF="
346c344
<     [alpha]'CF'
---
>                 "CF"
348c346
<     [alpha] =
---
>                 "="
396c394
<     XEQ 00
---
>                 XEQ calcNPV_IRR
399,400c397
<     [alpha]'NPV'
<     [alpha] =
---
>                 "NPV="
435c432
<     SLV 00
---
>                 SLV calcNPV_IRR
447,448c444
<     [alpha]'IRR'
<     [alpha] =
---
>                 "IRR="
454,455c450
<     LBL 00          // Calculates NPV and solves for IRR
<     1
---
> calcNPV_IRR::   1 // Calculates NPV and solves for IRR
468c463
<           GTO intzero
---
>                 JMP intzero
527,528c522
<     [alpha]'Cap'
<     [alpha] ?
---
>                 "Cap?"
533,534c527
<     [alpha]'Pmt'
<     [alpha] ?
---
>                 "Pmt?"
539,540c532
<     [alpha]'Tpr'
<     [alpha]'ds?'
---
>                 "Tprds?"
548,549c540
<     [alpha]'I/P'
<     [alpha]'%?'
---
>                 "I/P%?"
588,589c579
<     [alpha]'Prd'
<     [alpha]'-I?'
---
>                 "Prd-I?"
595,596c585
<     [alpha]'Prd'
<     [alpha]'-F?'
---
>                 "Prd-F?"
611c600
<     [alpha]'Pri'
---
>                 "Pri"
616c605
<     [alpha]'Int'
---
>                 "Int"
621c610
<     [alpha]'Bal'
---
>                 "Bal"
701,702c690
<     [alpha]'P-Y'
<     [alpha] ?
---
>                 "P-Y?"
733c721
<     XEQ 01
---
>                 XEQ calcEFF_NOM
739,740c727
<     LBL 01          // Calculates EFF and solves for NOM
<     RCL D
---
> calcEFF_NOM::   RCL D          // Calculates EFF and solves for NOM

            
Re: HP 34s: Three financial routines
Message #3 Posted by Miguel Toro on 13 Nov 2011, 3:11 p.m.,
in response to message #2 by Neil Hamilton (Ottawa)

Thank you Neil for your comments, I will make the necessary changes to incorporate them in my code and post an edited version.

Have a nice evening,

Miguel

            
Re: HP 34s: Three financial routines
Message #4 Posted by Miguel Toro on 13 Nov 2011, 3:56 p.m.,
in response to message #2 by Neil Hamilton (Ottawa)

...And done!


[ Return to Index | Top of Index ]

Go back to the main exhibit hall