HP-65 Reference the 1974 original with the card reader · 91 entries

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.

f f-1 g the prefixes · key a key · 35 04 the display
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.
Colour keythe machineentry, stack & displayprogrammingmathematicsvariables & memoryreference & system

The Keyboard

35 keys · three prefixes · program codes in every cap · drawn to the proportions of the machine
-1.234567809-65
OFFONW/PRGMRUN
1/x√xyxR↓x⇄y
 11A
 12B
 13C
 14D
 15E
 21DSPx≠y
 22GTOx≤y
 23LBLx=y
 24RTNx>y
 25SST
 31f
 32f⁻¹
 33STO
 34RCL
 35g
PREFIX41ENTER↑DEG
STK42CHSRAD
REG43EEXGRD
PRGM44CLxDEL
SF 151
LN077x⇄y
LOG088R↓
√x099R↑
TF 161+
SIN0441/x
COS055yx
TAN066ABS
SF 271×
R→P011NOP
D.MS+022π
→D.MS033n!
TF 281÷
→OCT000LST x
INT83.DSZ
 84R/S
hpHEWLETT · PACKARD65

Three prefixes, five keys of your own, and a slot for the card

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.

f LN
the gold legend above the 7 key
f-1 LN
its inverse, e^x
g DSZ
the blue legend on the lower face of the point key
A
run the function labelled A
STO + 4
register arithmetic: the operator between STO and the digit

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.

gold f and f⁻¹: the legend above the key, or its inverseblue g: the legend on the key’s lower faceblack: A–E and the programming keysthe small number: the key’s program code

HP-65 Guide

the machine, and how to make it do things

Anatomy six things worth seeing laid out

The stack, now with a way up

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.

4 ↑ 3 ↑ 2 ↑ 1
T4
Z3
Y2
X1
ENTER↑ written ↑
g R↑
T3
Z2
Y1
X4
t comes down to X
g R↑
T2
Z1
Y4
X3
four presses restore
g R↓
T3
Z2
Y1
X4
and R↓ undoes one R↑
g x⇄y
T3
Z2
Y4
X1
y without touching z or t

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.

One hundred steps and a pointer

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.

topyour program, one code per stepempty = g NOP00 0023 1133 08… steps …35 0135 01RTN goes herebottom: two minus signs

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.

Codes: row, column, and the ones that merge

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.

g 1/x35 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 of

This 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.

The two-step skip

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.

testskipped when falseruns either wayg x>y2205next instructionGTO 5: taken when true
one merged stepNOP paddingg DSZ35 0435 01next instructionR8 − 1; skip when it reaches 0

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.

DDDDD.MMSS

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.

degrees, up to 99999minutesseconds00045.1050f →D.MS makes one; f⁻¹ →D.MS reads itD.MS+ adds two directly

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+.

Nine registers, two of them spoken for

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.

R1free
R2free
R3free
R4free
R5free
R6free
R7free
R8DSZ counter
R9trig & test scratch

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 machine

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.

Prefixes and keying in

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.

90 f SIN1.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 setting

DSP 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.

The stack and Last X

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.

12 ENTER↑ 3 ÷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 time

The 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.

Registers

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.

1 ENTER↑ .05 STO 10.95 — a discount factor1000 RCL 1 ×950.006 STO 1 2 STO + 1 RCL 18.005 STO 1 RCL 13.00f REGall nine to zero

Two 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.

Functions of x

Logs and their antilogs, roots and squares, reciprocal, power, factorial, and the three the 45 lacked: INT, ABS and octal conversion.

1 f-1 LN2.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.1980

The 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.

Angles

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.

60 f COS0.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.0000

R→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.

Writing a program

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.

W/PRGM f PRGM00 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.00

Then 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.

Codes and the pointer

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.

SSTadvance the pointer and show the next codeg 1/x35 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 A

Power-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

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.

RUN GTO A W/PRGM11SST35 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 factorial

Keying 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.

Stopping, branching and looping

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.

f STK LBL 9 R/Sclear, mark the loop, stop for a pair of numbers× .85 × + GTO 9discounted cost added to the total, and round againRUN RTN R/S 5 ENTER↑ 2 R/S8.507 ENTER↑ 4 R/S32.30 — a running total; 66.30 and 178.50 follow

A 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.

Tests and flags

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.

LBL A f TF 1 g 1/x g NOP f-1 √x RTN(1/x)² if flag 1 is on, x² if offf SF 1 2 A0.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.00

The 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.

Magnetic cards

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.

RUNcard in — the program replaces memoryblinkingmisread or blank: memory cleared; CLx and reinsertW/PRGMcard in — memory recorded on the cardclip the notchprotected; the machine will not record over it

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.

Limits and errors

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:

f LN, LOG, √xx ≤ 0 (x < 0 for the root)
f-1 SIN, COS|x| > 1
D.MS+, →D.MSan operand or result past 99999.99999° or 99999.59599
→OCTnon-integer, or beyond 1073741823 (7777777777₈)
g 1/x, ÷x = 0
g y^xy ≤ 0
g n!non-integer or negative x
card readblank card, or a bit dropped

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.

Reading more

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.

Key & Function Index

91 entries · every key under each prefix, and every behaviour the handbook describes · hover for details and the page

Arithmetic

5
+y + x; the stack drops and x goes to Last X
y − x
×y × x
÷y ÷ x
serial & chainedan automatic ENTER↑ after every answer

Entry, display & clearing

15
0 … 9 .digits and the point
CHSchange sign
EEXenter exponent
CLxclear X, and stop a blinking display
f PREFIXcancel a pending f, f⁻¹, g, STO, RCL, GTO, LBL or DSP
f STKclear the four stack registers
f REGclear R1 … R9
f PRGMclear program memory
DSP . nfixed display with n decimal places
DSP nscientific display with n places
blinking displayimproper operation, or a card misread
illegible displaya program is running
all decimal points littwo to five minutes of battery left
OFF – ONpower switch
W/PRGM – RUNthe mode switch

The stack & Last X

7
ENTER↑copy x into Y
g x⇄yexchange X and Y
g R↓roll down
g R↑roll up
g LST xrecall Last X
stack liftenabled by every calculating key, disabled by CLx and ENTER↑
a constant in Treused on every drop

Storage registers

6
STO nstore x in R1 … R9
RCL nrecall Rn to X
STO + nRn + x → Rn
f REGclear all nine registers
R8the DSZ counter
R9scratch

Logs, powers & functions of x

11
f LNnatural logarithm
f LOGcommon logarithm
f √xsquare root
g 1/xreciprocal
g y^xy to the power x
g n!factorial of a non-negative integer
g ABSabsolute value
f INTinteger part, sign kept
f →OCTdecimal integer to octal
g π3.141592654 into X
A … Ethe window functions, until you redefine them

Angles & conversions

10
g DEGdegrees mode
g RADradians mode
g GRDgrads mode
f SINsine of x
f COScosine
f TANtangent
f R→Prectangular to polar
f →D.MSdecimal angle to DDDDD.MMSS
f D.MS+add y + x in DDDDD.MMSS
mode conversionthrough D.MS

Program control

10
LBL na label: a digit 0–9 or a top-row key A–E
A … Erun the function with that label
RTNreturn
R/Srun / stop
GTO ngo to LBL n
SSTsingle step
g NOPno operation
g DSZdecrement R8 and skip on zero
nestingone level
program memory100 steps, one pointer

Editing programs & codes

6
coderow then column
merged codesone step for g anything, STO n and RCL n
insertkey a step in W/PRGM mode
g DELdelete the displayed step
positioningRTN for the top, GTO n for a label, SST to walk
what did I press?switch to W/PRGM

Tests & flags

9
g x≠yskip two steps unless x ≠ y
g x≤yskip two steps unless x ≤ y
g x=yskip two steps unless x = y
g x>yskip two steps unless x > y
f SF 1set flag 1
f TF 1skip two steps if flag 1 is off
f SF 2set flag 2; f-1 clears
f TF 2test flag 2
the two-step skipskip a GTO, or one instruction and a NOP

Magnetic cards

7
readingswitch at RUN, card in the right-hand slot
recordingswitch at W/PRGM, an unprotected card
protectingclip the notched corner
second trackthe other edge, inserted arrow-end last
head cleaning cardabrasive — use it only when a card fails
batterythe motor needs it even on the charger
Standard Pac19 recorded programs and 20 blanks

Accuracy & limits

5
range10⁻⁹⁹ to 9.999999999 × 10⁹⁹
overflowall 9s with the sign, and a running program stops
accuracyone count in the tenth digit for +, −, ×, ÷, 1/x, √x
temperature10 to 40 °C, charging included
common errorsthe handbook’s list of seventeen

Worked Example — a loop that adds 1 to n, thirteen steps

the handbook’s page 65 program as a function on the A key, with every step’s code as the display shows it
23LBLthe function is called with the A key
11A
33 08STO 8n into the DSZ counter — one merged step
31ff takes a step of its own …
42STK… then the key: clear the stack
23LBLthe top of the loop
011
34 08RCL 8the counter’s current value, lifted into the stack
61+added to the running sum
35 83g DSZR8 − 1 → R8; at zero, skip two steps
22GTOthe two steps that get skipped
011
24RTNstop, with the sum in X

The 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:

R8 after DSZX (sum)Y5 A550n stored, stack clearedRCL 8 +4550 + 5; DSZ makes R8 4, not zero: GTO 1RCL 8 +395RCL 8 +2129RCL 8 +11412RCL 8 +01514DSZ reaches zero: GTO 1 skipped, RTN runs

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:

W/PRGM f PRGM00 00 — memory cleared, pointer at the topLBL A STO 8 f STK42 — the last code keyed showsLBL 1 RCL 8 + g DSZ GTO 1 RTN24RUNready

Running it. Key n and press A. The display goes illegible while the loop runs and steadies on the answer:

5 A15.0020 A210.0025 A325.00

What 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.