The first programmable pocket calculator: the HP-45’s functions and stack, a hundred steps of program memory with fifteen labels, four relational tests, two flags and a loop counter, three prefix keys, five keys you define yourself, and a magnetic card reader that makes a program permanent. This sheet is the keyboard drawn with every key’s program code, a guide from the stack to the two-step skip, an index of every key and behaviour with its handbook page, and a thirteen-step loop shown as the display shows it. The prefixes are written f f-1 g as the keys are.
Source: HP-65 Owner’s Handbook, HP 00065-90200 (Hewlett-Packard, Cupertino, January 1974) and the HP-65 Quick Reference Guide, 00065-90203; program codes checked against the Standard Pac listings. Page numbers are the handbook’s printed pages.Gold f does the gold function printed above a key; gold f⁻¹ does its inverse or complement (e^x for LN, x² for √x, clear for a set-flag); blue g does the blue function printed on the key’s sloping lower face. The top row A–E runs whatever program is labelled with that key — on power-up the five functions printed in the window above them, later whatever you or a magnetic card put there.
The small number in each cap is the key’s program code, row then column, which is what the display shows for that step in W/PRGM mode. The bracket labelled CLEAR on the case names the fourth row’s gold functions: STK, REG and PRGM, with PREFIX over ENTER↑.
Two switches: OFF–ON, and W/PRGM–RUN, which decides whether keys are executed or remembered. The card slot is on the right side, below the display.
X, Y, Z and T as on the HP-35 and HP-45, with Last X beside them and, for the first time, R↑ as well as R↓. The handbook’s own demonstration: put 4, 3, 2, 1 in T, Z, Y, X and look around.
The lift rules are printed as a table on page 26 and matter more here, because a program lives or dies by them. Disabled by CLx and ENTER↑, and by R/S when the step before it put a number in X. Enabled by every digit and calculating key, by R↓, R↑ and x⇄y, and by STO and RCL. Everything else — programming keys, modes, DSP, the clears and CHS — leaves the status alone.
Common error 17: CLx puts a zero in X that the next entry overwrites. Key 0 instead.
Program memory is a column of 100 locations. A pointer marks one of them; the display shows that location’s code in W/PRGM mode and SST moves the pointer down. Above the first location is the top of memory, where RTN puts the pointer and where execution starts when R/S is pressed after it.
Keying a step in W/PRGM mode inserts it after the pointer and pushes the bottom step off the end; g DEL removes the one at the pointer and fills the bottom with NOP. A minus sign in the display means memory is full — from then on every insert loses a real step.
Power-up loads the five window functions (1/x, √x, y^x, R↓, x⇄y under LBL A–E) into the top of memory; f PRGM clears them.
Every key has a two-digit code, its row and column on the keyboard — R/S is row 8 column 4, code 84 — except the digits, which are 00 to 09. The display shows a program one code at a time, and the trick to reading a listing is knowing which prefixes merge with their key into one step and which do not.
35 04 — one step: every g function mergesSTO 533 05 — one step; STO 9 and RCL 9 do not mergef LN31 then 07 — two steps: f, f⁻¹, GTO, LBL, DSP take their ownSTO + 433 81 04 — three stepsg NOP35 01 — what cleared memory is full ofThis is why a test “skips two memory locations”: the thing you usually want to skip is GTO n, which is exactly two. Skip a single merged instruction and the skip also swallows whatever follows it — so the handbook pads with a NOP.
Every decision on the HP-65 — the four relational tests, TF 1 and TF 2, and DSZ — has the same shape: if the condition fails, skip the next two locations and continue. There is no else and no jump-to; the branch is whatever you put in those two steps.
The relational tests compare X with Y and scribble in R9. TF skips when the flag is off with f, when on with f⁻¹. DSZ counts R8 down and skips at zero — put n in R8, and a segment ending in g DSZ, GTO n runs n times.
Angles and times in degrees, minutes and seconds are one number: the integer part is degrees, the first two decimals minutes, the next two seconds. Four fixed decimal places (DSP . 4) show it properly.
45° 10′ 50″ plus 44° 49′ 10″: 45.1050 ENTER↑ 44.4910 f D.MS+ shows 90.0000. The same keys time a piece of music from 9:25:07 to 9:39:47 — 14′ 40″ with f⁻¹ D.MS+.
STO n and RCL n with a digit 1 to 9, plus arithmetic into a register with STO + n and its siblings. Which register you choose is immaterial, the handbook says, except for two.
R8 is the loop counter that DSZ decrements, so leave it alone if a loop is coming. R9 is destroyed by the trigonometric functions, the polar conversions and the four relational tests. f REG clears all nine; switching off clears everything, program included.
The HP-65 of January 1974 is the first programmable pocket calculator: the HP-45’s functions, a 100-step program memory with labels, branching, tests and a loop counter, and a magnetic card reader built into the case so a program survives switching off. Same Classic case as the 35 and 45, with a second slide switch — W/PRGM–RUN — and a window above the top row that a program card slides into to label the five user keys.
Nine registers, two flags, fifteen labels, three angular modes, degrees-minutes-seconds arithmetic, octal conversion and a red LED display that shows program codes as well as numbers. Three prefixes — f, f⁻¹ and g — put three functions on most keys.
The handbook describes three ways to use it: by hand, with a recorded card from the Standard Pac, or with a program you write. A pad of program forms came in the box.
Digits, the point, CHS and EEX as before. f then a key does the gold function above it; f⁻¹ the inverse; g the blue function on the key’s lower face. A wrong prefix is fixed by pressing the right one, or cancelled with f PREFIX.
1.00.5 f-1 SIN30.00 — arc sine5 g 1/x0.20123.4567 DSP . 4123.4567 — fixed, four placesDSP 21.23 02 — scientificDSP . 2123.46 — the power-up settingDSP replaces the 45’s FIX and SCI: DSP, the point, a digit for fixed; DSP and a digit for scientific. Four clears live on the fourth row under f: PREFIX, STK (the stack), REG (R1–R9) and PRGM (program memory, at W/PRGM only). CLx clears X alone.
A wide number in a fixed setting is shown in full scientific notation; a tiny one shows as a signed zero.
Four registers, an automatic lift after every answer, T copied down on every drop. Last X takes the argument of each function as it runs, for recovery and for reuse. R↓, R↑ and x⇄y are g functions on 8, 9 and 7 — and, until you redefine them, on D and E.
4.00 — you meant −g LST x ×12.00g LST x −9.001.10 ENTER↑ ENTER↑ ENTER↑ 1000the growth factor in T, Z and Y×1100.00 — and again after one period× × × × ×1771.56 — six periods; a fresh 1.10 drops in each timeThe compound-growth trick above is the handbook’s favourite: a constant in T is copied back into Z and Y on every drop, so one key per period gives the whole series.
CLx and ENTER↑ disable the lift; CHS and the programming keys do not touch it. R/S in a program disables it too, when the step before put a number in X.
STO n and RCL n, n from 1 to 9, and arithmetic into a register with STO + n, STO − n, STO × n and STO ÷ n — the result stays in the register and X is unchanged. There is no RCL arithmetic on the 65.
0.95 — a discount factor1000 RCL 1 ×950.006 STO 1 2 STO + 1 RCL 18.005 STO − 1 RCL 13.00f REGall nine to zeroTwo registers have jobs: R8 is the counter that g DSZ decrements, and R9 is scratch for the trigonometric functions, the polar conversions and the relational tests. The rest are yours.
Logs and their antilogs, roots and squares, reciprocal, power, factorial, and the three the 45 lacked: INT, ABS and octal conversion.
2.72 — e; DSP . 9 shows 2.71828182810 ENTER↑ 2 f LOG ×3.01 — decibels for a doublingg π 3 ENTER↑ × × f √x5.32 — a square with a circle’s area6 g n!720.00512 f →OCT1000.002000 f-1 →OCT1024.0012.1980 f INT12.0000 — and f⁻¹ INT gives 0.1980The five most used — 1/x, √x, y^x, R↓ and x⇄y — are also on A–E when the machine is switched on, one keystroke instead of two, and stay reachable with g or f after a program replaces them.
n! is good to 69; y^x needs y > 0; INT keeps the sign.
Degrees on power-up; g DEG, g RAD, g GRD to change. The trigonometric functions are f on 4, 5 and 6 with their inverses on f⁻¹, and all of them use R9.
0.50g RAD 1 CHS f-1 COS3.14 — arc cosine in radians120 ENTER↑ 8 f-1 R→P-4.00 — x; x⇄y shows y = 6.933 ENTER↑ 4 f R→P5.00 — r; x⇄y shows θ = 36.87DSP . 4 g π 7 ÷ g RAD f →D.MS25.4251 — π/7 as 25° 42′ 51″45.1050 ENTER↑ 44.4910 f D.MS+90.0000R→P takes x in X and y in Y — the y is keyed first — and returns r and θ the same way; f⁻¹ goes back. →D.MS writes a decimal angle in any mode as DDDDD.MMSS and its inverse reads one, so converting to D.MS in one mode and back in another changes the mode of an angle. D.MS+ and its inverse add and subtract in that format directly, which also makes them a clock.
A program is the keys you would press, remembered. Switch to W/PRGM, press f PRGM to clear memory, key the steps, switch back to RUN. A function is a program that begins with LBL and a top-row key and ends with RTN; press the key and it runs.
00 00 — cleared, pointer at the topLBL A11 — the display shows the code of each stepENTER↑ ENTER↑ × ×x³: the number copied twice and multiplied twiceRTN24RUN 3 A27.005 CHS A-125.00Then pass an unprotected card through the slot with the switch still at W/PRGM and the program is recorded; clip the notch and it cannot be overwritten. Programs need not be functions: a sequence at the top of memory that ends in R/S runs from RTN (which sets the pointer to the top) and R/S.
Labels can be digits too, fifteen in all, but only A–E can be called from the keyboard. Common error 1 is forgetting f PRGM, leaving two LBL As in memory.
In W/PRGM mode the display shows the code of the step at the pointer, row then column: 23 is LBL, 11 is A, 24 is RTN. Digits show as 00–09. The most-used prefix pairs are merged into one step; the rest take two.
35 04 — every g function is one stepSTO 833 08 — and STO n, RCL n, except with 9f LN31 07 — f takes its own stepGTO 122 01 — so does GTO, LBL and DSPRTNfrom the keyboard at RUN: pointer to the topGTO Aat RUN: pointer to LBL APower-up fills the top of memory with the five window functions — SST from the top shows 23 11 35 04 24: LBL A, g 1/x, RTN. A minus sign in the display means memory is full; two mean the pointer is at the bottom.
Switching to W/PRGM mid-calculation shows the code of the last key you pressed, which settles whether you pressed + before the phone rang.
Editing is done at W/PRGM with the pointer on the step in question. Move it there at RUN first — RTN for the top, GTO n for a label — then switch and SST down.
11SST35 04 — the 1/x we want to replaceg DEL11 — deleted; the pointer backs up oneg n!35 03 — inserted after itRUN 5 A120.00 — A is now factorialKeying anything in W/PRGM mode inserts it after the displayed step, pushing the last step off the bottom; g DEL deletes the displayed step and fills the bottom with NOP. Neither PRGM, DEL nor SST can be recorded as steps. With memory full a delete loses the bottom step, and at the bottom it deletes two — reinsert the last step afterwards.
R/S stops a running program with X displayed and waits; pressed again it resumes at the pointer. GTO n jumps to LBL n. DSZ counts R8 down and skips two steps at zero, which with GTO makes a loop of n passes.
8.507 ENTER↑ 4 R/S32.30 — a running total; 66.30 and 178.50 followA function called from the keyboard stops at its RTN; called from a program it returns to the caller. That is the only level of nesting: a called function must return before another is called, or the return goes wrong.
A number placed in X by the step just before R/S is not lifted when you key your input, so a program can show 1, 2, 3 … to say which input it wants. And any key stops a running program — keep fingers off.
Four relational tests on g — x≠y, x≤y, x=y, x>y — compare X with Y and skip the next two steps if the condition is false. Two flags: f SF n sets, f⁻¹ SF n clears, f TF n skips two steps if the flag is off and f⁻¹ TF n if it is on.
0.25f-1 SF 1 2 A4.00LBL E f-1 SIN 0 g x⇄y g x>y 3 6 0 +arc sine, plus 360 if it came out ≤ 0.5 CHS E330.00The NOP after g 1/x above is the padding: 1/x is one merged step, the skip is two. The second example is the handbook’s — 3 6 0 are three digit steps, and when the test is true the skip lands on the 0 and adds zero instead of 360.
The tests use R9. Flags are off at power-up and stay set until cleared: common error 11.
Reading: switch at RUN, card into the right-hand slot, let the motor take it. Recording: switch at W/PRGM, an unclipped card, same motion. All 100 steps go each way; the registers are never touched, so one program can leave data for the next.
After loading, slide the card into the window above A–E so its labels name the keys. The card reader needs the battery even on the charger — a flat pack wants five minutes of charge first — and a head-cleaning card is supplied for the day a card will not read. Cards survive airport magnetometers.
The Standard Pac in the box holds nineteen recorded programs with listings, twenty blank cards and twenty pocket instruction cards; the Users’ Library sold more.
A blinking display is an improper operation, and in a program it is also a stop; switch to W/PRGM and the code of the guilty step is showing. The table on page 22 is short:
Overflow leaves all 9s with the sign and stops a program; underflow leaves zero and stops it too. Accuracy is the family story — a count in the tenth digit for arithmetic, a few counts of argument for the functions, n! to nine digits, D.MS to the second.
Appendix D lists seventeen common errors; the ones about lost T, lost R9, the two-step skip and CLx are in the index.
The Owner’s Handbook (January 1974, 100 pages) teaches by example and then boxes the reference material; its Section 4 is still a fine introduction to programming a machine with a pointer and a skip. The Quick Reference Guide is a key dictionary in keyboard order. The Standard Pac book has the nineteen programs with listings that show exactly how codes appear. All three are at literature.hpcalc.org, with the Users’ Library pacs for engineering, finance, surveying, aviation and medicine.
Between the HP-35 and this machine came the HP-45; after it the HP-67 and 97 of 1976 kept the card reader and gave the tests, labels and flags room to grow. The HP-41 sheet shows where the same ideas went next.
Keyboard drawn from the handbook’s keyboard figure; codes from its Figure 4-1 and the Standard Pac listings. Every keystroke sequence is the handbook’s or was checked; the worked example’s figures were computed.
23LBLthe function is called with the A key11A33 08STO 8n into the DSZ counter — one merged step31ff takes a step of its own …42STK… then the key: clear the stack23LBLthe top of the loop01134 08RCL 8the counter’s current value, lifted into the stack61+added to the running sum35 83g DSZR8 − 1 → R8; at zero, skip two steps22GTOthe two steps that get skipped01124RTNstop, with the sum in XThe code the display shows for each step in W/PRGM mode, read by pressing SST from the top of memory. A merged code is one step; f, GTO and LBL are followed by a step for their key. The listing format is the Standard Pac’s.
The loop for n = 5 — each pass recalls R8 into X, lifting the previous sum into Y, adds, and decrements:
Add the integers from 1 to n, for whatever n is in X. Section 4 of the handbook uses this to introduce DSZ, and it is the smallest program that shows the whole programming model: a label, a counter, a test that skips two steps, and a branch back.
The idea. Put n in R8 and clear the stack. Then repeat: recall R8, add it to X, count R8 down. When R8 reaches zero DSZ skips the GTO 1 that follows it — GTO and its label are exactly the two steps a skip covers — and execution falls through to RTN.
Keying it in:
00 00 — memory cleared, pointer at the topLBL A STO 8 f STK42 — the last code keyed showsLBL 1 RCL 8 + g DSZ GTO 1 RTN24RUNreadyRunning it. Key n and press A. The display goes illegible while the loop runs and steadies on the answer:
15.0020 A210.0025 A325.00What the loop does is traced on the left for n = 5. The stack lift is doing quiet work here. f STK leaves 0 in X with the lift enabled, so the first RCL 8 pushes that 0 up and + adds 5 to it. On later passes the RCL lifts the running sum the same way. Had the program cleared X with CLx instead, the first RCL would have overwritten the zero and the sum would still be right — but the handbook’s common error 17 is exactly that habit going wrong somewhere else.
The handbook writes this program at the top of memory without a label and starts it with RTN then R/S; putting it under LBL A costs two steps and lets a card label the key. Sums checked: n(n + 1)/2 for 5, 20 and 25.