Post Reply 
HP35s bugs - program searching for errors
12-10-2015, 10:44 AM (This post was last modified: 12-15-2015 10:39 PM by wojtek.)
Post: #1
HP35s bugs - program searching for errors
Inspired by Paul Dale's HP35s bug list, especially by the bug 14, I have written a program which looks for other data giving wrong results in simple calculations.
In short, the program generates randomly 3 input data, stores them in A,B,C variables then calls twice a function with the same input data and displays both (different) results in x and y registers.
When both results are equal they are omitted, when are different program also stores them for later display and manual checking if necesssary.

Attached there is a table with examples of errors found. Some functions take only 1 or 2 input data from 3 values generated.

For 100 tries for every function usually a few sets (5 to 20 - very high percentage) of randomly generated input data giving wrong results were found.

Definitely the problem is with the "-" sign at the beginning of the functions.
Another conclusion was that adding ("+") operation (and probably other operations) performed just before calling the test function makes the function give correct results (so in one place in the code I had to use ISG instead of "+" to see the errors).

To those who wonder why I bother about it.
Unfortunately I bought this calculator (second hand, but it is still on HP menu!) and then looking for manuals I found this forum and Paul's bug list.
So before throwing the 35s away I tried to write a program at least, just for fun.

The code of the program is attached for those who would like to play with it
Wojtek Waszak

PS.
As I spotted an error in attachment with outcomes of the program (one of the input data to function #4 = -(A-B)xC was missing) I enclose here the corrected attachment:
Code:

================================================================================​====
 # |    FUNCTION    |   A, B, C    |    results   |     remarks
================================================================================​====
 0  -(A)             27.7231744712  -27.7231744712 correct
                                     27.723174471  bad sign, last digit missing
                     812.083201122  -812.083201122 correct
                                     812.08320112  bad sign, last digit missing
 1  -(A+1)           27.7231744712  -28.7231744712 correct
                                     27.723174471  the same as from -(A) function
                     812.083201122  -813.083201122 correct
                                     812.08320112  the same as from -(A) function
 2  -(Ax2)           469.905386026  -939.810772052 correct
                                     1879.6215441  wrong, = -2 x correct
 3  -(A+B)           311.009796507  -1071.47176962 correct
                     760.461973111   311.009796489 wrong, almost same as data in A
 4  -(A-B)xC          77.403198273   63876.0881102 correct
                     365.311711707  -14090656.4407 wrong
                     221.862449805
 5  -(A+B)/C         653.642816498  -375694.722782 correct
                     334.936336329   142649873.314 wrong
                     380.035044951
 6  -Ax(B-C)/C       139.48921215    60.3314372662 correct
                     491.736252651   129.777293812 wrong
                     866.521356475
 7  -(A+B)/(B-C)     72.6138248053  -1.59167078012 correct
                     677.915633404   3.252000122   wrong
                     206.380019642
 8  -A+BxC           465.408630753   476927.326742 correct
                     763.771068422   364262828.495 wrong
                     625.04689574
 9  -Ax(B-C)/(B+C)   821.083201122  -628.990515742 correct
                     247.259901524  -911.297127623 wrong
                     32.754761305
10  -A                   no errors found
11  -A+B                 no errors found
12  -A-B                 no errors found
13   (A-B)/C             no errors found
And the code of the program:
Code:
    
                @ HP-35s program for testing errors while computing formulae in ALG mode
                @ Wojtek Waszak (12.2015)

        @        ROUTINE C - input data in x register, of N.FS structure, where:
        @ N = # of iterations (0=default=100), F = function number from 0-9 range
        @ S - stop flag (0=default=stop after 1-st error, other value = search for more errors, <10)
        @ examples: x=0 means max 100 iterations, test function #0, stop after 1st error found
        @ x=200.49 means max 200 iterations, test function #4, find max 9 wrong/correct results' pairs

        @        ROUTINE D - no input data. Displays correct & wrong results from memory,
        @ stores input data in variables A,B,C and function number in V for verification by routine B

        @        ROUTINE B - no input data, repeats calculations for data displayed by routine D
        @ which had led to wrong results, based on data in variables A,B,C and V.
        @ Stores results of procedure D in t and z and verified results in registers x and y

        @        ROUTINES E,F,X - auxiliary test routines
        @ ROUTINE E - calculations with data in A,B,C and V and test function from Y routine
        @ ROUTINE F - calculations with data in A,B,C and arbitrary function coded in F006 line
        @ ROUTINE X - calculations with arbitrary data in A,B,C and V and test function in routine Y

        @        DATABASE RECORD STRUCTURE (6 fields) in indirect register pool:
        @ 1-1st result (correct), 2-2nd result, 3-number of test function, 4-A, 5-B, 6-C

        @        VARIABLES USED:
        @ A,B,C - random generated input parameters for test functions
        @ S - copy of start parameter from x register for routine C
        @ U - max number of iterations, V - test function number, W - max number of errors to be found
        @ X - counter of errors found, Y - iteration counter
        @ D,E,Z - working variables, T - working variable - copy of I variable

        @ ROUTINE C - input data in x register - SET x REGISTER BEFORE RUNNING THIS ROUTINE!
C001        LBL C                        @ main loop (in RPN mode)                (CHS=4997,  bytes=118)
        STO S                        @ save start parameters from x register in S variable
C003        XEQ Z025                @ fetch start parameters
        0
        STO Y                        @ clear iteration counter
        STO I                        @ clear index to store data
        SEED                        @ clear seed for radom generator
        SF 10                        @ set message flag
C009        XEQ Z010                @ call random test data generator
        XEQ Z048                @ call testing functions
        ISG Y                        @ increment iteration counter
        x<>y                        @ dummy instruction
        RCL Y
        RCL U
        -                        @ if x=0 all iterations done
        RCL X                        @ if X=0 assumed number of errors was found
        x
        X<>0?
        GTO C009                @ continue search if iteration# and error# less then assumed
        RCL W
        RCL X
        -
        STO Z
        x<>0?                        @ check assumed number of results found and stored
        ERRORS FOUND
        x=0?
        NO ERRORS                @ press R/S to see number of errors found
         CF 10                        @ clear message flag
        RCL Y                        @ number of iterations to y register
        RCL Z                        @ number of errors found to x register
        STOP                        @ press R/S to continue
C030        GTO C003                @ go on for another search with same initial settings

        @ ROUTINE D - no input data
        @ displays correct and wrong results found
        @ stores input data in A,B and C variables, stores number of test function in V
D001        LBL D
        SF 10                                                        @ (CHS=08A6,  bytes=132)
        0
        STO I                        @ clear index of data
        RCL W                        @ recall number of wrong results found
        RCL X
        -
        x=0?
        GTO D035
        STO Z                        @ set counter of wrong results (working variable)
D011        RCL I
        STO T                        @ save copy of I in T
        XEQ Z006                @ load to stack and display correct and wrong results
        STO D
        XEQ Z006
        STO E
        XEQ Z006
        STO V                        @ save test function number
        XEQ Z006                @ save input data to test functions which generated errors
        STO A
        XEQ Z006
        STO B
        XEQ Z006
        STO C
        0                        @ put marker onto the stack
        RCL V                        @ load test function number
        RCL D                        @ load to y register calculated wrong result
        RCL E                        @ load to x register calculated correct result
        STOP                        @ press R/S to continue
        DSE Z                        @ decrement data counter
        GTO D011
        END OF ERRORS
        PSE
        GTO D001                @ display again the same data set
D035        NO ERRORS
D036        GTO D035

        @ ROUTINE B - check procedure - no input data.
        @ loads data pointed by I and repeats calculations that have led to wrong results
B001        LBL B                                        @ (CHS=9556,  bytes=39)
        RCL T
        STO I
        XEQ Z006
        STO D
        XEQ Z006
        STO E
        XEQ Y001        @ calculate again based on input data in A,B,C and V variables
        XEQ Y001
        RCL E                @ restore correct and wrong results from repeated calculations
        RCL D
        STOP                @ display results
B013        GTO B001        @ repeat the check calculations


        @ ROUTINE X - check procedure for single case of A,B,C set giving wrong result
X001        LBL X                                                @ (CHS=CA88,  bytes=75)
        8
        STO V                @ set function number from 0-9 range from Y routine
        465.408630753
        STO A
        763.771068422
        STO B
        625.04689574
        STO C                @ with A,B,C as above function 8 gives 364262828.495 and 476927.326742
        XEQ Y001
        XEQ Y001
X012        STOP

E001        LBL E                @ check procedure taking input data from A,B,C,  (CHS=49C8,  bytes=15)
        XEQ Y001        @  and calling test function from set in routine Y
        XEQ Y001        @ number of test function is in V
        STOP
E005        GTO E001

F001        LBL F                @ check procedure for single case of A,B,C set,  (CHS=667F,  bytes=27)
        XEQ F006        @ and test functions not limited to set in routine Y
        XEQ F006
        STOP
        GTO F001
F006        -(A x 2)        @ example test function
F007        RTN

        @ SUBROUTINE - test functions for generating errors
Y001        LBL Y                                                        @ (CHS=9B7B,  bytes=252)
        RCL V                        @ load test function number from 0-9 range
        IP
Y004        STO Z
        ISG Z                        @ change function number to 1-10 range.
Y006        1                        @ dummy
                @ it would be more straightforward just add 1 before STO Z (in Y004)
                @ instead of ISG Z and 1 here but "+" makes all the functions
                @ in routine Y give only correct results!
        Rv
Y008        DSE Z                                        @ select test function
        GTO Y011
        GTO Y038
Y011        DSE Z
        GTO Y014
        GTO Y040
Y014        DSE Z
        GTO Y017
        GTO Y042
Y017        DSE Z
        GTO Y020
        GTO Y044
Y020        DSE Z
        GTO Y023
        GTO Y046
Y023        DSE Z
        GTO Y026
        GTO Y048
Y026        DSE Z
        GTO Y029
        GTO Y050
Y029        DSE Z
        GTO Y032
        GTO Y052
Y032        DSE Z
        GTO Y035
        GTO Y054
Y035        DSE Z
        GTO Y038
        GTO Y056
Y038        -(A)                                        @ function 0 (errors)
        RTN
Y040        -(A + 1)                                @ function 1 (errors)
        RTN
Y042        -(A x 2)                                @ function 2 (errors)
        RTN
Y044        -(A + B)                                @ function 3 (errors)
        RTN
Y046        -(A - B) x C                                @ function 4 (errors)
        RTN
Y048        -(A + B) / C                                @ function 5 (errors)
        RTN
Y050        -A x (B - C) / C                        @ function 6 (errors)
        RTN
Y052        -(A + B) / (B - C)                        @ function 7 (errors)
        RTN
Y054        -A + B x C                                @ function 8 (errors)
        RTN
Y056        -A x (B - C) / (B + C)                        @ function 9 (errors)
        RTN

        @ AUXILIARY SUBROUTINES
Z001        LBL Z                                                        @ (CHS=1FE7,  bytes=210)
        @ SUBROUTINE - store data from x register in indirect register pool
Z002        STO (I)
        ISG I
        RTN
        RTN

        @ SUBROUTINE - load data from indirect register pool to x register
Z006        RCL (I)
        ISG I
        RTN
        RTN

        @ SUBROUTINE - generate 3 random test data
Z010        1000                @ range of random data, can be 100 or other number here
        RANDOM
        x<>y
        x
        STO A                @ store data in A,B,C variables
        LASTx
        RANDOM
        x<>y
        x
        STO B
        LASTx
        RANDOM
        x
        STO C
Z024        RTN

        @ SUBROUTINE - set start parameters for C routine
Z025        100
        STO U                        @ set default max number of iterations
        RCL S                        @ restore x register from S variable
        IP
        x>0?
        STO U                        @ set max number of iterations from input data
        10
        RCL S
        FP
        x
        ENTER
        IP
        STO V                        @ save test function number from 0-9 range
        x<>y
        FP
        10
        x
        IP
        x=0?
        1
        STO W                        @ set max number of errors to be found
        STO X                        @ set counter of errors
        RTN

        @ SUBROUTINE - call test functions and store results
Z048        XEQ Y001                @ call testing function
        XEQ Y001                @ call again the same test function
        x=y?                        @ check if results are equal
        RTN                        @ return if equal
        x<>y
        XEQ Z002                @ store correct and wrong results        
        x<>y
        XEQ Z002
        RCL V
        XEQ Z002                @ store function number
        RCL A
        XEQ Z002                @ store data which led to errors
        RCL B
        XEQ Z002
        RCL C
        XEQ Z002
        DSE X                        @ decrement counter of errors found
        RTN                        @ return if X>0
Z066        RTN                        @ return if X<=0
PS2
Below there is a short description of the usage of the program. Have fun!
1.
Set the input parameter for the routine C in register x, for example:
0 = max 100 iterations, test function #0, stop after 1st error found
150.99 = max 150 iterations, test function #9, find max 9 errors
2.
Run the routine C (press XEQ C)
3.
Usually after a few seconds to about 1 minute message ERRORS FOUND is displayed.
3.
Then you can press R/S to see:
in y register - the number of iterations made
in x register - the number of errors found
4.
Then you can press R/S to repeat the same process (routine C) with the same input data as before, or
5.
You can run the procedure D (press XEQ D) to see outcomes of the selected test function in x and y registers (and input values in A,B,C variables, and function number in V). When you press R/S the next outcome is displayed.
6.
When the outcomes are displayed by routine D you can also run routine B (press XEQ B) to repeat the calculations with the same input data in A,B,C variables and compare the results (saved in x and y registers) with the ones calculated previously by routine C (in z and t registers). The values in x and y should be the same as values in z and t


Attached File(s)
.txt  mail-hp-museum-table.txt (Size: 2.64 KB / Downloads: 41)
.txt  hp35-errors-pgm.txt (Size: 7.9 KB / Downloads: 37)
Find all posts by this user
Quote this message in a reply
12-11-2015, 01:10 AM
Post: #2
RE: HP35s bugs
I've updated the bug list to reference this post.


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




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