{"id":2486,"date":"2023-12-25T02:10:40","date_gmt":"2023-12-25T02:10:40","guid":{"rendered":"https:\/\/www.sydneysmith.com\/wordpress\/?p=2486"},"modified":"2023-12-25T21:21:41","modified_gmt":"2023-12-25T21:21:41","slug":"hp-25-ytox","status":"publish","type":"post","link":"https:\/\/www.sydneysmith.com\/wordpress\/2486\/hp-25-ytox\/","title":{"rendered":"HP-25 &#8211; YTOX"},"content":{"rendered":"\n<h2>The Problem<\/h2>\n\n\n\n<p>I had someone ask me recently about &#8220;ytox&#8221; (y^x) on a HP-25. He&#8217;d done 2 ENTER 29 f y^x, got 536870908.6 back, and thought that was wrong.<\/p>\n\n\n\n<p>It is hardly surprising that he thought it was wrong &#8211; very few powers of two end up with &#8220;.6&#8221; on the end. 29 shouldn&#8217;t be one of those.<\/p>\n\n\n\n<p>Perhaps it was a precision thing. We&#8217;re clearly pushing the bounds of what is reasonable here.<\/p>\n\n\n\n<h2>Other Calculators<\/h2>\n\n\n\n<p>However, he then said &#8220;it works fine on a HP-67&#8221;. That blew the whole 14 BCD digits with only 10 digits in the mantissa (significant digits) idea out of the park. Both calculators treat numbers the same way internally and both the HP-25 and HP-67 even have the same processor in them.<\/p>\n\n\n\n<p>I tried it. He was right. In both cases &#8211; it was wrong on the <a href=\"http:\/\/www.sydneysmith.com\/products\/hp25u\/run\/index.html\" data-type=\"URL\" data-id=\"http:\/\/www.sydneysmith.com\/products\/hp25u\/run\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">HP-25<\/a> and it was right on the <a href=\"http:\/\/www.sydneysmith.com\/products\/gss-hp67u\/run\/index.html\" data-type=\"URL\" data-id=\"http:\/\/www.sydneysmith.com\/products\/gss-hp67u\/run\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">HP-67<\/a>.<\/p>\n\n\n\n<p>Out of curiosity, I tried it on a HP-29 and got the correct result. I, and probably many others, consider the HP-29 to be a HP-25 with upgrades. It&#8217;s in the same case. It has, pretty much, the same keys &#8211; and they&#8217;re in the same spots too. Sure, the HP-29 is a much nicer calculator. They added quite a lot to the HP-25 to get there. But the starting point was obviously a HP-25. With them focused on adding things, I did not expect they had much time for rewriting what was already done. It was a surprise to see that y^x had been improved.<\/p>\n\n\n\n<p>Looking at the dates for the calculators using the unofficial <a href=\"http:\/\/hpmuseum.org\" data-type=\"URL\" data-id=\"http:\/\/hpmuseum.org\">hpmuseum.org<\/a> site shows the sequence as: 1975 HP-25, 1976 HP-25C, 1976 HP-67, 1977 HP-29C. Before the HP-25 was: 1974 the HP-65 (and early in 1975, the HP-55).<\/p>\n\n\n\n<p>That also suggested, &#8220;what about the HP-65?&#8221; There&#8217;s one of those lying around (<a rel=\"noreferrer noopener\" href=\"http:\/\/www.sydneysmith.com\/products\/gss-hp65\/run\/index.html\" data-type=\"URL\" data-id=\"http:\/\/www.sydneysmith.com\/products\/gss-hp65\/run\/index.html\" target=\"_blank\">HP-65<\/a>). Unlike its upgrade, the HP-67, it gives the same answer as the HP-25. It got it wrong (slightly). The correct answer is 536870912.0 not 536870908.6.<\/p>\n\n\n\n<p>Whilst I do have access to a HP-55 (not yet published on this site as, whilst interesting, it wasn&#8217;t one I&#8217;d used); I didn&#8217;t really check what it gave. If the HP-65 before it gave the wrong answer, and the HP-25 after it also gave the wrong answer, it was likely to give the same wrong answer. I&#8217;ve just checked and it does.<\/p>\n\n\n\n<p>The early HP calculators get this one wrong (slightly). The later ones don&#8217;t. The crossover point seems to be the HP-25.<\/p>\n\n\n\n<p>Late in 1975 or early in 1976 HP improved the microcode in their newer calculators to get this right.<\/p>\n\n\n\n<h2>Why<\/h2>\n\n\n\n<p>So then, why do the earlier ones get it wrong?<\/p>\n\n\n\n<p>This will get a bit technical. I&#8217;m skipping over a lot and summarising big chunks in order to make it a bit easier to follow. However, if that&#8217;s not your thing, feel free to skip over this.<\/p>\n\n\n\n<code class=\"CodeGreen\"><pre>HP-25 - ytox (y^x)\n\n2 ENTER 29 f y^x\n\n1. 00742 (WaitLoop) [2] pressed. Get:\n; M2=02000000000000 A= 02ffffffffffff B= 21000000000000 \" 2.          \"\n\n2. 00742 (WaitLoop) [ENTER] pressed. Get:\n; D= 02000000000000\n; M2=02000000000000 A= 0200ffffffffff B= 21000000000000 \" 2.00        \"\ns2 and s8 have been cleared. s8 is InputMode. s2 is AutoEnter.\n\n3. 00742 (WaitLoop) [2] pressed. Get:\n; D= 02000000000000\n; M2=02000000000000 A= 02ffffffffffff B= 21000000000000 \" 2.          \"\ns2 and s8 are set again\n\n4. 00742 (WaitLoop) [9] pressed. Get:\n; D= 02000000000000\n; M2=02900000000001 A= 029fffffffffff B= 20100000000000 \" 29.         \"\ns2 and s8 are still set. s13 is also set.\ny value is in D. x value (2.9x10^1) is in M2\n\n5. 00742 (WaitLoop) [f] pressed. Get:\n; D= 02000000000000\n; M2=02900000000001 A= 029fffffffffff B= 20100000000000 \" 29.         \"\nmain effect was to set s9 (f_Pressed)\nInputMode has ended (s8 cleared). s2 is still set. s13 was cleared also.\n\n6. 00742 (WaitLoop) [3] pressed ([f] [3] = y^x). Get:\n\n6a. Determine which function to run and save Lastx on the way\n\n00762 display off\n...\n00770 keys -&gt; rom address\n...\n00647 c + 1 -&gt; c[x]                      ; C= 00000000000003\n00650 return\n...\n00675 load constant 12                   ; C= 000000000000c3 P= 0\n; HexCode c3 is [3]\n...\n00701 if 0 = s 9 then goto 00616         ; if not f_Pressed (no, it is)\n00703 c - 1 -&gt; c[p]                      ; C= 000000000000b3\n00704 c - 1 -&gt; c[p]                      ; C= 000000000000a3\n; HexCode a3 is y^x ([f] [3])\n...\n01770 a + 1 -&gt; a[xs]                     ; A= 201000000001a3\n01771 a -&gt; rom address \/\/ 1a = 0001 1010 = 00 011 010 = 032 octal\n; A[2,1]=0x1a. Octal=032 In ROM 01400 so -&gt; 01432\n...\n02434 shift left a[x]                    ; A= 20100000000a30\n02435 a exchange c[xs]                   ; A= 20100000000130 ...\n; get x value and save in register 8 as Lastx\n02436 m2 -&gt; c                            ; C= 02900000000001\n02437 c -&gt; data register 8               ; save Lastx\n\n02440 0 -&gt; b[w]                          ; B= 00000000000000\n02441 p &lt;- 12                            ; P= 12\n02442 clear s                            ; S= ..23.5.........f\n02443 decimal\n02444 a -&gt; rom address\n; A[2,1]=0x13. Octal=023. In ROM 02400 so -&gt; 02423\n\n; (now running HexCode 0xa3)\n02423 if n\/c goto 02771\n\n6b. Calculate LN y\n\ndo_ytox:\n02771 stack -&gt; a                         ; A= 02000000000000 (y value, 2)\n...\n 03321 if a[s] # 0 then goto 01300\n 03323 a exchange c[m]                   ; A= 09900000000000 C= 06931471805999\n 03324 c -&gt; a[w]                         ; A= 06931471805999 &lt;---- this is LN(2)\n 03325 0 -&gt; b[w]\n 03326 p &lt;- 12\n 03327 return\n; 999 at end of C and A is EEX -1 so 6.931471805*10^-1 = 0.6931471805\n\n6c. Multiply by x \n\n03332 m2 -&gt; c                            ; C= 02900000000001 &lt;--- this is x for y^x\n03333 if n\/c goto 03114\n03114 jsb 03334 \/\/ MULTIPLY A=C*A; C=A\n ; In : A= 06931471805999 (0.69... ie 6.9...e-01) C=02900000000001\n ; Out: A= 02010126823001 C= 02010126823001 (=2.010126823e+01 =20.10126823)\n 03334 ...\n 03323 a exchange c[m]                   ; A= 09999999999900 C= 02010126823001\n 03324 c -&gt; a[w]                         ; A= 02010126823001 &lt;-- 29*LN(2)\n 03325 0 -&gt; b[w]                         ; B= 00000000000000\n 03326 p &lt;- 12\n 03327 return\n\n6d. Calculate e ^ (LN(2)*29) \/\/ note e ^ (LN(y) * x) = y^x\n\n03115 jsb 03162 ; return C= 02302585093000 P= 12\n03116 jsb 03101\n ; In:  A= 02010126823001 (LN(2)*29) C= 02302585093000\n ; Out: A= 00168058748600 B= 00000000000008 P= 11 C= 00500000000000\n 03274 return\n\n03117 jsb 03360 ; return if (P==11) { C=00693147180553; P=12 } \n03120 p &lt;- 11                            ; P= 11\n03121 jsb 03066\n ; In:  A= 00168058748600 B= 00000000000008 C= 00693147180553 P= 11\n ; Out: A= 00294293124894 B= 20000000000008 C= 00950000000000\n 03274 return\n\n03122 jsb 03144 ; return C=[0095]3101798055 P= 12 \/\/ keeps 1st 4 digits\n03123 p &lt;- 10                            ; P= 10\n03124 jsb 03066\n ; In:  A= 00294293124894 B= 20000000000008 C= 00953101798055 P= 10\n ; Out: A= 00083625854775 B= 32000000000008 C= 00995000000000 P= 9\n 03274 return\n\n03125 jsb 03200 ; return C=[009950]33085093 P= 12 \/\/ keeps 1st 6 digits\n03126 p &lt;- 9                             ; P= 9\n03127 jsb 03066\n ; In:  A= 00083625854775 B= 32000000000008 C= 00995033085093 P= 9\n ; Out: A= 00836258547750 B= 03200000000008 C= 00999500000000 P= 8\n 03274 return\n\n03130 jsb 03330 ; return C=[00999500]330850 P= 12 \/\/ keeps 1st 8 digits\n03131 p &lt;- 8                             ; P= 8\n03132 jsb 03066\n ; In:  A= 00836258547750 B= 03200000000008 C= 00999500330850 P= 8\n ; Out: A= 00366582830700 B= 80320000000008 C= 00999950000000 P= 7\n 03274 return\n\n03133 jsb 03066\n ; In:  A= 00366582830700 B= 80320000000008 C= 00999950000000 P= 7\n ; Out: A= 00665978307000 B= 38032000000008 C= 00999995000000 P= 6\n 03274 return\n\n03134 jsb 03066\n ; In:  A= 00665978307000 B= 38032000000008 C= 00999995000000 P= 6\n ; Out: A= 00659813070000 B= 63803200000008 C= 00999999500000 P= 5\n 03274 return\n\n03135 p &lt;- 6                             ; P= 6\n03136 0 -&gt; a[wp]                         ; A= 00659810000000\n03137 p &lt;- 13                            ; P= 13\n03140 b exchange c[w]                    ; B= 00999999500000 C= 63803200000008\n03141 a exchange c[w]                    ; A= 63803200000008 C= 00659810000000\n03142 load constant 6                    ; C= 60659810000000 P= 12\n03143 if n\/c goto 03224\n\n03224 a exchange c[w]                    ; A= 60659810000000 C= 63803200000008\n03225 a - 1 -&gt; a[s]                      ; A= 50659810000000\n03226 if n\/c goto 03216\n03216 a -&gt; b[w]                          ; B= 50659810000000\n03217 c - 1 -&gt; c[s]                      ; C= 53803200000008\n03220 if n\/c goto 03214\n\n03214 jsb 03373 ; \/\/ a= b + a[wp]\/(10^a[s])\n ; In:  A= 50659810000000 B= 50659810000000 (same) A[s]=5 P= 12\n ; Out: A= 50659816598100 B= 50659810000000 A[s]=5 P=12, B A[s] P used; not changed\n 03373 while (a[s]--, !CY)\n 03372   shift right a[wp]\n         ; A[s]=4 A[wp]=0065981000000\n         ; A[s]=3 A[wp]=0006598100000\n         ; A[s]=2 A[wp]=0000659810000\n         ; A[s]=1 A[wp]=0000065981000\n         ; A[s]=0 A[wp]=0000006598100\n         ; A[s]=9 CY\n 03375 0 -&gt; a[s]                         ; A= 00000006598100\n 03376 a + b -&gt; a[w]                     ; A= 50659816598100\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 51659816598100 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 51659816598100 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 43803200000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=5 P=12 A[wp]=1659816598100 (out= 1.00001*in [wp])\n 03376 a + b -&gt; a[w]                     ; A= 51659833196265\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 52659833196265 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 52659833196265 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 33803200000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=5 P=12 A[wp]=2659833196265\n 03376 a + b -&gt; a[w]                     ; A= 52659859794596\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 53659859794596 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 53659859794596 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 23803200000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=5 P=12 A[wp]=3659859794596\n 03376 a + b -&gt; a[w]                     ; A= 53659896393193\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 54659896393193 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 54659896393193 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 13803200000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=5 P=12 A[wp]=4659896393193\n 03376 a + b -&gt; a[w]                     ; A= 54659942992156\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 55659942992156 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 55659942992156 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 03803200000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=5 P=12 A[wp]= 5659942992156\n 03376 a + b -&gt; a[w]                     ; A= 55659999591585\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 56659999591585 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 56659999591585 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 93803200000008 CY \/\/ loop counter-- EXIT\n03220 if n\/c goto 03214\n\n; divide by 10\n03221 shift right a[wp]                  ; A= 50665999959158\n; shift next digit to loop counter in c[s]\n03222 a exchange c[w]                    ; A= 93803200000008 C= 50665999959158\n03223 shift left a[ms]                   ; A= 38032000000008\n03224 a exchange c[w]                    ; A= 50665999959158 C= 38032000000008\n; reduce power of 10 by 1 for r=1+r+r\/10^pwr\n03225 a - 1 -&gt; a[s]                      ; A= 40665999959158\n03226 if n\/c goto 03216\n\n03216 a -&gt; b[w]                          ; B= 40665999959158 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 28032000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=4 P=12 A[wp]= 0665999959158\n 03376 a + b -&gt; a[w]                     ; A= 40666066559153\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 41666066559153 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 41666066559153 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 18032000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=4 P=12 A[wp]= 1666066559153\n 03376 a + b -&gt; a[w]                     ; A= 41666233165808\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 42666233165808 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 42666233165808 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 08032000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=4 P=12 A[wp]= 2666233165808\n 03376 a + b -&gt; a[w]                     ; A= 42666499789124\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 43666499789124 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 43666499789124 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 98032000000008 CY \/\/ loop counter-- EXIT\n03220 if n\/c goto 03214\n\n; divide by 10\n03221 shift right a[wp]                  ; A= 40366649978912\n; shift next digit to loop counter in c[s]\n03222 a exchange c[w]                    ; A= 98032000000008 C= 40366649978912\n03223 shift left a[ms]                   ; A= 80320000000008\n03224 a exchange c[w]                    ; A= 40366649978912 C= 80320000000008\n; reduce power of 10 by 1 for r=1+r+r\/10^pwr\n03225 a - 1 -&gt; a[s]                      ; A= 30366649978912\n03226 if n\/c goto 03216\n\n03216 a -&gt; b[w]                          ; B= 30366649978912 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 70320000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=3 P=12 A[wp]= 0366649978912\n 03376 a + b -&gt; a[w]                     ; A= 30367016628890\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 31367016628890 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 31367016628890 \/\/ b= a\n03217 c - 1 -&gt; c[s]                      ; C= 60320000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=3 P=12 A[wp]= 1367016628890\n 03376 a + b -&gt; a[w]                     ; A= 31368383645518\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 32368383645518 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 32368383645518 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 50320000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=3 P=12 A[wp]= 2368383645518\n 03376 a + b -&gt; a[w]                     ; A= 32370752029163\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 33370752029163 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 33370752029163 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 40320000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=3 P=12 A[wp]= 3370752029163 \n 03376 a + b -&gt; a[w]                     ; A= 33374122781192\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 34374122781192 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 34374122781192 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 30320000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=3 P=12 A[wp]= 4374122781192\n 03376 a + b -&gt; a[w]                     ; A= 34378496903973\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 35378496903973 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 35378496903973 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 20320000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=3 P=12 A[wp]= 5378496903973\n 03376 a + b -&gt; a[w]                     ; A= 35383875400876\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 36383875400876 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 36383875400876 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 10320000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=3 P=12 A[wp]= 6383875400876\n 03376 a + b -&gt; a[w]                     ; A= 36390259276276\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 37390259276276 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 37390259276276 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 00320000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=3 P=12 A[wp]= 7390259276276\n 03376 a + b -&gt; a[w]                     ; A= 37397649535552\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 38397649535552 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 38397649535552 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 90320000000008 CY \/\/ loop counter--\n03220 if n\/c goto 03214\n\n; divide by 10\n03221 shift right a[wp]                  ; A= 30839764953555\n; shift next digit to loop counter in c[s]\n03222 a exchange c[w]                    ; A= 90320000000008 C= 30839764953555\n03223 shift left a[ms]                   ; A= 03200000000008\n03224 a exchange c[w]                    ; A= 30839764953555 C= 03200000000008\n; reduce power of 10 by 1 for r=1+r+r\/10^pwr\n03225 a - 1 -&gt; a[s]                      ; A= 20839764953555\n03226 if n\/c goto 03216\n\n03216 a -&gt; b[w]                          ; B= 20839764953555 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 93200000000008 CY \/\/ loop counter--\n03220 if n\/c goto 03214\n\n; divide by 10\n03221 shift right a[wp]                  ; A= 20083976495355\n; shift next digit to loop counter in c[s]\n03222 a exchange c[w]                    ; A= 93200000000008 C= 20083976495355\n03223 shift left a[ms]                   ; A= 32000000000008\n03224 a exchange c[w]                    ; A= 20083976495355 C= 32000000000008\n; reduce power of 10 by 1 for r=1+r+r\/10^pwr\n03225 a - 1 -&gt; a[s]                      ; A= 10083976495355\n03226 if n\/c goto 03216\n\n03216 a -&gt; b[w]                          ; B= 10083976495355 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 22000000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=1 P=12 A[wp]= 0083976495355\n 03376 a + b -&gt; a[w]                     ; A= 10092374144890\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 11092374144890 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 11092374144890 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 12000000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=1 P=12 A[wp]= 1092374144890\n 03376 a + b -&gt; a[w]                     ; A= 11201611559379\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 12201611559379 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 12201611559379 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 02000000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=1 P=12 A[wp]= 2201611559379\n 03376 a + b -&gt; a[w]                     ; A= 12421772715316\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 13421772715316 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 13421772715316 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 92000000000008 CY \/\/ loop counter--\n03220 if n\/c goto 03214\n\n; divide by 10\n03221 shift right a[wp]                  ; A= 10342177271531\n; shift next digit to loop counter in c[s]\n03222 a exchange c[w]                    ; A= 92000000000008 C= 10342177271531\n03223 shift left a[ms]                   ; A= 20000000000008\n03224 a exchange c[w]                    ; A= 10342177271531 C= 20000000000008\n; reduce power of 10 by 1 for r=1+r+r\/10^pwr\n03225 a - 1 -&gt; a[s]                      ; A= 00342177271531\n03226 if n\/c goto 03216\n\n03216 a -&gt; b[w]                          ; B= 00342177271531 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 10000000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=0 P=12 A[wp]= 0342177271531\n 03376 a + b -&gt; a[w]                     ; A= 00684354543062\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 01684354543062 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 01684354543062 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 00000000000008 \/\/ loop counter--\n03220 if n\/c goto 03214\n\n03214 ... ; A[s]=0 P=12 A[wp]= 1684354543062\n 03376 a + b -&gt; a[w]                     ; A= 03368709086124\n 03377 return\n\n03215 a + 1 -&gt; a[p]                      ; A= 04368709086124 \/\/ a= 1 + b + a[w]\/(10^a[s])\n03216 a -&gt; b[w]                          ; B= 04368709086124 \/\/ b=a\n03217 c - 1 -&gt; c[s]                      ; C= 90000000000008 CY \/\/ loop counter--\n03220 if n\/c goto 03214\n\n; divide by 10\n03221 shift right a[wp]                  ; A= 00436870908612\n; shift next digit to loop counter in c[s]\n03222 a exchange c[w]                    ; A= 90000000000008 C= 00436870908612\n03223 shift left a[ms]                   ; A= 00000000000008\n03224 a exchange c[w]                    ; A= 00436870908612 C= 00000000000008\n; reduce power of 10 by 1 for r=1+r+r\/10^pwr\n03225 a - 1 -&gt; a[s]                      ; A= 90436870908612 CY\n03226 if n\/c goto 03216\n; exit loop - for (a[s]=5; a[s]&gt;=0; a[s]--) \/\/ real a[s] is limited 0..9(or f) so break if a[s]--, CY\n\n03227 a exchange b[w]                    ; A= 04368709086124 B= 90436870908612\n03230 a + 1 -&gt; a[p]                      ; A= 05368709086124\n03231 jsb 03305\n ; sign to +ve, round to 10 digits, add in exponent\n ; In:  A=value (mantissa to 13 digits) C[2,1,0]=exponent. Uses B\n ; Out: A=value (rounded, mantissa and exponent). C=A B=0 P=12\n 03305 0 -&gt; a[s]\n 03306 p &lt;- 12\n 03307 0 -&gt; b[w]                         ; B= 00000000000000\n 03310 if a[p] # 0 then goto 01317       ; if mantissa starts with zero, shift left and adj exponent\n ; add last few digits (rounds if these are \"500\" or more)\n 03317 a -&gt; b[x]                         ; B= 00000000000124\n 03320 a + b -&gt; a[w]                     ; A= 05368709086248 \n 03321 if a[s] # 0 then goto 01300       ; if overflowed into sign\n 03323 a exchange c[m]                   ; A= 00000000000248 C= 05368709086008\n 03324 c -&gt; a[w]                         ; A= 05368709086008\n 03325 0 -&gt; b[w]                         ; B= 00000000000000\n 03326 p &lt;- 12\n 03327 return\n\n; At this point A= C= 05368709086008\n; This is e^(LN(2)*29) = ytox(2,29) = answer = +5.368709086e+08 = 536870908.6\n; 2^29 should be 536870912.0\n\n6e. Display\n\n03232 select rom 4\n02233 if n\/c goto 02340\n02340 m2 exch c                          ; C= 02900000000001 M2=05368709086008\n; 029...01 = what was in X previously (29)\n; 053...08 = HP-25 answer to 2 ENTER 29 y^x\n02341 1 -&gt; s 2                           ; AutoEnter\n02342 select rom 3\n01743 clear s                            ; S= ..23.5.........f\n01744 delayed rom 0\n01745 jsb 01705\n \/\/ get X value, check for 0, prob adjust if too small or too big (not shown here)\n 00305 m2 -&gt; c                           ; C= 05368709086008\n 00306 decimal\n 00307 p &lt;- 0                            ; P= 0\n 00310 if c[m] = 0 then goto 00272       ; no - mantissa isn't zero\n 00312 if c[xs] = 0 then goto 00321      ; yes - exponent is 0 or +ve\n 00321 return\n\n01746 m2 exch c\n01747 if p # 12 then goto 01752\n01752 if 0 = s 1 then goto 00247\n00247 display off\n00250 decimal\n00251 0 -&gt; b[w]\n00252 0 -&gt; a[w]                          ; A= 00000000000000\n00253 f exch a                           ; A= 00000000000001; \/\/ _f &lt;-&gt; A[0]\n00254 jsb 00341\n ; create display mask\n 00341 0 -&gt; a[w]                         ; A= 00000000000000\n 00342 a + 1 -&gt; a[s]                     ; A= 10000000000000\n 00343 shift right a[w]                  ; A= 01000000000000\n 00344 a + 1 -&gt; a[s]                     ; A= 11000000000000\n 00345 a + 1 -&gt; a[s]                     ; A= 21000000000000\n 00346 a exchange b[ms]                  ; A= 00000000000000 B= 21000000000000\n 00347 f -&gt; a ; \/\/ A[0]=_f\n 00350 p &lt;- 0\n 00351 a - 1 -&gt; a[p]                     ; A= 00000000000009 CY\n 00352 if n\/c goto 00233\n 00353 a exchange b[x]                   ; A= 00000000000000 B= 21000000000009\n 00354 0 -&gt; b[x]                         ; B= 21000000000000\n 00355 return\n\n00255 m1 -&gt; c                            ; C= 20000000000202\n00256 c -&gt; a[x]                          ; A= 00000000000202\n00257 0 -&gt; a[xs]                         ; A= 00000000000002 \/\/ 02=2 decimal places\n00260 delayed rom 2\n00261 if n\/c goto 00203\n01203 0 -&gt; s 14\n01204 c - 1 -&gt; c[xs]                     ; C= 20000000000102\n01205 if n\/c goto 01212\n01212 c - 1 -&gt; c[xs]                     ; C= 20000000000002\n01213 if n\/c goto 01305                  ; n\/c so FIX mode\n01305 m2 -&gt; c                            ; C= 05368709086008\n01306 a + c -&gt; a[x]                      ; A= 00000000000010\n01307 1 -&gt; s 13                          ; S= ..23.5.......d.f\n01310 jsb 01361\n \/\/ check if fits in FIX mode\n \/\/ will end with P=2 or P&gt;2\n \/\/ if P&gt;2 some digits on RHS will be blanked later (eg \" 1.00  \" not \" 1.00000...\")\n 01361 p &lt;- 12                           ; P= 12\n 01362 a + 1 -&gt; a[x]                     ; A= 00000000000011\n 01363 if n\/c goto 01356\n 01356 a - 1 -&gt; a[x]                     ; A= 00000000000010\n 01357 if n\/c goto 01353\n 01353 if p = 2 then goto 01364\n 01355 p - 1 -&gt; p                        ; P= 11\n 01356 a - 1 -&gt; a[x]                     ; A= 00000000000009\n 01357 if n\/c goto 01353\n 01353 ...                               ; P= 10 A= 00000000000008\n 01353 ...                               ; P= 9  A= 00000000000007\n 01353 ...                               ; P= 8  A= 00000000000006\n 01353 ...                               ; P= 7  A= 00000000000005\n 01353 ...                               ; P= 6  A= 00000000000004\n 01353 ...                               ; P= 5  A= 00000000000003\n 01353 ...                               ; P= 4  A= 00000000000002\n 01355 ...                               ; P= 3  A= 00000000000001\n 01353 ...                               ; P= 2  A= 00000000000000\n 01353 if p = 2 then goto 01364\n 01364 0 -&gt; a[w]\n 01365 c -&gt; a[wp]                        ; A= 00000000000008\n 01366 a + c -&gt; a[m]                     ; A= 05368709086008\n 01367 if n\/c goto 01376\n 01376 a -&gt; b[x]                         ; B= 21000000000008\n 01377 return\n\n01311 if a[xs] # 0 then goto 01327\n01313 jsb 01300  \/\/ set a[wp] to ff..f\n 01300 binary\n 01301 0 -&gt; a[wp]                        ; A= 05368709086000\n 01302 a - 1 -&gt; a[wp]                    ; A= 05368709086fff CY\n 01303 decimal\n 01304 return\n\n01314 a exchange b[x]                    ; A= 05368709086008 B= 21000000000fff\n01315 p &lt;- 1                             ; P= 1\n01316 if a[p] # 0 then goto 01345\n01320 a - 1 -&gt; a[x]                      ; A= 05368709086007\n01321 if n\/c goto 01325\n01325 shift right b[m]                   ; B= 20100000000fff\n01326 if n\/c goto 01320\n01320 ...                                ; A= 05368709086006 B= 20010000000fff\n01320 ...                                ; A= 05368709086005 B= 20001000000fff\n01320 ...                                ; A= 05368709086004 B= 20000100000fff\n01320 ...                                ; A= 05368709086003 B= 20000010000fff\n01320 ...                                ; A= 05368709086002 B= 20000001000fff\n01320 ...                                ; A= 05368709086001 B= 20000000100fff\n01320 ...                                ; A= 05368709086000 B= 20000000010fff\n01320 a - 1 -&gt; a[x]                      ; A= 05368709086999 CY\n01321 if n\/c goto 01325\n01322 0 -&gt; a[x]                          ; A= 05368709086000\n01323 a exchange b[x]                    ; A= 05368709086fff B= 20000000010000\n01324 if n\/c goto 01251\n01251 c -&gt; a[s]\n01252 clear s                            ; S= ..23.5.........f\n01253 0 -&gt; s 5\n01254 if 1 = s 5 then goto 00274\n00274 if 0 = s 1 then goto 00072\n00072 if 0 = s 3 then goto 01672\n00074 delayed rom 1\n00075 if n\/c goto 00165\n00565 0 -&gt; s 9\n00566 0 -&gt; s 10\n00567 if n\/c goto 00672\n00672 0 -&gt; s 14\n00673 jsb 00751\n 00751 display toggle\n ;\/\/\n ;\/\/ display \" 536870908.6\"\n ;\/\/\n 00752 jsb 00470\n  ; debounce (wait for key up)\n  00470 0 -&gt; s 15                        ; S= ..23.5..........\n  00471 p &lt;- 7                           ; P= 7\n  00472 p - 1 -&gt; p                       ; P= 6\n  00473 if p # 0 then goto 00472\n  00472 ...                              ; P= 5, 4, 3, 2, 1\n  00472 p - 1 -&gt; p                       ; P= 0\n  00473 if p # 0 then goto 00472\n  00475 if 1 = s 15 then goto 00470\n  00477 return\n\n 00753 cpu woodstock                     \/\/ about to enter main keypress loop \n 00754 if 1 = s 3 then goto 00742\n\nWaitLoop:\n 00742 0 -&gt; s 3                          \/\/ main keypress loop\n 00743 if 0 = s 3 then goto 01672\n 00745 if 0 = s 15 then goto 00742\n\nWaitLoop:\n 00742 ...\n 00742 ...\n<\/pre><\/code>\n\n\n\n<p>It basically does: LN(2), multiplies that by 29 and then does e^x of that.<\/p>\n\n\n\n<p>There are a few obvious solutions to making that better in later calculators: make sure LN(2) is more accurate, keep the precision of intermediate values as high as possible, make e^x more accurate, or maybe do the same process but with LOG10(2) and 10^x given that BCD (Binary Coded Decimal) is inherently base 10 anyway.<\/p>\n\n\n\n<p>Internally, as you&#8217;ll see above, most of the working uses 13 decimal places despite the mantissa only holding 10 digits. The 3 digits on the RHS for the exponent sign and value are pressed into service to improve precision. It&#8217;s quite impressive.<\/p>\n\n\n\n<p>As a first cut on comparisons, if I do LN(2) on a HP-25 I get &#8220;0.6931471805&#8221;. On a HP-67 I get &#8220;0.6931471806&#8221;. That might be the only reason for it being correct on later calculators and slightly low on earlier ones.<\/p>\n\n\n\n<p>I could do a more detailed comparison, and that would certainly be interesting, but the raw listing I started with for the HP-25 y^x was just over 3600 lines of execution. Simplifying that to just over 600 lines (above) took quite a bit of work. I have some reluctance to go through that again for the HP-67 version.<\/p>\n\n\n\n<p>Given the processors in the HP-25 and HP-67 are the same, a direct comparison of the microcode in both calculators will probably be an easier way forward. I have the addresses that apply for the HP-25. Given the way ROMs were reused in later calculators, or reused with updates, there&#8217;s a good chance the two microcode programs will match up except for a few small (but significant) updates. I&#8217;ll add another article if I get around to that comparison.<\/p>\n\n\n\n<p>If I do Math.Log(2) on a modern computer, it gives a double precision result of 0.693147180559945. So &#8220;&#8230;805&#8221; was close, but &#8220;&#8230;806&#8221; is the correct answer to 10 digits.<\/p>\n\n\n\n<p>When you think of the precision that was available at the time, through the careful use of a sliderule or the use of printed four figure math tables, the results from even the earlier calculators are stunning.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Problem I had someone ask me recently about &#8220;ytox&#8221; (y^x) on a HP-25. He&#8217;d done 2 ENTER 29 f y^x, got 536870908.6 back, and thought that was wrong. It is hardly surprising that he thought it was wrong &#8211; very few powers of two end up with &#8220;.6&#8221; on the end. 29 shouldn&#8217;t be &hellip; <a href=\"https:\/\/www.sydneysmith.com\/wordpress\/2486\/hp-25-ytox\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">HP-25 &#8211; YTOX<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,5,69],"tags":[6,32,34],"_links":{"self":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2486"}],"collection":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2486"}],"version-history":[{"count":12,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2486\/revisions"}],"predecessor-version":[{"id":2500,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2486\/revisions\/2500"}],"wp:attachment":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}