Re: RPN versus ALG in programs Message #5 Posted by Vieira, Luiz C. (Brazil) on 27 Aug 2007, 4:16 a.m., in response to message #1 by Thomas Klemm
Hi, Thomas;
(here I am at 4:50 AM feeling insomnia...)
many of us who not only use and deal with HP calculators but also try to go further to their 'guts' have probably read that RPN structures were achieved mostly in search of a resident 'proto', portable operating system that could fit in less ROM, OR could offer the most in the same available ROM space. So, RPN offers many intersting features BUT math precedence. I like to say that math precedence in RPN calculators must be provided by the user, who must master math prior to use an RPN calculator. That is why I think RPN is educative, but I'd rather not going ahead with that in order to avoid seeting fire in extinguished fireplaces...
To achieve algebric operation, it is mandatory to have at least a few registers to store the first keyed-in number and the code of the operation to be performed (for two-number sequences) so you can key in the second value and press [=] key. Keep in mind that there is no way to count on system 'memory' to hold necessary data if this memory has not yet been provided, meaning that, in any digital device, data must reside somewhere, and this 'somewhere' needs a very well defined address and physical circuits... Sorry if you already know about this.
RPN calculators demand no structure for precedence operators because whenever the operation key is pressed, the number(s) over which such operations will be performed must exist in the stack (in programs it happens the same). So they are already stored in X and Y registers and the system only needs to retrieve a copy of them and go ahead with the operations.
Consider line H008 SQRT(A*B)>B in your listing. You see, prior to get the resulting value from SQRT(A*B), the system must store the codes for:
SQRT( (a code for calling it, not the routine itself)
A
*
B (in RPN/ALG HP calculators, shares X-register address) A total of four registers taken from somewhere in RAM, meaning that it actually uses more memory as you noticed, indeed. When the ')' is found, the whole sequence is 'unloaded' and the result is found.
The system uses some cycles (clock) to store the intermediate codes, some others to 'unload' them and the actually necessary cycles to perform then. It may take almost three to four times more time when compared to the RPN version.
I may have left some considerations behind, but I guess the most important facts are described here already.
Hope this helps.
My 2¢.
Luiz (Brazil)
Edited: 27 Aug 2007, 4:39 a.m.
|