Copyleft (C) 2003 Glen Kilpatrick
Distributed under GNU General Public License
This program is supplied without representation or warranty of any kind. The author and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.
The HP-20S is wonderful for offering base conversions to and from HEXadecimal, OCTal, and BINary. To quote from HP-20S Scientific Calculator Owner's Manual (Edition 6, Part Number 00020-90001, pages 47 and 49):
Representation of Numbers
The internal representation of a number does not change when a number is converted to another base. When a number is converted from its decimal value to a different base, the integer part of the number is represented as a 36-bit binary number.
In Hexadecimal, Octal, and Binary modes, numbers are displayed in 2's complement format. The left-most bit of the binary representation of a number is the sign bit. It is set to 1 for negative numbers.
Range of Hexadecimal, Octal, and Binary Numbers
The 36-bit word size determines the range of numbers that can be represented in hexadecimal, octal, or binary base, and the range of decimal numbers that can be converted to other bases.
Arithmetic Operations
All functions are active in all bases (except non-shifted functions on the top row keys).
All arithmetic operations in hexadecimal, octal, and binary base use 2's complement arithmetic. When a division produces a remainder, only the integer portion of the number is retained.
Alas, Boolean Logic isn't one of these. Thus I wrote these back in Autumn of 1994 for my own use.
For AND / OR / XOR select base (HEXadecimal or OCTal; note the logic may be fine for BINary, but the programmatic uses of the number "2" preclude it as a base here), #1 INPUT #2, XEQ A / B / C; for NOT (1's complement), XEQ D or \R/S; for NOT (2's complement) \+/-.
HEXadecimal: 1FFFF XEQ D → FFFFE0000 (1's complement) FFFFE0000 \R/S → 1FFFF (returns original number) 1FFFF \+/- → FFFFE0001 (2's complement) FFFFE0001 \+/- → 1FFFF (likewise) dEAd INPUT bEEF XEQ A → logical AND yields 9EAd dEAd INPUT bEEF XEQ B → logical OR, FEEF dEAd INPUT bEEF XEQ C → logical XOR, 6042 6042 INPUT dEAd XEQ C → logical XOR, bEEF (reverses prev. XOR) OCTal: 123456701234 XEQ D → 654321076543 (1's complement) 654321076543 \R/S → 123456701234 (returns original number) 123456701234 \+/- → 654321076544 (2's complement) 654321076544 \+/- → 123456701234 (likewise) 157255 INPUT 137357 XEQ A → logical AND yields 117255 157255 INPUT 137357 XEQ B → logical OR, 177357 157255 INPUT 137357 XEQ C → logical XOR, 60102 60102 INPUT 157255 XEQ C → logical XOR, 137357 (reverses prev. XOR)
Enter ... See CLPRGM 00- LBL D 01- 61 41 d ( 02- 33 +/- 03- 32 - 04- - 1 05- 1 ) 06- 34 RTN 07- 61 26 LBL A 08- 61 41 A XEQ 0 09- 41 0 LBL 4 10- 61 41 4 RCL 2 11- 22 2 X=0? 12- 61 43 GTO 3 13- 51 41 3 XEQ 8 14- 41 8 XEQ 9 15- 41 9 GTO 4 16- 51 41 4 LBL B 17- 61 41 b XEQ 0 18- 41 0 LBL 5 19- 61 41 5 RCL 2 20- 22 2 X=0? 21- 61 43 GTO 3 22- 51 41 3 XEQ 8 23- 41 8 SWAP 24- 51 31 XEQ 9 25- 41 9 GTO 5 26- 51 41 5 LBL C 27- 61 41 C XEQ 0 28- 41 0 LBL 6 29- 61 41 6 RCL 2 30- 22 2 X=0? 31- 61 43 GTO 3 32- 51 41 3 XEQ 8 33- 41 8 X≤Y? 34- 61 42 GTO 7 35- 51 41 7 1 36- 1 XEQ 9 37- 41 9 GTO 6 38- 51 41 6 LBL 7 39- 61 41 7 0 40- 0 XEQ 9 41- 41 9 GTO 6 42- 51 41 6 LBL 0 43- 61 41 0 X≤Y? 44- 61 42 SWAP 45- 51 31 STO 1 46- 21 1 SWAP 47- 51 31 STO 2 48- 21 2 1 49- 1 STO 0 50- 21 0 C 51- 71 STO 3 52- 21 3 RTN 53- 61 26 LBL 1 54- 61 41 1 ( 55- 33 RCL 1 56- 22 1 - 57- 65 ( 58- 33 ÷ 59- 45 2 60- 2 × 61- 55 STO 1 62- 21 1 2 63- 2 ) 64- 34 ) 65- 34 RTN 66- 61 26 LBL 2 67- 61 41 2 ( 68- 33 RCL 2 69- 22 2 - 70- 65 ( 71- 33 ÷ 72- 45 2 73- 2 × 74- 55 STO 2 75- 21 2 2 76- 2 ) 77- 34 ) 78- 34 RTN 79- 61 26 LBL 3 80- 61 41 3 C 81- 71 STO 0 82- 21 0 RCL 3 83- 22 3 RTN 84- 61 26 LBL 8 85- 61 41 8 XEQ 1 86- 41 1 INPUT 87- 31 XEQ 2 88- 41 2 X≤Y? 89- 61 42 SWAP 90- 51 31 RTN 91- 61 26 LBL 9 92- 61 41 9 ( 93- 33 × 94- 55 RCL 0 95- 22 0 ) 96- 34 STO+3 97- 21 75 3 2 98- 2 STO×0 99- 21 55 0 SHOW 636F
Registers 0 through 3 (the other six of ten registers, 4 through 9, are preserved unmodified for use in statistical calculations); LaBeLs A through D (E & F unused) and 0 through 9; program lines 00 through 99 (all program space).
A grateful thanks go to Christof for the loan of an HP-20S (otherwise my photocopy of some hand-scrawled 3X5 index cards from 1993-4 might never have made sense).
Go back to the software library
Go back to the main exhibit hall