Adventures with the HP41CL and the %T function..

Publicado el por

Adventures with the HP41CL and the %T function..

Interesting adventures with the HP41cl

As you may have found in this blog, despite being engineer, I have a financial job. Therefore, I have used all HP financial calculators and I am a little bit accustomed to how they work.


In the routine costs analysis, you find yourself trying to see which % of a total are several quantities that form part of that total. HP developed several percentage functions, one of them, %CH, is included in the standard set of HP41 functions (as well as in the HP15c, for that matter). It is logical, since in science you usually try to find how much a variable has increased. However, the “percentage of a total”, %T, is absent in both calculators.


One key feature in all % functions in HP calculators is that they leave the y register untouched (the number from which the x percentage is taken, in the % function; the origin for change, in the %CH function, and the total, in the %T function). Most other functions “consume” the operands, which “collapse” into the result. Why?


Typically the y value needs to be used again. For %, you typically add or subtract the result of % to the base number. For example, if you want to add VAT to a price, you just enter the number, enter, the VAT rate, %, + and you’re done.


In the case of %CH, you may want to try with a different “new” value. You just CLX, which disables stack lift, enter the new value, and you’re ready for another %CH calculation.


With the %T function is the same. Once you have entered the total, you may want to calculate the percentage as part of the total of a number of quantities. Again, for each one, you press CLX, enter the new part, press %T and you’re there.


As I said, there’s no %T function in the plain HP41c. The HP41c manual, in its programming part, shows a supremely elegant way of performing this function:

LBL “%T”

1/X

%

1/X

As % keeps Y, so does %T defined as above.


But when I started working with the HP41CL, and having the Sandmath module as one of the plugged in, I decided to use the %T function that resides there. But when I started using it, I discovered that it did not keep the Y register! It rendered unusable the function for my purposes. What a pity.


I then wrote to Angel Martín to inform him of the function behavior. He had modeled it as the typical binary function, that consumes its parameters, but he came up with the solution: you just need to change a byte in a specific position in the ROM and that’s it. He did it from the top of his head - that’s how well he knows his modules!


As I am not too much versed in the inner working of the HP41cl, I asked him for more directions. Actually, he told me three different way of doing it, from the easiest to the most difficult and dangerous.


The first involves downloading the latest version of the module with the serial cable. A no-no in my case, since I decided early on not to have it. It is ugly, and in the long term I can live with the HP-IL.


The second was to copy the module from its flash location to RAM, then modify it there with YPOKE, and the redirect the PLUG to a port of my choice.


The third involved the initial part of the second, but then writing it back to flash - I did not dare to do it by fear of destroying something.


Here’s the procedure for number 2:


Copy the module to RAM. The location of the 4SMT module was 126 and 127 (is a two block module)

"126>840", YMCPY

"127>841", YMCPY

The byte to change is 0xp8EC, relative to where you put it. So:

Step 1. introduce in Alpha the text: "8408EC-1111"

Step 2. execute YPEEK. You should get "8408EC-0369”. This si to check that the previous step did work, and that you’re operating on the right byte.

Step 3. modify the Alpha value to "8408EC-0331"

Step 4. execute YPOKE.

Step 5. Plug it to the port of your choice (mine was 2):

"840-DBL", PLUG4

Comentarios: 0
Más sobre: HP41cl

Solo los usuarios registrados pueden poner comentarios.
Identificarse y añadir comentario Regístrese ahora