HP-71B BASIC Reference Programmer's guide · 249 keyword entries grouped by function · from the HP-71 Owner's Manual

Page 1 explains the HP-71 as a machine and language: keyboard and CALC mode, program-line syntax, variables and strings, operators, number formats and IEEE math exceptions, branching, subprograms, errors, flags, input, output formatting, files, data files, editing, clock and statistics. The following pages index every keyword from the Owner's Manual's Keyword Index by category. Hover any keyword for its syntax, description and Owner's Manual page. A final section covers the Emu71 emulator only.

Type: Statement Function (usable in expressions) Operator · OM p.nn = HP-71 Owner's Manual page
Sources: HP-71 Owner's Manual (HP 00071-90001 Rev. D, Feb 1985) — sections 1–14, appendices A–C, Keyword Index. Keywords in more than one category are listed in each. Emu71 section: Emu71 v1.19 manual and MK71MAC.TXT (C. Gießelink).
Hewlett-Packard HP-71B handheld computer, top view, showing the LCD and full QWERTY keyboard
HP-71B — 1984. Four-line-capable 22-character LCD, full QWERTY keyboard, HP-BASIC in ROM, four card-edge ports. Photograph by M.G. Berberich, Wikimedia Commons, released into the public domain.
Colour keythe machineentry, stack & displayprogrammingmathematicsdata objectsvariables & memoryinput, output & interfacenative code & hardware

HP-71B Programmer's Reference

BASIC language, machine features, idioms — syntax, semantics

Keyboard & Modes

Shifts: f (gold, above keys) · g (blue, below keys). Release the shift before or hold it while pressing the key. Letters are uppercase; g+letter gives the other case; fLC toggles lowercase mode (flag −15).

KeyAction
END LINEExecute / enter the line (like RETURN)
ATTNClear display; halt a running program (SUSP). Also the ON key
fOFF / ONPower off / on (auto-off after 10 min unless flag −3 set)
fCALCToggle CALC mode ↔ BASIC mode
RUNRun current file (or resume) · in CALC: show next partial result
fCONTContinue a suspended program
fSSTSingle-step one statement (or one CALC step)
fUSERToggle User keyboard · g1USER = User kbd for next key only
gCMDSCommand Stack: last 5 commands; ▲▼ to browse, END LINE to run
fVIEWHold next key → shows its DEF KEY string
gERRMShow last error/warning message
fBACKBackspace (delete left) · in CALC: undo last operation
f-CHAR / f-LINEDelete char under cursor / delete to end of line
fI/RToggle Insert / Replace cursor
◀ ▶ · ggMove cursor · jump to start / end of the 96-char line
▲ ▼Previous / next line (FETCH neighbours, CAT entries, Command Stack)
gCTRL+keyControl character (CTRL-M = CR, CTRL-J = LF, CTRL-g[ = ESC)
ON+/INIT: 1 (system reset, memory kept) · 2 (self-test) · 3 (memory reset: clears main RAM; independent RAM survives)

Display: 22-character window on a 96-character line; ← → annunciators show the line extends. Typing aids: f+top-row keys type keywords (e.g. fS = DISP ).

Annunciators

f g shift pending · USER User keyboard · RAD radians · 0 1 2 3 4 user flags 0–4 set · BAT low battery · ((•)) alarm · PRGM program running · SUSP suspended · CALC CALC mode · AC reserved.

CALC Mode

fCALC toggles. Evaluates numeric expressions with intermediate results as you type — same variables, functions, precedence and user-defined single-line functions as BASIC. Assignments allowed (A=3*4).

SIN(30auto-supplies ")" — closing parens optional()implied result: value of the last evaluated expressionMAX(3,flashing "," reminds of missing arguments2+3*partial results shown as precedence allows
KeyIn CALC mode
END LINEFinish and evaluate
RUN / fSSTShow next intermediate step separately
fBACKBackward execution: undo operands/operators one at a time
Recall whole expression into Command Stack for editing; ⊲ shows it was already evaluated

Not available in CALC: strings, DTH$/HTD, multi-line user functions, statements other than assignment, program lines. Don't insert/remove modules while CALC mode is on (memory reset).

Program Lines & Syntax

10 DISP "HI" @ BEEP @ WAIT 1line number 1–9999; @ joins statements20 ! comment / 20 REM commentremarks (! also allowed after a statement)30 'AGAIN': X=X+1 @ IF X<5 THEN AGAINlabel = up to 8 letters/digits + colon; quotes added by the 7140 IF A>B THEN 100 ELSE DISP "NO"THEN/ELSE take a line, label or statement(s)LET A=1 · A=1 · A,B,C=0LET optional; multiple assignment
  • Keywords may be typed in lower case; the HP-71 uppercases keywords, file names and variable names. Strings keep case; quote with "…" or '…'.
  • Line length 96 chars. Program lines are kept sorted; enter in any order. Multi-statement lines save 2 bytes each.
  • Variables: a letter or letter+digit (A, X1); strings add $ (N$); arrays A(3), M(2,3) (max 2 dims). Numeric and string of the same name are distinct.
  • Files: name = 1–8 letters/digits, first a letter; optional device :MAIN, :PORT(n), :CARD. Reserved: ALL CARD KEYS TO INTO PCRD.
  • Numbers: 1.5E-3, -7; 12 significant digits, exponent ±499. Hex via HTD("FF"), DTH$(255).

Variables, Arrays & Strings

DIM A(10), B(3,4), N$[80]numeric arrays (default OPTION BASE 0), string max lengthREAL X, Y(5) · SHORT S(100) · INTEGER I,Jdeclare precision (also dimensions arrays)OPTION BASE 1lowest subscript 1 (default 0); must precede DIMDESTROY A, B$ · DESTROY ALLfree variables (ALL: every variable, incl. arrays)A$[3,5] · A$[4] · A$[3,3]="x"substring chars 3–5 · from 4 to end · replaceA$ & B$ · LEN(A$) · POS(A$,"x")concatenate · length · position (0 if absent)VAL("12.5") · STR$(2/3) · NUM("A") · CHR$(65)string↔number, char code↔charUPRC$(A$) · VER$ · A$="ab" & CHR$(13)uppercase · ROM version string · control chars
TypeRangeStorage
REAL (default)±1E-499 … ±9.99999999999E499, 12 digits8 bytes
SHORT5 digits, ±9.9999E4994 bytes
INTEGER−99999 … +999993 bytes
Stringdefault max 32 chars; DIM up to memorylen+2

Undeclared numeric variables are REAL scalars created on first use (value 0); strings default to "" with max length 32. Arrays are dimensioned implicitly to (10) / (10,10) on first use. Comparing strings uses character codes.

Operators & Precedence

LevelOperators (highest first)
1( ) — innermost first
2Functions: SIN, LOG, FACT, user FN…
3^ (exponentiation)
4unary −, NOT
5* / % DIV
6+ −
7Relational: = # <> < <= > >= ?
8AND
9OR, EXOR
7 DIV 2 → 3 · 7 \ 2 → 3integer division (\ is the same operator)MOD(7,2) → 1 · RMD(-7,2) → -1modulo (sign of divisor) · remainder (sign of dividend)50 % 200 → 100x % y = x percent of yA=B vs IF A=B= assigns when the line can be read either wayX # Y · X <> Ynot equal (both forms)X ? Yunordered: 1 if either operand is NaNNOT A AND B → (NOT A) AND Blogical ops treat non-zero as true, return 1/0"ABC" < "ABD" → 1strings compare by character code

Same-level operators evaluate left to right. EXOR: exactly one true. Relational operators return 1 (true) or 0 (false).

Number Display & Rounding

STDminimum digits for full 12-digit accuracy (default)FIX 2 · SCI 4 · ENG 3fixed decimals · scientific · engineering (0–11 digits)OPTION ROUND NEAR|ZERO|POS|NEGrounding direction for inexact results (default NEAR)RESvalue of the last expression evaluatedEPS → 1E-499 · MAXREAL → 9.99999999999E499smallest / largest positive realMINREAL → 1E-499 · PI · INF · NANconstants (INF/NAN with DEFAULT EXTEND)RND · RANDOMIZE [seed]random 0≤r<1 · reseed (no arg: from clock)IP(-3.7)→-3 FP(-3.7)→-.7 INT(-3.7)→-4integer part · fraction · greatest integer ≤ xFLOOR = INT · CEIL(3.2)→4 · SGN · ABSrounding familyRED(x,y) → x-y*n, n=nearest int to x/yreduce (like MOD but rounds)

Numbers ≥ 1E12 in magnitude are always shown in exponential form. FIX/SCI/ENG digits are readable in flags −17…−20; format in flags −13/−14; rounding in flags −11/−12. Display formats do not change stored values (12-digit internal precision).

Math Exceptions & IEEE

ExceptionFlagNameExamples
Invalid operation−8IVLACOS(2), LOG(-23), (-14)^(-1/3)
Division by zero−7DVZ187/0, TAN(90)
Overflow−6OVFFACT(254), 10*1E499
Underflow−5UNFEXP(-1149), 1/3E499
Inexact result−4INX1/3, 1+1E-50
DEFAULT ON(reset state) DVZ/OVF/UNF → warning + default value; IVL stopsDEFAULT OFFany exception except INX is an error (use ON ERROR)DEFAULT EXTENDIEEE defaults: Inf, -Inf, NaN; math continuesTRAP(DVZ,2) · TRAP(-7)set trap for a flag: 0 error · 1 default value · 2 IEEE value; no 2nd arg → readCFLAG MATH · CFLAG -8clear all / one math-exception flagCLASS(X)category of X: 1 zero, 2 denormalised, 3 normalised… ±sign; NaN/Inf classesX ? Y · INF · NANunordered test · IEEE constants (with DEFAULT EXTEND)
ERRNWarning (DEFAULT ON)Default value
1 UNFunderflow0
2 OVFoverflow±99999 INTEGER · ±9.9999E499 SHORT · ±9.99999999999E499 REAL
3 DVZEXPONENT(0)−9.99999999999E499
4 DVZTAN of odd multiple of 90°±9.99999999999E499
5 DVZ0 ^ negative±9.99999999999E499
60 ^ 01
12 DVZLN(0)−9.99999999999E499

Branching, Loops & Conditionals

GOTO 100 · GOTO DONEline or labelGOSUB 500 … RETURN · POPsubroutine; POP discards one pending RETURNON N GOTO 10,20,LAB · ON N GOSUB …N rounded → 1st, 2nd… targetON N RESTORE 100,200sets DATA pointer by NIF X<0 THEN X=-X @ Y=1 ELSE Y=0statements after THEN/ELSE run only on that branchIF A THEN 100THEN line-number = GOTOFOR I=1 TO 10 STEP 2 … NEXT Iloop; NEXT var optional; body skipped if start beyond limitWAIT 2.5 · PAUSE · STOP · END · END ALLdelay · suspend (CONT resumes) · halt · end · end all subprograms tooON TIMER #1,30 GOTO 900 · OFF TIMER #13 timers, 0.1 – 134 217 727 s; retriggers each intervalON TIMER #2,15 GOSUB 100RETURN re-arms; timers can wake a switched-off HP-71BYE · OFFturn off (a program with a timer resumes on wake-up)

GOTO/GOSUB cannot branch into a subprogram or user function. Timers are local to the program/subprogram that set them. Nested GOSUBs limited only by memory.

Subprograms & User Functions

CALL AREA(R, A) ! in current filecall subprogram; parameters by referenceCALL AREA((R), A) IN GEOM(R) passes by value; IN file = other fileSUB AREA(X, Y) @ Y=PI*X*X @ END SUBsubprogram; own variables, flags & files sharedSUB SHOW(A(,), N$) … END SUBarray (,) and string parametersDEF FNC(F)=(F-32)*5/9single-line numeric functionDEF FNR$(S$)=S$[LEN(S$)]&S$[1,LEN(S$)-1]string functionDEF FNF(N) @ IF N<2 THEN FNF=1 ELSE FNF=N*FNF(N-1) @ END DEFmulti-line: assign to name, END DEF returnsDISP FNC(212) · X=FNF(5)use like built-ins (single-line ones also in CALC mode)
  • SUB…END SUB blocks live in program files (after the main program or in a file of their own). CALL name searches the current file, then all files. RUN starts at the first line, so a file may be all subprograms.
  • Subprogram variables are local; only parameters, files, flags, and DATA are shared. END SUB / END returns to the caller.
  • Recursion allowed (memory limited). END ALL terminates the whole chain of subprograms.

Errors & Debugging

ON ERROR GOTO 900 · ON ERROR GOSUB 900trap run-time errors; GOSUB returns to the failing statementOFF ERRORrestore normal error haltERRN · ERRL · ERRM$last error number · line · message textTRACE FLOW · TRACE VARS · TRACE VARS A,B$ · TRACE OFFshow branches / assignments while runningCONT · CONT 120 · RUN 120 · RUN FILE,LABresume · from a line · run from line/labelSFLAG -1suppress most warning messagesBEEP OFF · SFLAG -2silence beeper (flag −2)
Message formMeaning
ERR:Invalid Exprsyntax error from the keyboard
ERR L30:String Ovflrun-time error at line 30 (program suspended)
WRN L30:…warning; execution continues
Line Too Long, Missing Param, Data Typecommon messages — full list in the Reference Manual

gERRM or ERRM$ redisplays the last message. Errors set ERRN/ERRL; a suspended program shows SUSP — fix and CONT, or SST through it. Math-exception warnings 1–12 are listed in "Math Exceptions".

Flags

SFLAG 3 · CFLAG 3 · FLAG(3)set · clear · test (1/0)IF FLAG(-10) THEN …system flags are negativeCFLAG ALL · CFLAG MATHclear all user flags 0–63 · clear −4…−8SFLAG -25 · RESETloud beeper · reset system flags to defaults
FlagMeaning (set = …)
0 – 63User flags; 0–4 have annunciators
−1Suppress warning messages
−2 / −25Beeper off / loud
−3Continuous on (no 10-min auto-off)
−4…−8INX UNF OVF DVZ IVL math exceptions
−9User keyboard active
−10Radians (RAD annunciator)
−11,−12Rounding: 00 NEAR · 01 ZERO · 10 POS · 11 NEG
−13,−14Format: 00 STD · 10 FIX · 01 SCI · 11 ENG
−15Lowercase keyboard
−16OPTION BASE 1
−17…−20Digits shown (binary, −17 = bit 0)
−26BASIC prompt suppressed
−46EXACT executed (read-only)
−57 −60…−64AC · alarm · BAT · PRGM · SUSP · CALC annunciators (read-only)

−1…−32 may be set/cleared/tested; −33…−64 test only. All flags are global (visible in subprograms).

Input & the Keyboard

INPUT A, B$prompts "?"; items separated by commas; expressions allowedINPUT "NAME, AGE: "; N$, Acustom prompt (quoted string; can't be overwritten)INPUT "N? ","10"; Ndefault string appears in the display for editingLINPUT "TEXT? "; L$whole line into one string (commas, quotes kept)K$=KEY$oldest key from the 15-key buffer ("" if none); same names as DEF KEYKEYDOWN · KEYDOWN("Q") · KEYDOWN("#43")any key down? · specific key (unshifted only)PUT "RUN"&CHR$(13) · PUT "#43"push keystrokes into the key bufferDISP$readable characters currently in the display (max 96)

User keys

DEF KEY "fS","DISP TIME$";typing aid (";") — string only displayedDEF KEY "gC","RUN CLOCK":execute-only (":") — runs directly, display ignoredDEF KEY "A","STD @ FIX 2"display-then-execute (no suffix)DEF KEY "#43" · DEF KEY "K"key by number (1–56, f: 57–112, g: 113–168) · cancelFETCH KEY "gC" · KEYDEF$("gC")edit definition · read assigned stringUSER · USER ON · USER OFFtoggle / set the User keyboard (flag −9)LIST KEYS · PURGE KEYS · MERGE KEYFILEdefinitions live in the "keys" fileCOPY KEYS TO K1 · COPY K1 TO KEYSsave / restore key sets

Output & Formatting

DISP A; B$, C";" no space (numbers get sign/space), "," next 21-col fieldDISP "X=";X; · PRINT TAB(10);Atrailing ; suppresses end-of-line · TABPRINT …to printer (or display when no printer is assigned)DISP USING "DDD.DD,4X,5A"; N, S$format string inlinePRINT USING 100; A, B · 100 IMAGE 2(8X,6D)/format on an IMAGE lineF$="SDDD.DD" @ DISP USING F$; Vstring variable formatDELAY 0.5,0.1 · DELAY 8line rate (s), scroll rate; ≥ 8 = infinite (wait)WIDTH 22 · PWIDTH 80 · ENDLINE CHR$(13)&CHR$(10)line lengths 0–96 · end-of-line string (≤3 chars)WINDOW 5,18 · WINDOW 1protect display columns outside 5–18 · unprotectCONTRAST 9 · BEEP 440,.5 · BEEP0–15 · Hz, seconds (default 500 Hz, .25 s)GDISP D$ · D$=GDISP$132-column dot pattern out / in (1 char per column)CHARSET CHR$(64)&… · CHARSET$define chars 128… (6 bytes per char) · read set

IMAGE field specifiers

SpecMeaning
Ddigit (leading zeros as blanks)
Zdigit with leading zeros
*digit, leading asterisks
Ssign + or −
M− or blank
.decimal point
Rcomma as radix
Cdigit separator ,
Eexponent field
Kcompact (like STD, no padding)
Acharacter
Xblank
"text"literal
/end of line
#suppress end of line
Bbyte: char with the given code
n(…)repeat group n times
,field separator

Symbol list per the Reference Manual's IMAGE entry (the Owner's Manual defers to it). A format string is reused when the list has more items than fields. Numeric field ↔ numeric item, else error. Escape sequences (ESC = CHR$(27)): ESC< cursor off · ESC> on · ESC E clear · ESC N/R insert/replace · ESC %cn cursor to column CODE(c) · ESC C/D right/left · ESC K clear to end · ESC O delete char. Text written while the cursor is off is a protected field.

Files & Memory

File typeWhat
BASICprogram (EDIT/RUN)
TEXTLIF1 text records (TRANSFORM, HP-IL transfer)
DATArandom/sequential records (CREATE DATA)
SDATA8-byte numbers, HP-41 compatible
KEYkey definitions ("keys" = current)
BIN / LEXbinary program / language extension (keywords)
EDIT PROG · EDIT · NAME NEWNAMEmake current (create if new) · edit workfile · name itCAT · CAT ALL · CAT PROG · CAT :PORT(1) · CAT$(2)catalog: current file · all · one · device · nth entryCOPY A TO B · COPY A TO :PORT(0) · COPY :CARD · COPY A TO CARDduplicate (dest. must not exist)RENAME A TO B · PURGE A · PURGE KEYSrename · deleteMERGE SUBS · MERGE SUBS,100,200append lines of another BASIC file (line range) into currentSECURE F · UNSECURE F · PRIVATE Fno modify/purge · undo · irreversible: run only, no list/copy/editPROTECT / UNPROTECTcard write-protection (HP 82400A)TRANSFORM PROG INTO TEXT PTXT · TRANSFORM PTXT INTO BASICprogram ↔ text fileMEM · MEM(0) · SHOW PORT · SHOW PORT 0free bytes (main RAM / port) · port sizes & type (1 RAM 2 ROM)FREE PORT(0.02) · CLAIM PORT(0)make 4K unit independent RAM (survives INIT: 3) · reclaim (clears it)ADDR$("PROG") · PEEK$("2F400",8) · POKE "2F400","0F"file address · read/write nibbles as hex strings

Devices: :MAIN, :PORT (all ports), :PORT(n) n = 0–5 (5 = card reader port), :CARD, :PCRD (private card). Search order without a device: main RAM, then ports 0,1,2… Port 0 = internal 16 K in four 4 K units (0, .01, .02, .03). CAT columns: NAME S TYPE LEN DATE TIME PORT (S: P private, S secure).

Data: DATA/READ & Data Files

100 DATA 1, 2.5, "text", ABCconstants in program lines (unquoted strings OK)READ A, B, S$ · RESTORE · RESTORE 200sequential read · reset pointer (to a line)CREATE DATA DF, 50, 32DATA file: 50 records of 32 bytes (defaults: 1 record, 256 bytes)CREATE TEXT TF · CREATE SDATA SF, 100text file · SDATA (100 8-byte numbers)ASSIGN #1 TO DF · ASSIGN #1 TO DF:PORT(1) · ASSIGN #1 TO *open channel 1–255 · closePRINT #1; A, B$, M(,)sequential write; whole array with (,)PRINT #1,5; X · READ #1,5; Xrandom access: record 5READ #1; A, B$ · RESTORE #1 · RESTORE #1,3sequential read · rewind · to record 3IF … THEN … ON ERROR GOTO EOFend of file gives an error → trap itCALL SUB1(#1) · SUB SUB1(#C)pass an open channel to a subprogram

DATA files store numbers (8 bytes) and strings (length+text) in records; an item that doesn't fit a record spills to the next in sequential mode but errors in random mode. TEXT files are read/written a line (record) at a time. Closing: ASSIGN # TO * or program END.

Editing & Running Programs

EDIT PROGcreate/select current file — the PRGM lines you type go here10 DISP "HELLO"type line number + statements, END LINEAUTO · AUTO 100,5auto line numbers (start, step; default 10,10); ATTN endsFETCH 30 · FETCH LAB · ▲ ▼bring a line to the display for editing; step throughLIST · LIST 100,200 · PLISTlist (display, paced by DELAY) · to printerDELETE 30 · DELETE 30,90 · DELETE ALLremove linesRENUMBER · RENUMBER 100,10 · RENUMBER 1000,10,500,600renumber (new start, step, old first, old last)RUN · RUN PROG · RUN PROG,LAB · RUN 200run current / named file, from a line or labelCALL PROG · CHAIN PROG:CARDrun as subprogram · purge current, load & run nextCONT · f-SST · ATTNcontinue · single-step · suspendCOPY TO PROG · DELETE ALLsave the workfile under a name · clear workfileSECURE PROG · PRIVATE PROGprotect before distributing

workfile is the unnamed default file (NAME gives it a name). Only one current file; RUN filename makes it current. BIN files run with RUN/CALL but can't be listed; LEX files add keywords and just need to be in memory. TRACE FLOW/VARS for debugging.

Clock, Calendar & Timers

SETDATE "85/03/07" · SETDATE 85066 · SETDATE "1985/03/07"YY/MM/DD or YYDDD (day of year)DATE → 85066 · DATE$ → "85/03/07"numeric YYDDD · stringSETTIME "08:15:00" · SETTIME 8*3600+15*6024-hour string or seconds since midnightTIME → 29700 · TIME$ → "08:15:00"seconds since midnight · stringADJABS -3600 · ADJABS "-01:00:00"shift clock, no speed correction (time zones)ADJUST 43 · ADJUST "00:01:00"shift and accumulate a speed-correction (±100 h)EXACTmark "clock is exact now"; applies accumulated correction (flag −46)AF(0.5) · AFset / read speed adjustment factor directlyRESET CLOCKclear speed correction, keep timeON TIMER #1,60 GOSUB TICKsee Branching — 3 timers, wake from OFF

Set the clock with SETTIME after a memory reset, then EXACT; later use SETTIME/ADJUST to correct drift and EXACT again to teach the crystal correction. Calendar range 0000–9999 (Gregorian from 1582/1752).

Statistics

STAT S(3) · STAT Screate/select current statistical array for 3 variables (max 15) · reselectCLSTATclear (zero) the current statistical arrayADD 6.4, 3.85, 3.6 · DROP 6.4, 3.85, 3.6add / remove a data point (one value per variable)TOTAL(2) · TOTAL(0) · MEAN(1) · SDEV(3)sum of var 2 · number of points · mean · sample std. dev.CORR(1,2)sample correlation of variables 1 and 2LR 2,1 · LR 2,1,A,Blinear regression of var 2 on var 1; intercept→A, slope→BPREDV(X)predicted dependent value at X for the current LR model

The array holds only summary statistics (sums, sums of squares, cross products), always base 0 and REAL. Default variable number is 1. Fit other curves by transforming data (e.g. ADD X, LN(Y) for exponential fits).

Idioms

10 DESTROY ALL @ OPTION BASE 1 @ STDclean start of a program20 DELAY 0,0fastest display, no waiting30 ON ERROR GOSUB 900central error handler40 INPUT "N? ",STR$(N); Nre-prompt with previous value as default50 K$=KEY$ @ IF K$="" THEN 50wait for a key60 IF UPRC$(K$)="Q" THEN ENDquit on Q (ATTN itself suspends the program)70 DISP "Working…"; @ … @ DISPprogress on one line80 T=TIME @ … @ DISP TIME-T;"s"timing (seconds)90 A$=DTH$(HTD(A$)+1)hex arithmetic100 IF FLAG(-10) THEN RADIANS ELSE DEGREESpreserve angle mode110 X=RND*(H-L)+Lrandom real in [L,H)120 SFLAG -1 @ … @ CFLAG -1quiet sectionDEF KEY "gR","RUN":one-key run from the User keyboardSTARTUP "RUN MENU"command executed at every power-onLOCK "SECRET"lock the keyboard until the password is typed

Keyword Reference

249 entries · 13 categories · hover for syntax & details

Program Entry & Editing

14

Files

EDITSelect / create program file
NAMEName the workfile
TRANSFORMBASIC ↔ TEXT
PRIVATEMake file run-only
SECUREProtect from change
UNSECURERemove SECURE

Lines

AUTOAutomatic line numbers
DELETEDelete lines
FETCHBring line to display
LISTList program
PLISTList to printer
RENUMBERRenumber lines
REM (!)Remark
@Statement separator

Program Execution & Control

34

Run

RUNRun a program
CONTContinue
CALLCall subprogram
CHAINChain program
BYEPower off
OFFPower off

Branch

GOTOBranch
GOSUBSubroutine call
RETURNReturn
POPDrop return address
ON…GOTOComputed GOTO
ON…GOSUBComputed GOSUB
ON…RESTOREComputed RESTORE
IF…THEN…ELSEConditional
FOR…NEXTLoop

Stop & wait

ENDEnd program
STOPHalt
PAUSESuspend
WAITDelay

Subprograms & functions

SUBBegin subprogram
END SUBEnd subprogram
DEF FNDefine user function
END DEFEnd multi-line function
FNCall user function

Timers

ON TIMER #Timer branch
OFF TIMERCancel timer

Errors

ON ERROR GOTOError trap
ON ERROR GOSUBError trap (subroutine)
OFF ERRORCancel trap
ERRNError number
ERRLError line
ERRM$Error message
DEFAULTException handling
TRACETrace execution

Storage & Memory

15

Variables

DIMDimension
REALDeclare REAL
SHORTDeclare SHORT
INTEGERDeclare INTEGER
OPTION BASEArray base
DESTROYFree variables
LETAssign
STATStatistical array

Ports

MEMFree memory
SHOW PORTPort info
FREE PORTMake independent RAM
CLAIM PORTReclaim RAM
ADDR$File address
PEEK$Read memory
POKEWrite memory

Operators

17

Arithmetic

+Add
Subtract / negate
*Multiply
/Divide
^Power
DIV (\)Integer divide
%Percent

Relational

=Equal
# / <>Not equal
< <=Less
> >=Greater
?Unordered

Logical

ANDBoth true
OREither true
EXOROne true
NOTNegate
&Concatenate

General Math

42

Parts & rounding

ABSAbsolute value
SGNSign
IPInteger part
FPFractional part
INTFloor
FLOORFloor
CEILCeiling
MAXMaximum
MINMinimum
MODModulo
RMDRemainder
REDReduce

Powers & roots

SQRSquare root
SQRTSquare root
FACTFactorial
EXPe^x
EXPM1e^x − 1
LNNatural log
LOGNatural log
LOGP1ln(1+x)
LGTCommon log
LOG10Common log
EXPONENTExponent of x

Random & constants

RNDRandom
RANDOMIZESeed
PIπ
RESLast result
EPSSmallest positive
MINREALSmallest positive
MAXREALLargest real
INFInfinity
NANNot a number

Conversions

DTH$Decimal → hex
HTDHex → decimal
CLASSNumber class

Exceptions

IVLInvalid flag
DVZDivide-by-zero flag
OVFOverflow flag
UNFUnderflow flag
INXInexact flag
TRAPException trap
OPTION ROUNDRounding mode

Trigonometry

12

Functions

SINSine
COSCosine
TANTangent
ASIN / ASNArcsine
ACOS / ACSArccosine
ATAN / ATNArctangent
ANGLEAngle of (x,y)
DEGRad → deg
RADDeg → rad

Mode

DEGREESDegree mode
RADIANSRadian mode
OPTION ANGLEAngle mode

Statistics

10

Data

STATStatistical array
CLSTATClear stats
ADDAdd data point
DROPRemove data point

Results

TOTALSum
MEANMean
SDEVStd. deviation
CORRCorrelation
LRLinear regression
PREDVPredicted value

Strings

10

Functions

LENLength
POSPosition
VALString → number
STR$Number → string
NUMCharacter code
CHR$Code → character
UPRC$Uppercase
VER$Version
&Concatenate
s$[a,b]Substring

Input & Output

35

Display & print

DISPDisplay
PRINTPrint
DISP USINGFormatted display
PRINT USINGFormatted print
IMAGEFormat line
TABTab
WIDTHDisplay line width
PWIDTHPrinter line width
ENDLINEEnd-of-line string
DELAYDisplay timing
CONTRASTLCD contrast
WINDOWProtect columns
DISP$Read display
GDISPDot graphics
GDISP$Read dots
BEEPTone
LCLowercase

Keyboard input

INPUTInput values
LINPUTInput a line
KEY$Key from buffer
KEYDOWNKey pressed?
PUTPush keys
USERUser keyboard

Data statements & files

DATAData constants
READRead DATA
RESTOREReset DATA pointer
CREATECreate data file
ASSIGN #Open / close channel
PRINT #Write to file
READ #Read from file
RESTORE #Reposition file

Formats

STDStandard format
FIXFixed format
SCIScientific
ENGEngineering

File Management

17

Catalog & copy

CATCatalog
CAT$Catalog entry
COPYCopy file
RENAMERename
PURGEDelete file
MERGEMerge lines

Protection

SECUREPrevent change
UNSECUREAllow change
PRIVATERun-only forever
PROTECTCard write-protect
UNPROTECTCard write-enable

Memory

MEMFree bytes
SHOW PORTPort sizes
FREE PORTIndependent RAM
CLAIM PORTReclaim
ADDR$File address
TRANSFORMChange type

Time & Date

11

Read

DATEDate number
DATE$Date string
TIMETime number
TIME$Time string

Set & adjust

SETDATESet date
SETTIMESet time
ADJABSShift clock
ADJUSTShift + correct
EXACTMark exact
AFAdjustment factor
RESET CLOCKClear correction

Customization & Keyboard

20

User keys

DEF KEYDefine key
KEYKey name forms
FETCH KEYEdit definition
KEYDEF$Read definition
KEY$Buffered key
KEYDOWNKey pressed
PUTPush keys
USERUser keyboard

Display & system

CHARSETAlternate chars
CHARSET$Read char set
CONTRASTContrast
DELAYOutput timing
WINDOWProtected fields
LCLowercase
LOCKLock keyboard
STARTUPPower-on command
DTH$ / HTDHex conversion
FIX / IMAGEsee Output
PEEK$ / POKEMemory access
ADDR$File address

System Settings & Flags

12

Flags

SFLAGSet flag
CFLAGClear flag
FLAGTest flag
RESETReset settings

Modes

DEFAULTExceptions
TRAPException trap
DEGREES / RADIANSAngle mode
OPTION ANGLEAngle mode
OPTION BASEArray base
OPTION ROUNDRounding
DELAYDisplay timing
IVL DVZ OVF UNF INXException flags

Emu71 Emulator Notes

host-side only — not part of the HP-71B

Emu71 — running the HP-71B on the Mac (Wine)

Install: ~/ide/HP71B/emu71/./emu71.sh starts run/EMU71.exe under Wine. First start: pick a KML skin (e.g. Christoph's Real HP71B for 1024x768) → OK. Emu71 emulates the real ROM (HP71B.ROM = 1BBBB, checksum-verified), so everything on these pages applies unchanged; the emulator adds only its Windows menu.

Emu71 menuUse
File → New / Open / Save (.e71)Emulator state = the calculator's whole memory. Save before quitting (or enable Settings → "Automatically Save Files On Exit").
Edit → Port Configuration…Plug modules: RAM (4/32 K…), ROMs from run/ (MATHROM.BIN, Hpilrom.bin, FORTHROM.BIN/HRDFORTH.BIN), HP-IL interface. Then SHOW PORT / CAT :PORT(n) on the 71.
Edit → Copy Stack / Paste StackCopy the display text to the clipboard · paste clipboard text into the command line (BASIC mode). Handy for single lines.
Edit → Reset Calculator · BackupCPU reset (then INIT: 1/2/3 as on the real machine) · snapshot / restore state.
File → Settings → Authentic Calculator SpeedUncheck for maximum speed (needed for fast macro replay).
Tools → Macro → Record / Play / Stop / SettingsKeyboard macro recorder — the way to "type" a whole program file into the 71.
View → Change KML ScriptOther skins incl. module-overlay backgrounds (kml-overlays).

Editing programs offline and loading them

Emu71 has no "load text file" command; instead a text listing is converted to a keystroke macro that Emu71 replays into the calculator (MK71MAC package, emu71/mk71mac/).

1. Write the program as plain ASCII in your editor: prog.basone program line per text line, LF line ends; ≤ 96 chars/line EDIT MYPROGfirst line: make/select the target file (or NAME it) 10 DISP "HELLO" @ BEEPnormal HP-71 lines; keywords may be lower case RUNoptionally finish with a command2. ~/ide/HP71B/emu71/bas2mac.sh prog.bas→ prog.mac (runs ASC71MAC.EXE via Wine; UTF-8 handled)3. Emu71: Tools → Macro → Play… choose prog.mackeys are typed into the running 71 (BASIC prompt, no program running)4. CAT MYPROG · LIST · RUNcheck; File → Save to keep it in the .e71 state
  • Every LF in the text presses END LINE; CR is ignored. Character set: printable ASCII 32–126 except \ | ~ and DEL. Use DIV instead of \.
  • Replay speed: Tools → Macro → Settings → Manual + slider; if keystrokes get lost, slow it down or untick "Authentic Calculator Speed".
  • Type errors on the 71 beep and leave the bad line un-entered — the rest continues. Check with LIST; the 71 keeps only what parsed.
  • Reverse direction: LIST and Edit → Copy Stack copies one display line at a time; for whole listings use PLIST to a virtual HP-IL printer (Emu71 virtual HP-IL over TCP/IP + ILPer/pyILPER) or TRANSFORM to TEXT and copy to a virtual LIF disk.
  • Larger workflow: virtual HP-IL (HP-IL ROM in a port + pyILPER on the Mac) gives a mass-storage drive — COPY MYPROG TO :TAPE, COPY :TAPE… exactly as with a real HP 82161A.

Sources: Emu71 v1.19 manual (emu71/emu71-bin/Emu71.htm), MK71MAC.TXT. Nothing in this box applies to a physical HP-71B.