Starting HP25 programs with numbers

11242017, 09:38 AM
(This post was last modified: 11242017 09:40 AM by Dieter.)
Post: #1




Starting HP25 programs with numbers
Hi all,
I just encountered an unexpected behaviour in an HP25 program that may be caused by a different way this calculator handles stack lift after number entry. Here are the first lines of the original program: Code: 01 FIX 4 This is supposed to store 2–x in R5, and indeed it works fine. Enter x=3, press R/S and 2–3 = –1 is stored in R5. Now omit the first two lines: Code: 01 2 This led to unexpected results. The result stored in R5 seems to depend on other stack content, it looks like the first step does not cause the user entry to get pushed to Y and leave a 2 in X. The whole thing seems to work if the first line is not a number. I now have found one or two HP25 programs where the first step is NOP preceding a number in the second line. May this be neccessary because the HP25 handles stack lift different from other/later calculators? The HP67 doesn't seem to be affected by this. Then, similar problems occur with the following version: Code: 01 CHS I know that CHS is handled differently in various HP calculators and the above code may result in either X+(–2) or (–X)+2. What does the HP25 do here? I do not have a hardware calculator so I cannot check this. All this showed up in programs for an emulator. BTW, I see that the HP65 requires a NOP as the conditional tests skip two steps if false, but is there a special reason why the HP25 also features a NOP command? Dieter 

11242017, 10:07 AM
Post: #2




RE: Starting HP25 programs with numbers
The CHS and 2 continue number entry. I'd noticed this previously and been a little surprised by it too.
NOP is useful for deleting steps. Pauli 

11242017, 11:26 AM
Post: #3




RE: Starting HP25 programs with numbers
[quote='Dieter' pid='84024' dateline='1511516280']
Now omit the first two lines: Code: 01 2 I think this works ok. if there is only zeros in the stack then the result will be 2. 2[Y]  0[X] = 2[X] Run the program again 2[X]  2[Y] = 0[X] Run it again and it repeats with 2 in X again. If you enter 2 then R/S then the next [2] from line 01 from the program will be a continuation of a number entry. Eg 22 Assuming a clear stack. 22[Y]  0[X] = 22[X]. The HP67 (emulator) does exactly the same thing. cheers Tony 

11242017, 12:14 PM
(This post was last modified: 11242017 12:31 PM by Dieter.)
Post: #4




RE: Starting HP25 programs with numbers
(11242017 11:26 AM)teenix Wrote: I think this works ok. The result should be independent of the stack content. The user enters a number (in this case 1, 2 or 3), presses [R/S] and the program is supposed to calculate 2 minus that number, i.e. 1, 0 or –1. (11242017 11:26 AM)teenix Wrote: If you enter 2 then R/S then the next [2] from line 01 from the program will be a continuation of a number entry. Eg 22 That's exactly the problem. The user enters "3", presses [R/S] and instead of calculating 2–3 the HP25 appends the "2", giving 32, and then calculates 32 minus what happens to be in Y. (11242017 11:26 AM)teenix Wrote: The HP67 (emulator) does exactly the same thing. Which one ?) I am using the Panamatik HP25 and HP67 emulators which are supposed to run the original microcode. Here the bahaviour of both machines differs: Enter the same four step program both in an HP25 and an HP67. Code: 01 2 Then run it on the HP67: h[RTN] 3 [R/S] => –1 This works as I would have expected: [R/S] terminates number entry and so the "2" in the first line starts a new number, pushing the previous input "3" to Y, leading to 2–3=—1, as desired. Now try this on an HP25: GTO 00 3 [R/S] => 32 (assuming an otherwise empty stack) Here [R/S] did not terminate number entry, instead the "2" is appended to the entered "3", giving 32. So finally 32–Y is calculated. Unlike other HPs I have used before. That's why I'm asking here. So the HP25 program must not start with a number here, it requires an additional line that terminates number entry, e.g. ENTER or NOP or FIX 4 or whatever. BTW, comparing both machines, it is nice to see what a difference one year makes: The 1976 HP67 already uses 13digit internal precision while the HP25 still has to rely on merely 10 digits for internal intermediate results. Consequently the infamous 3^{201} example has only 6 (!) correct digits (after rounding). Dieter 

11242017, 02:07 PM
Post: #5




RE: Starting HP25 programs with numbers
(11242017 12:14 PM)Dieter Wrote: Here [R/S] did not terminate number entry, instead the "2" is appended to the entered "3", giving 32. So finally 32–Y is calculated. Unlike other HPs I have used before. That's why I'm asking here. That is authentic HP25 behavior. I don't even have to get mine out of its drawer to check, I remember noticing this quirk back in 1977 and being annoyed at having to waste a line by adding an ENTER in that situation. (11242017 12:14 PM)Dieter Wrote: BTW, comparing both machines, it is nice to see what a difference one year makes: The 1976 HP67 already uses 13digit internal precision while the HP25 still has to rely on merely 10 digits for internal intermediate results. Consequently the infamous 3^{201} example has only 6 (!) correct digits (after rounding). Indeed, but I came to the HP25 from the Sinclair Scientific, which, to me, made the 25 the epitome of speed and accuracy. :) 

11242017, 02:36 PM
Post: #6




RE: Starting HP25 programs with numbers
(11242017 12:14 PM)Dieter Wrote: BTW, comparing both machines, it is nice to see what a difference one year makes: The 1976 HP67 already uses 13digit internal precision while the HP25 still has to rely on merely 10 digits for internal intermediate results. Consequently the infamous 3^{201} example has only 6 (!) correct digits (after rounding). I don't think the HP67 has higher internal precision than the HP25, both represent a number as 10 digit mantissa and 3 digit exponent with sign. Perhaps the 15digit HP67 display suggests a higher precision. It can display the full mantissa all the time, while the 12digit HP25 display shares the display between mantissa and exponent, it shows only 8 mantissa digits when an exponent is displayed. Bernhard That's one small step for a man  one giant leap for mankind. 

11242017, 03:18 PM
(This post was last modified: 11242017 03:26 PM by Thomas Okken.)
Post: #7




RE: Starting HP25 programs with numbers
(11242017 02:36 PM)PANAMATIK Wrote:(11242017 12:14 PM)Dieter Wrote: BTW, comparing both machines, it is nice to see what a difference one year makes: The 1976 HP67 already uses 13digit internal precision while the HP25 still has to rely on merely 10 digits for internal intermediate results. Consequently the infamous 3^{201} example has only 6 (!) correct digits (after rounding). HP Journal, November 1976, pp. 1617, has a sidebar titled The New Accuracy: Making 2^3 = 8, included in the MoHPC document set, which mentions using extra digits for intermediate results. It doesn't say how many, and it does indicate that this extra internal precision was not used for all functions. It does mention using a 13digit approximation of pi internally, for argument reduction. 

11242017, 04:17 PM
Post: #8




RE: Starting HP25 programs with numbers
(11242017 03:18 PM)Thomas Okken Wrote: HP Journal, November 1976, pp. 1617, has a sidebar titled The New Accuracy: Making 2^3 = 8, included in the MoHPC document set, which mentions using extra digits for intermediate results. It doesn't say how many, and it does indicate that this extra internal precision was not used for all functions. It does mention using a 13digit approximation of pi internally, for argument reduction. I apologize. I didn't know that document. According to it, there was made an improvement of precision, which calculates better results in the last digits of the mantissa. It could be very interesting to find (and understand) the firmware parts, which are affected. The register size and usage for final results however is the same as in HP25. Bernhard That's one small step for a man  one giant leap for mankind. 

11242017, 09:11 PM
Post: #9




RE: Starting HP25 programs with numbers
(11242017 12:14 PM)Dieter Wrote: The HP67 (emulator) does exactly the same thing. Which one ?) [/quote] Sorry Dieter, my bad, I probably did something wrong, you are correct. As far as I can see, all the programmable calculators reset their number entry flags when the R/S key is pressed which would give the expected results for this problem. However, the same flag [s8] is not cleared in the HP25 after R/S is pressed, therefore giving the number continuation. There is only 4 words of usable ROM remaining so I don't think this problem could be repaired easily. cheers Tony 

11242017, 09:25 PM
Post: #10




RE: Starting HP25 programs with numbers
(11242017 03:18 PM)Thomas Okken Wrote: HP Journal, November 1976, pp. 1617, has a sidebar titled The New Accuracy: Making 2^3 = 8, included in the MoHPC document set, which mentions using extra digits for intermediate results. It doesn't say how many, and it does indicate that this extra internal precision was not used for all functions. It does mention using a 13digit approximation of pi internally, for argument reduction. some 2^3 results Classics/HP25 X = 08000000002000 (8.000000002) HP65/HP67/HP22/HP27/HP25c/HP34c/HP19c 08000000000000 (8.00) HP21 X=07999997770000 (7.99999777) cheers Tony 

11242017, 10:01 PM
Post: #11




RE: Starting HP25 programs with numbers
(11242017 09:11 PM)teenix Wrote: However, the same flag [s8] is not cleared in the HP25 after R/S is pressed, therefore giving the number continuation. There is only 4 words of usable ROM remaining so I don't think this problem could be repaired easily. I managed to use those spare ROM locations. I cannot see any code reference that would jump to these locations so the problem should be solved. I posted the modified HP25 code at this link if anyone is interested. http://www.teenix.org/HP25rsMod.asm cheers Tony 

11242017, 10:07 PM
Post: #12




RE: Starting HP25 programs with numbers
(11242017 10:01 PM)teenix Wrote: I managed to use those spare ROM locations. I cannot see any code reference that would jump to these locations so the problem should be solved. Hi Tony, There are some HP25 application program from the Applications Programs Manual, which start with ENTER. Do they still behave as expected with your patch? Bernhard That's one small step for a man  one giant leap for mankind. 

11242017, 11:06 PM
Post: #13




RE: Starting HP25 programs with numbers
(11242017 10:07 PM)PANAMATIK Wrote: Hi Tony, Hi Bernhard I tested with the example on page 28 and it worked as described. s8 is cleared just after the code for the Enter function executes cheers Tony 

11242017, 11:18 PM
Post: #14




RE: Starting HP25 programs with numbers
(11242017 11:06 PM)teenix Wrote: Hi Bernhard I already integrated your wonderful patch for the HP29C PAUSE interruption, and I think I should also use this patch for the HP25 emulation, if you allow. Thanks Tony Bernhard That's one small step for a man  one giant leap for mankind. 

11242017, 11:21 PM
Post: #15




RE: Starting HP25 programs with numbers  
11242017, 11:28 PM
Post: #16




RE: Starting HP25 programs with numbers
(11242017 11:18 PM)PANAMATIK Wrote: I already integrated your wonderful patch for the HP29C PAUSE interruption, and I think I should also use this patch for the HP25 emulation, if you allow. Just as an aside, I don't think the pause mod is in this code. You can change your modified pause code with the following... at address Oct 231 (99) delayed select rom 3 go to drsls2 replace with... delayed select rom 4 go to modrs at address oct 2200 ($480) no operation no operation no operation no operation no operation replace with... modrs: 0 > s8 delayed select rom 3 go to drsls2 no operation no operation cheers Tony 

11242017, 11:37 PM
(This post was last modified: 11242017 11:43 PM by Thomas Okken.)
Post: #17




RE: Starting HP25 programs with numbers
(11242017 09:25 PM)teenix Wrote:(11242017 03:18 PM)Thomas Okken Wrote: HP Journal, November 1976, pp. 1617, has a sidebar titled The New Accuracy: Making 2^3 = 8, included in the MoHPC document set, which mentions using extra digits for intermediate results. It doesn't say how many, and it does indicate that this extra internal precision was not used for all functions. It does mention using a 13digit approximation of pi internally, for argument reduction. I'm seeing several differences between these results and Joe Horn's earlier post For which models is 2^3>8? I'm particularly surprised at seeing the 25 and 25C Return different results, and the 65 getting it right... 

11242017, 11:40 PM
Post: #18




RE: Starting HP25 programs with numbers
(11242017 10:07 PM)PANAMATIK Wrote:(11242017 10:01 PM)teenix Wrote: I managed to use those spare ROM locations. I cannot see any code reference that would jump to these locations so the problem should be solved. They should, all of them. Performing an ENTER just before entering a number is necessary if you are in number entry mode already, and unnecessarybutharmless if you're not. With Tony's patch, the calculator won't be in number entry mode when that initial ENTER is executed, and that's fine. 

11242017, 11:49 PM
Post: #19




RE: Starting HP25 programs with numbers
(11242017 11:37 PM)Thomas Okken Wrote: I'm particularly surprised at seeing the 25 and 25C Return different results, and the 65 getting it right... I'm surprised too, because HP25 and HP25C have identical firmware. Bernhard That's one small step for a man  one giant leap for mankind. 

11252017, 12:17 AM
Post: #20




RE: Starting HP25 programs with numbers
(11242017 11:49 PM)PANAMATIK Wrote:(11242017 11:37 PM)Thomas Okken Wrote: I'm particularly surprised at seeing the 25 and 25C Return different results, and the 65 getting it right... My bad again. I'm having a "bad" day. I think I meant the 29c cheers Tony 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)