Dec 052017
TSR RPN scientific/financial calculator with TP3 source.
File RPNCALC.ZIP from The Programmer’s Corner in
Category Pascal Source Code
TSR RPN scientific/financial calculator with TP3 source.
File Name File Size Zip Size Zip Type
RPNCALC.COM 26363 16983 deflated
RPNCALC.DOC 4634 1805 deflated
RPNCALC.PAS 54895 13225 deflated

Download File RPNCALC.ZIP Here

Contents of the RPNCALC.DOC file


RPNCALC is a TSR FORTH-like calculator written in Turbo Pascal 3.01.
The TSR code is from a public domain package called STAYRES by Lane Ferris
and Neil Rubenking. The original RPNCALC code was from a public domain
subroutine package written by Samuel H. Smith. I have extensively modified
the RPNCALC code and added many new functions.
The following functions are supported:

+ plus
- minus
* times
/ divide
^ power
\ inverse
% percent
ln natural log
log log10
pi PI
e e
abs absolute value
int integer part
frac fractional part
mod modulus
chs change sign
sqrt square root
sqr square
sin sine
cos cosine
tan tangent
asin arcsine
acos arccosine
atan arctangent
hr convert HH.MMSSHH to decimal hours
hms convert decimal hrs to HH.MMSSHH
jdn convert YYYY.MMDD to julian day number
date convert julian day number to YYYY.MMDD
drop [n1 n2 ... n1]
dup [n1 ... n1 n1]
swap [n1 n2 ... n2 n1]
over [n1 n2 ... n1 n2 n1]
rot [n1 n2 n3 ... n2 n3 n1]
clst clear stack
clrg clear registers
! store
@ fetch
.s display stack
fix set format for fixed display (e.g. 10.2 fix)
sci set format for scientific display (e.g. 16.5 sci)
cls clear calculator window
fin initialize financial functions
n calculate number of years
i calculate interest rate (as percent)
pv present value
pmt payment
fv future value
? help

The stack size is set to 20 and there are 10 registers. These may be
changed by altering the appropriate declarations and recompiling.
The financial functions are invoked by first calling FIN with 5 numbers
on the stack in the order N I PV PMT FV. Some of these may be placeholders.
Then execute the particular financial function needed. For example, to
calculate the monthly payment for a ten year loan of $10000 at 11.2 %,
enter the following: 10 12 * 11.2 12 / 10000 0 0 fin pmt. You will be
prompted for compounding frequency (default = 1), payment frequency (default
= 1), continuous or discrete compounding( default = D) and beginning or
end of period payment (default = E). The answer will be -138.88. The
standard convention that a negative sign indicates a cash outflow is used.
FIN stores the five arguments in registers 1-5, so for what-if exercises
the arguments may be modified directly after the first time. For example,
continuing with the above example, to see the effect of a 10.5% interest
rate instead of 11.2% just enter 10.5 12 / 2 ! pmt and get the answer -134.93.
The program installs itself using interrupt $60. This may be changed
by recompiling if necessary. When RPNCALC is executed it will just install
itself and then return to DOS. To invoke it at any time, the hotkey is
ALT F10. This may also be changed. To quit RPNCALC while retaining the stack
and registers, enter Q or q at the prompt. To exit and have RPNCALC
uninstall itself, enter control home at the prompt. This should only be
done from DOS.
I have tried to trap potential error conditions, and if one is found
or if an unknown command is found in the command string, the string will
be written out with an underscore at the error. It is possible, however,
that errors such as numeric overflow will occur, so be warned. To the best
of my knowledge all numerical algorithms are correct and work as described,
however no representation is made that such is actually the case.
All code in RPNCALC that is not already in the public domain is hereby
placed in the public domain for personal non-commercial use only.

S. Jason Olasky, December 20, 1988.

 December 5, 2017  Add comments

Leave a Reply