HP-67 Program – Binary View by Class’67

Here’s a program from a contributor, Class’67. It does high precision base conversions. In his words:

Gss HP-67 Binary View

v0.07, 12/04/2015 by Class’67

Store these constants for D2B & B2D programs:

Reg. Value
A 2^32
B 2^16
C  
D  
E  
R04 .01 (adjust for best EXT operation)

CNV – Convert Z in base Y to base X. (Lbl A)
Binary form of decimals up to 2^16 can be viewed in R00 in Data screen.
Uses registers R00 – R03.

D2B – Decimal to binary conversion. (Lbl B)
Uses Data Screen to display binary expansion of decimal values.
ex. 33554499 = 2^25 + 67

QR – Quotient_Remainder function. (Lbl C)
Returns remainder in X and quotient in Y, Z, and T. ( Y, X > 0 ) Uses R09.

B2D – Binary to decimal conversion. (Lbl D)
Using the Data Screen view, input binary number in registers R05 – R07. Leading zeros are not required. Result is stored in R08. Uses registers R01 – R09, RA, RB, and R25.

DblD – Double input for D2B and CNV. (Lbl d)
This extends the input range to 2^48 – 1.

To use the D2B routine, Press [ d ],
At the prompt (1), input the left half of the number to convert. Press [R/S].
At the prompt (2), input the right half of the number to convert. Press [R/S].

ex. Convert 145678901456789 to binary.

Press [ d ].
(1) 1.4567890 E14 [R/S]
(2) 1456789 [R/S]
View Data screen.
05: 1000010001111110
06: 1000001100101100
07: 10111110010101
08: 12181

To use the CNV routine, first Set Flag 2.
Store ‘from base’ in R01.
Store ‘to base’ in R03.
Press [ d ].

ex. Convert 6767676767676767(octal) to decimal using the CNV routine.

Set Flag 2.
Store 8 in R01.
Store 10 in R03.
Press [ d ].
(1) 6.7676767 E15 [R/S]
(2) 67676767 [R/S]
View R00 in Data screen.
00: 245732122525175

EXT – Extracts the X’th digit from Y. (Lbl E)
(uses constant in R04)

Nbits – Calculates the number of bits in the binary expansion of X. (Lbl b)

( ) – D2B and DblD subroutine. (Lbl a)

CSR – Clear Summation Registers. (Lbl c)

( ) – Binary extraction subroutine. (Lbl e)

Note: Flag 1 will be left set by DblD. This will not affect operation of other routines.

Here’s the program in gss-hp67 format:

PROG
224
001: 31 25 11
002: 35 61 01
003: 33 03
004: 35 53
005: 33 01
006: 32 25 11
007: 35 71 01
008: 34 01
009: 41
010: 31 22 03
011: 31 22 00
012: 34 03
013: 31 22 03
014: 33 01
015: 34 03
016: 31 25 00
017: 33 02
018: 51
019: 35 52
020: 33 00
021: 31 25 01
022: 34 01
023: 35 52
024: 34 02
025: 81
026: 31 83
027: 31 51
028: 22 02
029: 35 53
030: 71
031: 35 53
032: 71
033: 33 61 00
034: 35 53
035: 22 01
036: 31 25 02
037: 34 00
038: 35 22
039: 31 25 03
040: 01
041: 51
042: 31 53
043: 31 83
044: 01
045: 61
046: 32 53
047: 35 22
048: 31 25 15
049: 32 53
050: 81
051: 32 83
052: 34 04
053: 61
054: 01
055: 00
056: 71
057: 31 83
058: 35 22
059: 31 25 12
060: 35 51 01
061: 33 08
062: 00
063: 33 05
064: 33 06
065: 33 07
066: 61
067: 02
068: 33 03
069: 44
070: 01
071: 00
072: 33 01
073: 44
074: 34 11
075: 32 81
076: 22 06
077: 31 22 13
078: 33 08
079: 35 52
080: 32 22 11
081: 33 05
082: 34 08
083: 41
084: 31 25 06
085: 44
086: 34 12
087: 32 81
088: 22 07
089: 31 22 13
090: 33 08
091: 35 54
092: 32 22 11
093: 33 06
094: 34 08
095: 41
096: 31 25 07
097: 44
098: 61
099: 32 22 11
100: 33 07
101: 35 61 01
102: 35 22
103: 31 25 13
104: 33 09
105: 35 52
106: 41
107: 41
108: 34 09
109: 81
110: 31 83
111: 41
112: 41
113: 35 53
114: 35 53
115: 34 09
116: 71
117: 51
118: 35 22
119: 32 25 13
120: 31 42
121: 00
122: 33 04
123: 33 05
124: 33 06
125: 33 07
126: 33 08
127: 33 09
128: 61
129: 31 42
130: 35 22
131: 32 25 12
132: 31 53
133: 02
134: 31 53
135: 81
136: 01
137: 61
138: 31 83
139: 35 22
140: 31 25 14
141: 35 61 01
142: 01
143: 09
144: 42
145: 33 02
146: 01
147: 06
148: 33 03
149: 00
150: 33 08
151: 34 05
152: 31 51
153: 22 06
154: 34 11
155: 33 09
156: 34 05
157: 32 22 15
158: 31 25 06
159: 34 06
160: 31 51
161: 22 07
162: 34 12
163: 33 09
164: 34 06
165: 32 22 15
166: 31 25 07
167: 01
168: 33 09
169: 34 07
170: 31 51
171: 22 09
172: 32 25 15
173: 33 01
174: 34 03
175: 35 33
176: 22 08
177: 35 33
178: 31 25 08
179: 34 09
180: 02
181: 35 34
182: 01
183: 51
184: 35 63
185: 71
186: 34 01
187: 35 34
188: 31 22 15
189: 71
190: 33 61 08
191: 31 33
192: 35 71 01
193: 22 09
194: 34 02
195: 35 24
196: 22 24
197: 31 25 09
198: 34 08
199: 35 22
200: 32 25 14
201: 01
202: 84
203: 33 08
204: 02
205: 84
206: 33 61 08
207: 34 08
208: 35 51 01
209: 35 71 02
210: 22 31 11
211: 22 12
212: 84
213: 84
214: 84
215: 84
216: 84
217: 84
218: 84
219: 84
220: 84
221: 84
222: 84
223: 84
224: 84
STATE
7
DEG
FIX
9
0
0
0
1
CARD
11
Title: Binary View
A: CNV
B: D2B
C: QR
D: B2D
E: EXT
a: 
b: Nbits
c: CSR
d: DblD
e: 
HELP
16
Gss HP-67 Binary View
 v0.07,  12/04/2015  by  Class'67

A)  Convert Z in base Y to base X.
B)  Decimal to binary converter.
b)  Number of bits in decimal X.
C)  Quotient_Remainder function.
c)  Clear summation registers.
D)  Binary to decimal converter.
d)  Double input for D2B and CNV.
E)  Extract the X'th digit from Y.
      
Notes:
Store  2^32 in Reg. RA 
Store  2^16 in Reg. RB
Store  .01 in Reg. R04
END
It's only fair to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUponDigg thisPin on PinterestEmail this to someone

3 thoughts on “HP-67 Program – Binary View by Class’67”

    1. Best I can see, from an earlier version of the program that I have, step 095 should be a 41 (ENTER). I’ve added that into the listing above.
      Send me an email (see the contact page) if that doesn’t solve it and I’ll work my way through the program to fix it for you.

  1. Note [d] stores the first part of the number in memory 8 and then uses STO+ to add the second part. This worked fine with my original HP-67 emulator which was only limited by the precision of the javascript in the browser it used (but could give slightly different results in different browsers).

    The real HP-67 stores numbers in the X,Y,Z and T registers, and in memories; as 14 binary coded decimal digits. Two of those are used for the mantissa sign and exponent sign and two more are used for the exponent. This is why the HP-67 can deal with numbers up to 10^99 and down to 10^-99, the two exponent digits. This leaves the HP-67 with its advertised 10 digit accuracy.

    If you store 1.4567890 E14 in a real HP-67 it appears as
    01456789000014
    The first 0 is the sign of the number and 0 is positive.
    The next 10 digits are the mantissa. Then there is the exponent sign and exponent.

    Doing a STO + with 1456789 tries to add
    01456789000000 to 01456789000014.

    The first step the calculator does is to shift one of the numbers until the exponents match so you get the following:
    00145678900001 + 01456789000014
    00014567890002 + 01456789000014

    00000000145007 + 01456789000014
    00000000014008 + 01456789000014
    00000000001009 + 01456789000014

    00000000000014 + 01456789000014

    The result is no change from what you started with. You can’t get more than 10 digit accuracy from a real HP-67 or from an emulator that matches that behaviour. (There are some exceptions where the microcode uses all 14 digits as an unsigned integer but the result always ends up as 10 digits, sign, exponent and exponent sign).

    This means you can’t use the [d] function on a real calculator, or close equivalent, to get more than 10 digit accuracy. Other techniques have to be used.

    Thank you to W Kunz for drawing my attention to the issue with [d].

Leave a Reply

Your email address will not be published. Required fields are marked *