Post Reply 
HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
06-25-2014, 09:41 PM (This post was last modified: 06-25-2014 10:53 PM by Thomas Klemm.)
Post: #1
HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
Inspired by a recent thread I started using the HP-80 emulator but had troubles with the calendar functions. Whatever I entered the result was always a blinking 9.999999999 99.

So I started to debug the DATE function and noticed a fishy line 6201 in the following block of code:
Code:
1708   L06175:  .1....11..                          4 -> p
1709   L06176:  1...11..1.                          b exchange c[wp]
1710   L06177:  1..1..111.                      dd2:    shift right c[w]
1711   L06200:  .....111..                          p - 1 -> p
1712   L06201:  111.1.11..                          if p # 14
1713   L06202:  .111111111  -> L063177                   then go to dd2
1714   L06203:  .11.1.1.1.                          if c[x] = 0

The loop was executed once too often and thus the month (here 6) was shifted over the right end of register c and thus got lost:
Code:
1712   L06201:  111.1.11..                              if p # 14            
pc=06202  p=15  stat: 0 2 3 7 9                                              
a: 00000030680000                                                            
b: 00000000023099                                                            
c: 00000000030006                                                            
m: 07000000000000                                                            
1713   L06202:  .111111111  -> L063177                       then go to dd2  
pc=06177  p=15  stat: 0 2 3 7 9                                              
a: 00000030680000                                                            
b: 00000000023099                                                            
c: 00000000030006                                                            
m: 07000000000000                                                            
1710   L06177:  1..1..111.                      dd2:    shift right c[w]     
pc=06200  p=15  stat: 0 2 3 7 9                                              
a: 00000030680000                                                            
b: 00000000023099                                                            
c: 00000000003000                                                            
m: 07000000000000                                                            
1711   L06200:  .....111..                              p - 1 -> p           
pc=06201  p=14  stat: 0 2 3 7 9                                              
a: 00000030680000                                                            
b: 00000000023099                                                            
c: 00000000003000                                                            
m: 07000000000000                                                            
1712   L06201:  111.1.11..                              if p # 14            
pc=06202  p=14  stat: 0 2 3 7 9                                              
a: 00000030680000                                                            
b: 00000000023099                                                            
c: 00000000003000                                                            
m: 07000000000000                                                            
1713   L06202:  .111111111  -> L063177                       then go to dd2  
pc=06203  p=14  stat: 0 2 3 7 9                                              
a: 00000030680000                                                            
b: 00000000023099                                                            
c: 00000000003000                                                            
m: 07000000000000                                                            
1714   L06203:  .11.1.1.1.                              if c[x] = 0          
pc=06204  p=14  stat: 0 2 3 7 9                                              
a: 00000030680000                                                            
b: 00000000023099                                                            
c: 00000000003000                                                            
m: 07000000000000

To be sure I had a look at the original US-patent 3863060 and noticed a special case at exactly that line:
[Image: hp-80-bug.png]
The leading L is missing in line number 6201. And while the texts agree (if p # 14 | IF P # 14) the bit pattern don't: 111.1.11.. | 11111.11... And of course [if p # 15] makes more sense.

Thus I patched these two files in my installation:
/usr/local/lib/nonpareil diff 80.lst.orig 80.lst
Code:
2074c2074
< 1712   L06201:  111.1.11..                            if p # 14
---
> 1712   L06201:  11111.11..                            if p # 15
/usr/local/lib/nonpareil diff 80.obj.orig 80.obj
Code:
1666c1666
< 3201:1654
---
> 3201:1754

And, lo and behold, the bug in the calendar functions was fixed.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
06-25-2014, 10:19 PM
Post: #2
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
(06-25-2014 09:41 PM)Thomas Klemm Wrote:  Inspired by a recent thread I started using the HP-80 emulator but had troubles with the calendar functions. Whatever I entered the result was always a blinking 9.999999999 99.

Thomas - While checking out my new HP-80, I had similar trouble using the DATE function, getting blinking 9.999999999 99 and somtimes even 0.000999999 99, though my conclusion was that I simply didn't know how to use this particular function on such an old machine, assuming usage had changed over time. I must admit, it absolutely did not occur to me to disassemble the ROM and patch the code. Nope, not even for an instant.

A quick look at the UG today on the Museum DVD reveals that, e.g. to calculate days between dates, one does DATE1, [SAVE], DATE2, [DAY], and this works correctly after all. Not sure about the issue you encountered, but my conclusion is it's easier to RTFM than to debug the OS. Of course, you may have had more fun than I did.

In any case, thanks for the interesting answer to my question about bugs in the HP-80!

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
06-25-2014, 10:49 PM
Post: #3
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
Not sure whether this has become clear: I assume the bug exists only in Eric's emulator (or ROM-dump, to be precise) but not in the real calculator. This happened probably when scanning the code printed in the patent. The aforementioned line is ambiguous already there.

But you tell me that you have problems with the real calculator?
What happens when you calculate something like:

6.252014 [SAVE] 123 [DATE]

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
06-25-2014, 11:21 PM (This post was last modified: 06-25-2014 11:23 PM by bshoring.)
Post: #4
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
Thomas, the Nonpariel bug you found is probably responsible for the calendar bug on RPN-80 by Maciej Bartosiak. He stopped offering his emulators (for iPhone) about a year ago. When I asked about the calendar bug he said he got the microcode from Nonpariel.

I don't suppose there is a way to fix my iOS app.

Bob
Find all posts by this user
Quote this message in a reply
06-25-2014, 11:51 PM
Post: #5
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
(06-25-2014 11:21 PM)bshoring Wrote:  Thomas, the Nonpariel bug you found is probably responsible for the calendar bug on RPN-80 by Maciej Bartosiak.
Can confirm this: I used its debugger (double touch the display) to track down the issue.

Quote:I don't suppose there is a way to fix my iOS app.
Unfortunately, that's probably true.

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
06-26-2014, 02:53 AM
Post: #6
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
(06-25-2014 10:49 PM)Thomas Klemm Wrote:  Not sure whether this has become clear: I assume the bug exists only in Eric's emulator (or ROM-dump, to be precise) but not in the real calculator. This happened probably when scanning the code printed in the patent. The aforementioned line is ambiguous already there.

But you tell me that you have problems with the real calculator?
What happens when you calculate something like:

6.252014 [SAVE] 123 [DATE]

Kind regards
Thomas

Yes, I did misunderstand, I thought you were implying a bug in the HP80.

Anyhow, an actual HP80 processes that and returns 10.26, which checks out with result from a 41CX (date format is MM.DDYYYY).

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
06-26-2014, 07:52 AM
Post: #7
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
(06-25-2014 09:41 PM)Thomas Klemm Wrote:  ... To be sure I had a look at the original US-patent 3863060 and noticed a special case at exactly that line:
[Image: hp-80-bug.png]
The leading L is missing in line number 6201. And while the texts agree (if p # 14 | IF P # 14) the bit pattern don't: 111.1.11.. | 11111.11... And of course [if p # 15] makes more sense.

Thus I patched these two files in my installation:
/usr/local/lib/nonpareil diff 80.lst.orig 80.lst
Code:
2074c2074
< 1712   L06201:  111.1.11..                            if p # 14
---
> 1712   L06201:  11111.11..                            if p # 15
/usr/local/lib/nonpareil diff 80.obj.orig 80.obj
Code:
1666c1666
< 3201:1654
---
> 3201:1754

And, lo and behold, the bug in the calendar functions was fixed.

Cheers
Thomas

Very nice archeo-software debugging!

What is surprising is the coincidence of the missing L letter, and the mismatch between the bit pattern and assembler symbolic instruction in the original patent.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
06-26-2014, 10:55 AM
Post: #8
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
(06-26-2014 07:52 AM)J-F Garnier Wrote:  What is surprising is the coincidence of the missing L letter, and the mismatch between the bit pattern and assembler symbolic instruction in the original patent.

Somehow it reminded me of the movie Brazil:
Quote:an error caused by a fly getting jammed in a printer
Find all posts by this user
Quote this message in a reply
06-28-2014, 07:04 PM
Post: #9
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
(06-25-2014 11:21 PM)bshoring Wrote:  I don't suppose there is a way to fix my iOS app.

Possibly. If Maciej included the ROM as a file in the Documents subdirectory of the app, then it may be possible to "upgrade" it using iExplorer (was iPhone Explorer).

If the ROM was "included" in the binary or the ROM file is in one of the read-only subdirectories of the .app directory, well then, there is little you can do but request the source from Maciej, get a developers license, and build it yourself.
Find all posts by this user
Quote this message in a reply
06-28-2014, 07:26 PM
Post: #10
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
Thanks Egan. Sounds like it is beyond my technical abilities.

Bob
Find all posts by this user
Quote this message in a reply
06-30-2014, 09:11 PM (This post was last modified: 06-30-2014 09:38 PM by Egan Ford.)
Post: #11
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
(06-28-2014 07:26 PM)bshoring Wrote:  Thanks Egan. Sounds like it is beyond my technical abilities.

It's all point and click:

1. Install iExplorer
2. Quit iTunes
3. Connect iDevice
4. Run iExplorer and browse apps until you find RPN-80 and open up the folders

There's an example here:

http://retrocompute.org/2011/02/26/final...your-ipad/
Find all posts by this user
Quote this message in a reply
06-30-2014, 09:28 PM
Post: #12
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
(06-30-2014 09:11 PM)Egan Ford Wrote:  What is the name of the app in the app store? I cannot find it.

Quote:We're sorry, "rpn–80" has been removed from the App Store.

Known issues:
Date arithmetic operations don't work.

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
06-30-2014, 09:42 PM (This post was last modified: 06-30-2014 09:42 PM by Egan Ford.)
Post: #13
RE: HP-80 Nonpareil Emulator: fixed a bug in the calendar functions
[quote='Thomas Klemm' pid='15654' dateline='1404163728']
Quote:We're sorry, "rpn–80" has been removed from the App Store.

There's another RPN-80 there now from AmeloConsulting. They may have the same bug.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: