Post Reply 
[TI-59/58] Percentage calculation.
05-23-2016, 01:46 AM
Post: #1
[TI-59/58] Percentage calculation.
000 76 LBL
001 11 A
002 82 HIR
003 03 03
004 82 HIR
005 11 11
006 82 HIR
007 43 43
008 82 HIR
009 13 13
010 55 /
011 01 1
012 00 0
013 00 0
014 54 )
015 91 R/S

Ex: 150 + 17 [A] 175.50
150 - 17 [A] 124.50

Systems Analyst
My passions (Facebook)
48G+/58C/85B/PC1500A
TH-78A/Samsung A51
Focal & All Basic´s
Visit this user's website Find all posts by this user
Quote this message in a reply
05-23-2016, 02:08 AM
Post: #2
RE: [TI-59/58] Percentage calculation.
Very nice use of the TI-58/59 Hierarchical registers!
Find all posts by this user
Quote this message in a reply
05-23-2016, 01:59 PM (This post was last modified: 05-23-2016 02:32 PM by Dieter.)
Post: #3
RE: [TI-59/58] Percentage calculation.
(05-23-2016 02:08 AM)Gene Wrote:  Very nice use of the TI-58/59 Hierarchical registers!

For those who never heard about the HIR commands and their use: take a look here.

So the HIR sequence in the program can be entered this way:

Code:
Enter this                 get that

key   code                 cmd   code
----------                 ----------
 STO   42                  HIR    82
 82    82                  03     03    ' store percentage in H3
  3    03                  HIR    82
 STO   42    delete all    11     11    ' recall base number from H1
 82    82    STO commands  HIR    82
  A    11    (code 42)     43     43    ' multiply by percentage in H3
 STO   42    and get =>    HIR    82
 82    82                  13     13    ' recall result from H3
 RCL   43
 82    82
  C    13

Hint: the program assumes there are no other pending operations. To be sure, press [CLR] or [=] before using this program.

Question to the TI experts: would it be possible to directly multiply percentage and base number within H2? And do the division by 100 also in H2 (by a HIR 62) in order to recall the final result from there? My idea is something like this:

Code:
150 [+] 17 [A]  =>  25,50
    [=]         => 175,50

Edit: I have absolutely no idea if this may work, but you get the idea (in this case still using the third hierarchy register).

Code:
000 76 LBL
001 11 A
002 82 HIR
003 03 03   ' store % in H3
004 82 HIR
005 11 11   ' recall base
006 82 HIR
007 43 43   ' multiply by %
008 93 .
009 00 0
010 01 1
011 82 HIR
012 43 43   ' multiply (base * %) by 0.01
013 83 HIR
014 13 13   ' recall result
015 82 HIR
016 02 02   ' store this as 2nd operand in H2
017 91 R/S

Please let me know if (and why) this will not work – and how to make it work. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
05-23-2016, 03:54 PM
Post: #4
RE: [TI-59/58] Percentage calculation.
Perfect :-)

Systems Analyst
My passions (Facebook)
48G+/58C/85B/PC1500A
TH-78A/Samsung A51
Focal & All Basic´s
Visit this user's website Find all posts by this user
Quote this message in a reply
05-23-2016, 11:18 PM
Post: #5
RE: [TI-59/58] Percentage calculation.
and more completely, the code provided by Dieter works perfectly and as described.

Very nice.
Find all posts by this user
Quote this message in a reply
05-24-2016, 12:54 AM (This post was last modified: 05-24-2016 01:07 AM by hp41cx.)
Post: #6
RE: [TI-59/58] Percentage calculation.
2 bytes (step) less ;-)

Code:
00 76 LBL
01 11 A
02 82 HIR
03 02 02
04 82 HIR
05 11 11 
06 82 HIR
07 42 42
08 93 .
09 00 0
10 01 1
11 82 HIR
12 42 42
13 82 HIR
14 12 12
15 91 R/S

Systems Analyst
My passions (Facebook)
48G+/58C/85B/PC1500A
TH-78A/Samsung A51
Focal & All Basic´s
Visit this user's website Find all posts by this user
Quote this message in a reply
05-24-2016, 09:48 AM (This post was last modified: 05-24-2016 09:58 AM by Dieter.)
Post: #7
RE: [TI-59/58] Percentage calculation.
(05-24-2016 12:54 AM)hp41cx Wrote:  2 bytes (step) less ;-)

Ah, great, so it really can be done directly within the second hierarchy register.
BTW, is the initial HIR 02 required?

The last time I got my hands on a TI58/59 was at school in the early Eighties. Can someone recommend a good PC emulator that behaves more or less exactly as the real thing?

Dieter
Find all posts by this user
Quote this message in a reply
05-24-2016, 10:20 AM
Post: #8
RE: [TI-59/58] Percentage calculation.
TI Emulator

Systems Analyst
My passions (Facebook)
48G+/58C/85B/PC1500A
TH-78A/Samsung A51
Focal & All Basic´s
Visit this user's website Find all posts by this user
Quote this message in a reply
05-24-2016, 12:24 PM (This post was last modified: 05-24-2016 12:34 PM by Dieter.)
Post: #9
RE: [TI-59/58] Percentage calculation.
(05-24-2016 12:54 AM)hp41cx Wrote:  
Code:
.. .. ...
08 93 .
09 00 0
10 01 1
11 82 HIR
12 42 42
.. .. ...

I just tried this on Hrastprogrammer's TI59E emulator that is said to run the original microcode. Here the .01 HIR 42 sequence does not work (after the HIR command the display switches from .01 to 100), but 100 HIR 62 does it.

So this is the final version:

Code:
000  76 LBL
001  11  A
002  82 HIR
003  02  02
004  82 HIR
005  11  11
006  82 HIR
007  42  42
008  01  1
009  00  0
010  00  0
011  82 HIR
012  62  62
013  82 HIR
014  12  12
015  92 RTN

BTW, answering my own question: obviously the last operand (the one in the display) is not automatically stored in HIR, so the initial HIR 02 is required.

Dieter
Find all posts by this user
Quote this message in a reply
05-30-2016, 06:05 PM
Post: #10
RE: [TI-59/58] Percentage calculation.
hp41cx,
thank you to report my emulator.

Dieter,
I recommend you, certainly, my emulator but you can also see the links to other emulators in the menu "Emulators" on my website ti58c.mooo.com .
For the HIR feature, my emulator allows to use it, but I do not use these registers in the basic operations (H0... H9 registers are independent of standard operations.) but the HIR command is usable via the calculator keyboard.
(Remember that my emulator offers more than 100 programs and more than 200 skins!)
Enjoy with TI emulator and find again the pleasure to use an old but great technology of the twentieth century.

http://pierre.phweb.me
http://ti58c.phweb.me
"No! Do or Do not. There is no try!" [Master Yoda]
Visit this user's website Find all posts by this user
Quote this message in a reply
06-01-2016, 07:45 AM
Post: #11
RE: [TI-59/58] Percentage calculation.
(05-24-2016 12:24 PM)Dieter Wrote:  
(05-24-2016 12:54 AM)hp41cx Wrote:  
Code:
.. .. ...
08 93 .
09 00 0
10 01 1
11 82 HIR
12 42 42
.. .. ...

I just tried this on Hrastprogrammer's TI59E emulator that is said to run the original microcode. Here the .01 HIR 42 sequence does not work (after the HIR command the display switches from .01 to 100), but 100 HIR 62 does it.

Although that .01 HIR 42 result looked like bug at first, I checked it on all TI-59 emulators I have access to, and they all produced the same result:

(1) My TI-59E for HP-48SX/48G+/48GX/49G/49G+/50G

(2) My TI-59E for Windows

(3) TI-59 emulator by Hynek Sladky (Windows console version)

(4) TI-59 emulator by Willibald Meyer (Windows version)

I believe the real TI-59 should behave the same, but I don't have a working one to check it ...

http://www.hrastprogrammer.com/hrastwerk/
http://hrastprogrammer.bandcamp.com/
Visit this user's website Find all posts by this user
Quote this message in a reply
06-01-2016, 10:52 AM
Post: #12
RE: [TI-59/58] Percentage calculation.
08 93 .
09 00 0
10 01 1
11 82 HIR
12 42 42

OK!
In a real TI-58C.

Systems Analyst
My passions (Facebook)
48G+/58C/85B/PC1500A
TH-78A/Samsung A51
Focal & All Basic´s
Visit this user's website Find all posts by this user
Quote this message in a reply
06-01-2016, 12:17 PM (This post was last modified: 06-02-2016 12:08 PM by Dieter.)
Post: #13
RE: [TI-59/58] Percentage calculation.
(06-01-2016 10:52 AM)hp41cx Wrote:  08 93 .
09 00 0
10 01 1
11 82 HIR
12 42 42

OK!
In a real TI-58C.

Very interesting. OK, the 58C has a ROM that's different from the 59. Since it appeared quite a while after the 58/59 were released this could be a kind of bugfix.

I did some more tests on TI59.EXE for Windows, using a short test program:

Code:
000  76 LBL
001  11  A
002  32 x<>t
003  01  1
004  82 HIR
005  01  01
006  32 x<>t
007  82 HIR
008  41  41
009  82 HIR
010  11  11
011  92 RTN

This loads the first HIR with 1 and multiplies this by the input before the register is finally recalled. So if everything works as expected the output should match the input.

Here is what I got:

Code:
input          output
---------------------
1       [A]         1
3       [A]         3
4,5     [A]       4,5
635,7   [A]     635,7
-17     [A]       -17

0,1     [A]        10
0,0123  [A]       123
0,00005 [A]    500000

So in numbers with negative exponent the sign of the latter is ignored. 0,1 = 1E-1 becomes 1E+1 = 10, and 5E-5 becomes 5E+5 = 500000.

But wait, it's getting even better:

Code:
input                   output
------------------------------
100000      [x^2]        1  10
            [1/x]  ,0000000001
       [÷] 10 [=]        1 -11
            [A]          1 -11
            [x^2]        1 -22
            [A]          1 -22

So very small values are handled correctly while for larger ones the sign of the exponent is ignored. Further tests showed that the limit seems to be 5E-11. See below.

Now let's enter values below 1 in EE mode.

Code:
input          output
----------------------
1 EE -1  [A]     1 -01
5 EE -5  [A]     5 -05
3 EE -99 [A]     3 -99

So in EE mode everything sees to work fine!

Now let's try ENG mode

Code:
2nd ENG

input          output
---------------------
123     [A]   123  00
1234    [A] 1,234  03
0,123   [A]   123 -03
0,00005 [A]    50 -06

INV ENG       0,00005

So ENG mode seems to work fine, too.

All in all it turned out that the problem with the ingored exponent sign only occured if the number was displayed without an exponent. That's why 5E-11 still shows the problem (display is rounded to ,0000000001) while 4,99E-11 has no problems (display is 4,99 -11). Is this strange, or what?

BTW, I just discovered some other odd behaviour, not sure whether it's the same on a real hardware 58/59/58C:

Code:

input         display
---------------------
123 EE 15 =   1,23 17
    EE 5      1,23 75
       9      1,23 59
       =      1,23 59
    EE 0      1,23 90
       3      1,23 03
       =                    // this was originally missing
INV EE        1230

So even after a number has been entered or calculated, pressing EE seems to re-edit the exponent.

Dieter
Find all posts by this user
Quote this message in a reply
06-01-2016, 04:23 PM
Post: #14
RE: [TI-59/58] Percentage calculation.
Well, I was finally able to revive my ancient TI-59 by using an stabilized power supply and that .01 HIR 42 thing behaves exactly like on the above emulators. Using 100 HIR 62 gives the correct result.

http://www.hrastprogrammer.com/hrastwerk/
http://hrastprogrammer.bandcamp.com/
Visit this user's website Find all posts by this user
Quote this message in a reply
06-01-2016, 04:33 PM
Post: #15
RE: [TI-59/58] Percentage calculation.
And I can also confirm that all other calculations from this thread are the same on the real TI-59 ...

http://www.hrastprogrammer.com/hrastwerk/
http://hrastprogrammer.bandcamp.com/
Visit this user's website Find all posts by this user
Quote this message in a reply
06-01-2016, 06:30 PM
Post: #16
RE: [TI-59/58] Percentage calculation.
So it appears the TI-58C acts differently. Very curious!
Find all posts by this user
Quote this message in a reply
06-02-2016, 01:13 AM
Post: #17
RE: [TI-59/58] Percentage calculation.
Code:
input         display
---------------------
123 EE 15 =   1,23 17
    EE 5      1,23 75
       9      1,23 59
       =      1,23 59
    EE 0      1,23 90
       3      1,23 03
INV EE        1.23 03 <= TI-58C

Systems Analyst
My passions (Facebook)
48G+/58C/85B/PC1500A
TH-78A/Samsung A51
Focal & All Basic´s
Visit this user's website Find all posts by this user
Quote this message in a reply
06-02-2016, 03:57 AM
Post: #18
RE: [TI-59/58] Percentage calculation.
(06-02-2016 01:13 AM)hp41cx Wrote:  
Code:
input         display
---------------------
123 EE 15 =   1,23 17
    EE 5      1,23 75
       9      1,23 59
       =      1,23 59
    EE 0      1,23 90
       3      1,23 03
INV EE        1.23 03 <= TI-58C

This is the same as on the real TI-59 and emulators because the original sequence is missing = before INV EE.

http://www.hrastprogrammer.com/hrastwerk/
http://hrastprogrammer.bandcamp.com/
Visit this user's website Find all posts by this user
Quote this message in a reply
06-02-2016, 05:05 AM (This post was last modified: 06-02-2016 06:27 AM by HrastProgrammer.)
Post: #19
RE: [TI-59/58] Percentage calculation.
(06-01-2016 06:30 PM)Gene Wrote:  So it appears the TI-58C acts differently. Very curious!

Yes. I am now trying to extract a TI-58C ROM dump Smile

http://www.hrastprogrammer.com/hrastwerk/
http://hrastprogrammer.bandcamp.com/
Visit this user's website Find all posts by this user
Quote this message in a reply
06-02-2016, 12:07 PM
Post: #20
RE: [TI-59/58] Percentage calculation.
(06-02-2016 03:57 AM)HrastProgrammer Wrote:  This is the same as on the real TI-59 and emulators because the original sequence is missing = before INV EE.

Right, a [=] was missing. Either before or after the [INV] [EE].

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 




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