You are on page 1of 12

A PocketComputer1

Sizing up the HP-41C


Bruce D Carbrey
704 Currituck Dr
Raleigh NC 27609

These days, the introduction of a new pocket calcula-


tor is usually greeted with a yawn. This is because calcu- The HP-41C has an array of features
lators have become so commonplace. So what's all the
excitement over the Hewlett-Packard HP-41C? The
that blurs the distinction between
answer is that the HP-41C has novel features that place it calculators and personal computers.
a cut above all other calculators and blur the distinction
between calculators and personal computers. Hewlett-
Packard, not usually given to wild claims, ventures to
suggest in the HP-41C Owner's Handbook and Program- ciators," which inform you of various calculator modes
ming Guide that the calculator "can even be called a per- currently active. For example, i( you select radian
sonal computing system." What are the features that measure instead of degrees for trigonometric functions ,
separate the HP-41C from the pack? "RAD" appears at the bottom of the display. There is
even a SHIFT annunciator that indicates when the shift
• twelve-character, true alphanumeric display key has been depressed.
• expandable, nonvolatile memory The keyboard is HP's usual very high-quality, thirty-
• plug-in peripherals: magnetic card reader, printer, five-key, tactile-feedback keyboard, augmented by four
read-only memory application packs, and a bar-code push-on-push-off mode-selection switches. With fifty-
reader nine displayable characters and 130 built-in functions, it
should be apparent that the thirty-nine keys have several
These, plus a host of convenience features, make this duties. In fact, each key is etched with three labels: its
calculator the most versatile machine ever. standard (unshifted) function, its shifted function (above
the key), and its alpha-mode function (on the bottom
Display and Keyboard sloping side of the key). Alpha-mode characters are
Perhaps at some time you have marveled at the in- enabled as long as the alpha-mode switch is set. The more
genuity of the person who discovered that, if you hold unusual alpha-mode characters (such as "r;," "%," "* ,"
your calculator upside down after entering 710.77345, it "$," etc) are selected by using the shift key in alpha mode.
will read "SHELL OIL". Well, you don't need to resort to To keep the keyboard reasonably uncluttered, this set of
tricks like that on the HP-41C, because the usual red special characters is not etched on the keys but appears in
seven-segment light-emitting diodes (LEDs) are gone. a pictorial layout on the back of the calculator.
They are replaced by a large, high-resolution black-on- Even with each key potentially performing quadruple
white liquid-crystal display (LCD) capable of displaying duty, there are simply not enough keys for all the func-
all twenty-six uppercase alphabetic characters, ten tions . To employ one of the more esoteric functions , you
numerals, and twenty-three other characters (see photo depress the execute (XEQ) button and spell the name of
1) . In addition, the display contains eleven "status annun- the desired function. For example, to compute 121 (12 fac-

244 December 1980 © BYTE Publications Inc


Circle 364 on inquiry card.

torial), you would key in:

1 2 XEQ ALPHA F A C T ALPHA


DISK DRIVE BONANZA BY aT
8" DISK DRIVES
If you happen to be heavily involved in statistics, you Shugart 801R Sgl / side Obi/Den $395.00
may find this a nuisance because FACT (the factorial Two for. . . . . . . . . . . . . . . . . . . $775.00
function) will be frequently needed. This is where the Qume Datatrak 8"dbl sided, dbl density.
"programmable keyboard" feature of the HP-41C comes OM E- 8DS (851R compatibl e) ........... . . $ 599.00
Pkg o f tw o ...... .. . .... ... . . $549.00 ea
in handy. You can assign or reassign any function to any
key you like by using the ASN function . For example:
QT DISK PACKAGES
ASN ALPHA F A C T ALPHA TAN lObi Den Controll e r. A & T . two 8" dbl den drives . CP / M '
2.2. cab in et. power supply & cables $1395.00
IT Two 801 R disk drives with cabinet. power supply
assigns the FACT function to the button normally used to & fan .. $1100.00
activate the tangent function. A push-on-push-off USER m Dual 8" Drives :
mode switch determines whether user-defined or stan- Obi den drives i n ca b inet on ly
2 sg l si ded (80 1R) $ 989.00
dard meanings are currently associated with the keys . If 2 dbl sided (OUM E) $1409.00
you forget what function you have assigned to a key, you
can find out by simply holding down the key. For our ex-
ample, holding down the TAN button will show "FACT" 5'1.' DRIVES
on the display while in user mode and ''TAN'' while in
normal mode. MPI-B5' M PI 8-51
5g1 Sided Sg l / Obl Den
. $250.00 MPI-B91 MPI 8-91 . . . ... $375 .00
S9! Sided , Ob i Den . 77 Tracks
User-programmed functions can also be assigned to Exa c t Replacement lor SA-400
PERTEC FO -200 PE R-FD200 ... . $225.00
MPI ' B52 MPI 8- 52 . . ....... 5350.00 5g 1 Sided . Sg l/ Dbl Den
keys , allowing the calculator to be customized to your Obi Sided . Obi Den
Shugart SA400 SHU-SA400 . . ... $250 .00
application. Two keyboard overlays with stick-on labels 5g1 Sided . Obi / Den

are provided for identification of user-defined keys.

~
COMPUTER
SYSTEMS WE ACCEPT MlC. VISA. AM EXP
INC . PLACE ORDERS TOLL FREE
1-800-4 21 -5150
15620 South Inglewood Ave . (CONTINENTAL U.S. ONLY)
Lawndale, California 90260 (EXCEPT CALIFORNIA)
(213) 970-0952 CP / M is a Irademark 01 Oigl1al Res ea rch

the electric P~!!,~.!l 111M


Jj~. for the TRS-80 Model II· Computer
d 'l.~
&
The Electr ic Pencil Is a Choracter Oriented Word P rocessing
Syst em. This means thol lexl is en t ered as (I continuous sIring
of c::ruaclers O'ld 15 manipulated os soch. This ollow$ the user
enormovs freedom (J"Id ease in the movement (J"Id hondti r.g of
l exl. Since lines ore no l delinea t ed, ony num ber o f thor·
octers, words, lines or paragraphs mer be inser t ed or deleted
anywhere in The lext . The enti rely o f lhe lex' shif ts O"ld
opens up or c loses as needed in full view of lhe vse r. CQr-
rioge rel urns as well as word hyphenation ore nol req ui red
since ooen line of l ext is forrTlolled Qu tomati ca lly.

As. teXT is typed Q1d the end of (I ~ r een line is reached, Q

partially comple ted word is shi ft ed 10 the beginning of the


following line. Wht.'f\cvcr lexl is inserTed or dele ted, exist ing
Icltl is pushed dow" or pulled up in (I wrop around fashion.
Everything appea rs M the video disp lay screen os il occurs
thereby eliminaling aly C}J(!sswork. TeXT may be reviewed at
'Nill by VQl'iable speed Ol" poge.at·o-lime scrolling bol h in the
farword end reverse di rec l iMs. By using the search or Ihe
search rnd replace function , any string of charac Te rs may be
100000ed cnd/or replaced wi t h my other sT ring of chorocters as
desired . Speci fi c SillS of charac ters within Meaded str ings
may a lso be loco ted,

When text is prin ted, The Elec: tri c Penci l outomaticall y


inserts c:orrioge returns where they are needed. Nume rous
CO'TIbino l ions of Line Lengt h, Page Length, C haracter Spacing,
LIne Spacing md Page Spacing allow for O"Iy form to be
hQ'ldled. Right justification gives ri ght. hond margi ns tho t
ore even . Pages may be numbered os well as ti lled.

the electric pendl


-~ Proyen Werll Prllt ~s\i ng SYll eru

The TRSDOS vl!rslons 01 The Electric Pencil II are our best


evu-! YOAJ c:on now type os fast os you like without losing aly
chcrocters. New TRSDOS fw tures include word le ft, word right, Features
word delete , ba ll orn of page numbering os well 0$ extended
cursor controls for greater vser lI eJCibiti t y. BASIC files may TRSDOS or CP/M Compatible · Supports Four Dhk
also be writ ten md simply edi ted without additional software. Drives · Dynamic P rinl Formatting · Diablo, NEC &
Q..rne Print Pockoges • Mulli·Colvmn Printing · Print
au- CP / M versions tre the some os we hove been dist ributing Value Chain ing • Poge . ot.a.l;m~ Sc ro ll ing •
lor several years md allow the CP/M user to edit CP/M files BidirecliO"lol Multispeed Scrolling • Subsystem Nith
with t he addition of our CONVERT uti lity for CJ'\ addi tional Print Value Scoreboard · Automotic Word & Record
S35.oo. CONVERT is not requi red if mly quick md t(lsy word Nl.mber Tolly · Globol Search & Replace· Full Morgin
Photo 1: The Hewlett-Packard HP-41C calculator. Each key on

-
proceuing is required. A keyboard bvff er permits fosl Iyping Conlrol • End of Page Con trol· Non Prin ti ng Text
CommenT ing • lin~ & Paragraph Indentatien •

-
withou t charac te r lou.
the HP-41 C has up to three labels associated with it: the label CP/M
Seria l Dioblo, NEC, Qume S 300.00
TRSDOS
S 350.00
Center i n g · Underlining · Boldroce

etched into the top face of the key, the label visible directly All ot he r printers ••••• S 275.00 S 325.00
VISA
above the key , and a letter of the alphabet (enabled by toggling The Elec t ric Pencil I is st ill ovoiloble for TR5.aO Model I
users . Although not as .sophisticated os Elec tr ic Pencil II, it
is stilt m extr emely easy to lISe md power ful word processing
the ALPHA button) etched into the bottom face of the key. system. The software hos been desi9"ed to be used wi th both
Level I (16K system) Q'ld Level II models of the TRS-SO. Two
Additional functions are called by hitting the XEQ button and
spelling out the function name. (Photo courtesy of Hewlett-
versiO"\S, one for use wilh cosselle, Qr'Id Qr'Ie for use wi th disk,
a re available Q'l cosselle . The TRS-aO disk version is cosily
transf e rred to disk md 15 fully Interactive with the READ , m MICHAel SHRAYER SOFTWARE. INC.
1198 Los Robles Dr .

Packard.)
WRITE, DIR , OI"Id KILL rout ines of TRSDOS.

TRC
TRD
Cassp,tw .•. , ••• S 100.00
Disk . . • • • • . . • S 150.00
5S Palm Springs. CA, 92262
(714) 323·1400

Circle 167 on Inquiry card . December 1980 © BYTE Publical ions tn c 245
To facilitate the entry of multiple-key sequences, the dresses or instruction lengths; instead, programs are
display provides prompting messages, and invalid keys entered on automatically numbered lines, as is done on
are disabled . In addition to the normal clear-display key, many microcomputer text editors. Lines may be freely in-
there is a backspace key to facilitate corrections. If you serted or deleted anywhere, with automatic renumbering
forget the name of a function (programmed or standard), of subsequent lines . Alphabetic labels of up to seven
depressing the CAT (catalog) key will list all functions characters can be used for tagging the destination of
currently known to the calculator. branches or for program, subroutine, and function
names. Also, any number of programs may be resident in
Memory memory, each uniquely indentified by an alphabetic
The HP-41C has continuous memory, which means name. Programs can be selectively edited, deleted, or
that the contents of memory are preserved even when the entered without affecting other programs.
calculator is turned off. You can even replace the bat- Best of all , the key codes displayed by other calculators
teries without destroying the contents of memory . The are gone, and are replaced by mnemonic instruction dis-
HP-41C's size-N throw-away batteries typically last 1 or plays. For example, if you examine an instruction for
2 months, instead of the 9 to 12 months claimed in the storing a number into register 15 on the Texas In-
documentation. A BAT annunciator warns you when struments TI-59, it is displayed on three separate lines as
you have only about 2 weeks' worth of life left in the bat- "42", "01", "05", where "42" is the TI-59's key code for
teries. The HP-41C can also be run using an AC adapter. the STO key. On the HP-41C, however, the same opera-
Not only are user programs saved in continuous tion is displayed on a single line as "STO 15". This im-
memory, but so is virtually everything relating to the provement is analogous to stepping up to assembly-
calculator: data, flags, user-key assignments, registers, language programming from machine-language, an ad-
and display formats. You can even set a flag so that, vantage that really speeds up program development and
when you turn on the calculator, it immediately con- checkout.
tinues executing a program from where it left off when Two powerful loop-control instructions have been
shut down! added to the function repertoire of the HP-41C: incre-
The standard calculator contains sixty-three registers ment and skip if greater (ISG), and decrement and skip if
of memory. Each register is 7 bytes long and can be used equal (DSE). These instructions allow a single register to
to store one number, up to six characters, or several pro- serve as a loop counter, increment value, and final value
gram steps. The total memory space can be partitioned simultaneously, by coding the number in the register in
into any combination of program and data storage, or it the form:
can be left at the default partition of seventeen data
registers and forty-six program registers. The instruction iiiii.fffcc
set contains eighty-six I-byte instructions, thirty-one
2-byte instructions, three 3-byte instructions, and one where iiiii is the current counter value, ftf is the final
4-byte instruction . Instructions with alphanumeric value , and cc is the increment. For example, the BASIC
operands such as LABEL, GOTO, etc, use 1 extra byte loop:
per character. In a typical mix of instructions, the HP-
41C can store about 200 lines of program code in the FOR I 1 TO 50 STEP 2
default forty-six registers of program space. An HP-41C
containing four optional expansion-memory modules
contains over 2.1 K bytes of continuous memory, capable
of storing an average of over 1300 program steps. NEXT I

Programming is programmed on the HP-41C as:


Programming is easier on the HP-41C than on any
other calculator. You need not be concerned with ad- 1.05002 iiiii = l,fff=050,cc= 2

IIIIIIIIIIIIIFII\ COMPUTERS OSI OUR


SAMPLE PRICES: RETAIL PRICE
CIP Series 2 8K RAM with 24 x 24 or 48 x 12 character display; sound,
music & voice ; 300 baud modem & printer port; expansion to color,
joysticks. AC remote & more . $479 $422

CIP MF Series 2 Same as above plus 20K RAM; real ·tlme clock, 90K
mini floppy & more . $1279 S1126

630 1/ 0 Expander Board (add to C1P or C1P MF) 16 color output; dual
8 axis joystick interface; home security interface; 16 line parallel li D;
programmable sound generator & more . $229 $202
CALL NOW • TOLL FREE
FARAGHER ASSOCIATES. INC.
1-800-558-0870 7635 W8LUEMOUND MILWAUKEE, WI 53213
HOURS: C.ST M-F 8-6 SAT, 9-1
MASTER CARD • VISA

246 December 1980 © BYTE Publicati ons In c Circle 168 on inquiry card .
TONE VALUE- 0 3 4 8

Figure 1: Musical notes on the HP-41C. The TONE function on the HP-41C produces one of ten musical notes that roughly corres-
pond to the notes presented in this figure.

STO 01 Store the loop-control number in which normal execution resumes. The data entry flags
register 01 can be tested to see if any keys were depressed during a
LBL 'TOPLOOP" Top of loop label pause; if so, the corresponding key indentifications,
which are stored in the display register, are available to
the program. This feature facilitates the programming of
games with real-time user responses .
ISG 01 Increment register 01 by 2, skip
next line if greater than 50 Let the Music Play
GTO 'TOPLOOP" Otherwise, repeat this loop The calculator can produce ten different audible tones
under keyboard or program control. I found the volume
The integer part (iiiii) of register 01 is incremented by 2 in level of the tones a little too low for my taste; it is barely
each pass until 51 is reached; the GTO is then skipped audible in a noisy office. After successfully programming
and the loop is exited at the bottom. "Mary Had a Little Lamb," I decided to tabulate which
A full complement of indirect operations (including in- musical notes are actually provided; the results are
direct subroutine calls) and register arithmetic are sup- presented in figure 1. Those with perfect pitch may find
ported. Subroutines may be nested up to 6 levels deep. the error in the frequencies of the notes a little annoying,
Ten different compare operations are available, including but the tones are close enough to produce recognizable
a test for character string equality. Fifty-five flags are music.
provided, some of which are predefined for controlling
calculator functions such as display format, mode of Documentation
operation, etc. One of life's little pleasures is reading Hewlett-Packard
There are eleven user-defined flags, five of which have documentation, which is among the best in the industry .
built-in status annunciators on the display . I found the It took me three evenings to finish the entire 268-page
flags with annunciators useful for monitoring program HP-41 C Owner's Handbook, working each example pro-
execution during debugging. Since running programs gram as I read . For me, the manual struck just the right
have complete control over the display format, it is easy balance between simplicity and comprehensiveness. My
to display several labeled numeric values on the display only complaint is that the text does not always make
at the same time. User-defined prompts for data entry are clear which functions are available on the keyboard and
also easily programmed. In fact, an executing program which must be spelled out. For instance, I spent several
can even turn the calculator off . minutes fruitlessly searching for the multiple-line-delete
(DEL) function shown in the example on page 138 as a
Error Detection key, only to conclude that it must be accessed by depress-
When a running program encounters an error condi- ing:
tion, the calculator displays an English error message.
Dividing .by 0, for instance, produces the diagnostic XEQ ALPHA DEL ALPHA
"OUT OF RANGE". If you depress the PROG key, the
display will show the exact line number and instruction A second manual, HP-41C Standard Applications
that caused the error. If desired, a flag can be set to ignore Handbook, gives ten sample programs ranging from
errors, or errors can be detected under program control hexadecimal conversions to a blackjack game. These pro-
for user-specified recovery. grams detail a wealth of programming techniques in-
Besides flags for various error conditions, there are cluding random-number generation, character-string con-
flags that detect whether the data entered is numeric or catenation and substring extraction, display formatting ,
alphabetic in nature . Since these flags are set only if data table lookup, etc. In addition, a year's free membership
is entered, they can be used in conjunction with the to Keynotes , the HP calculator newsletter, is included
PAUSE function to poll the keyboard during program ex- with your purchase.
ecution to see if a key has been depressed . The PAUSE in- Membership in a user's library group is available on a
struction activates the keyboard for about 1 second, after subscription basis for $20 per year. This subscription en-

248 Dece mb er 1980 © BYTE Publicatio ns Inc


titles you to a catalog of contributed programs, updates
to the catalog, and a coupon good for four free programs
of your choice, distributed on magnetic cards. Additional
programs are $6 each. You may submit programs to the
library in return for four free programs from the library.

Expansion
One of the most exciting aspects of the HP-41C is the
array of available peripheral devices, including:

• a twenty-four-column thermal printer


• an attachable magnetic card reader/writer
• application packs in read-only memory
• continuous-memory expansion modules
• bar-code program reader

Several of these accessories are shown in photo 2.


The 82143A battery-powered thermal printer produces
127 characters, including all uppercase and lowercase
letters, in either single width (twenty-four characters per
line) or double width (twelve characters per line) . (See
photo 3 for an example of printer output.) In addition,
user-defined characters may be defined within a 7 by 7
dot matrix. Simple printer-plots are supported. The
printer can also be used to trace program execution dur-
Photo 2: The HP-41C and accessories. Clockwise from top are: ing debugging.
the 82143A peripheral printer, a key overlay (for use when
The 82104A magnetic card reader is similar to the
redefining key functions), the HP-41C with the 82104A plug-in
card reader, two magnetic cards, and three read-only-memory
built-in unit on the HP-67 and HP-97 and is compatible
application packs. In the center is the 82153A bar-code wand, with cards produced on these machines. Up to sixteen
which is used to read software printed in the form of bar codes. registers can be stored on each side of a card; the calcula-
(Photo courtesy of Hewlett-Packard.) tor prompts you to enter as many cards as needed. Pro-
grams, data flags, and even key reassignments can also be
saved on the cards. For the security-minded, programs
can be designated as execute-only, in which case an at-
6809' )-100 iJIIsTM tempt to display or alter the program will result in the
display of the message, "PRIVATE."
SINGLE BOARD COMPUTER Plug-in application packs (useful routines stored in
• MEETS I.E.E.E. S-100 STANDARD read-only memory modules) are available in disciplines
r::,o:. • 10 addressing modes such as aviation, medicine, surveying, finance, stress
'0'0 • 24 indexed sub modes analysis, etc. Programs in these applications modules can
~0 • auto incrernentl decrement be copied into continuous memory, if desired, for
• constant indexing fro_m PC customizing by the user.
• 4K/8K/16K ROM • 2K RAM For large programs, from one to four 82106A con-
ROM I RAM relocatagi,e on 4K boundary tinuous memory modules may be plugged in to extend
• ACIA; PIA; 8080 SI'M.ULATED
___ d 1/0 the built-in memory from the standard 63 to a maximum
of 319 registers, in 64-register increments. The extended
• 20 PARALLEL I/O !-I!'LES. 256 I/O PORTS
memory can be partitioned between program and data
ACIA provides RS-232.. tines for asychronous com-
munications with limited modem control at 8 select- storage and is continuous, just like the memory supplied
with the standard HP-41C.
able baud rates; I/O locafable at any 4K boundary
An accessory just recently made available is a wand
P.C . Board & Manual $69.95 that is used to read bar-codes similar to the kind found on
with Monitor $99.95 most grocery products. This will enable users to load pro-
• ASSEMBLED & TESTED WITH 2K RAM grams directly from HP-41C Solution Books to be pub-
& MONITOR $349.50 lished by Hewlett-Packard, which will use bar-code list-
• adsMON: ADS MONITOR ings of programs to supplement the usual step-by-step
Examine and change registers and memory; punch keystroke listings. An HP-41C user with a bar-code wand
and load in Motorola format; user definable inter- will be able to enter these programs by running the wand
rupt service and more across the bar-code listing, eliminating the tedium and er-
$39.95 in 2716 EPROM ror associated with manually entering a program.
MasterChargelVISA Accepted
Illinois residents add sales tax Add 2.5% for shipping The Great Calculator Race
Ackerman Digit!l!Systems, Inc. A strong contender for the programmable calculator
110 N . York Rd., Suite 208, Elmhurst, lll. 60126 (312) 530-8992 market is the Texas Instruments TI-59 , which sells for less
money than the Hewlett-Packard machine and includes a

250 December 1980 © BYTE Publications Inc Circle 171 on inquiry card.
standard magnetic card reader and larger standard calculators. I programmed both calculators in the same
memory (960 bytes, as opposed to 441 bytes on a stan- manner, deliberately trying to avoid "trick" program-
dard HP-41C). (Price information for the Hewlett- ming but taking advantage of each machine's strengths
Packard machine is given at the end of this article .) Of where possible (such as short-form addressing on the
course, it doesn't have an alphanumeric display or con- TI-S9 and stack manipulation on the HP-41C).
tinuous memory; still, it is an attractive alternative to the The programs for the HP-41C and the TI-S9 are in
HP-41C. listings 1 and 2, respectively. Although I expected the
I decided to run a small benchmark test to compare HP-41C to run slower since it uses ultra-low-power
speed and memory usage on both machines. Conducting technology , both calculators took about the same
proper benchmark tests is an involved and time- amount of time to execute the benchmark. The HP-41C
consuming process. Instead, I settled for one represen- program uses less memory space, but of course it has
tative test that should be adequate for at least rough com- only about half as much memory available in its standard
parison. I programmed both the HP-41C and the TI-S9 to configuration.
compute the present value of a bond with "periodic
coupons, " as given by the formula:
N
P=IE(l+ yr +M(l+ yr
J N
Listing 1: HP-41C benchmark program to calculate the present
J=l v alue of a bond with "pe riodic co upons." This problem ,
desc ribed in th e text, w as used as a ben chm ark program against
where : the Texas Instrumen ts TJ-59 because it uses both arithmetic
calculations and program loo ping. Th e TI-59 ben chmark pro-
gram is given in listing 2, and the results of th e comparison are
P present value
given in table 1.
I coupon value HP-41C program steps often consist of multiple keystrokes;
N number of periods each step is shown in this listing as it appears in th e calculator's
M maturity value disp lay after entry , w ith one exceptio n: characters en tered in
Y yield rate, in percent alphabetic m ode on th e calculator are shown here en closed in
quotes. O n th e calculator's display the quotes do not appea r,
I picked this example because it requires a mix of bu t the characters are preceded by a superscript "T il.
arithmetic, looping, and register operations; I intuitively
felt that this mixture is representative of the operations REGISTERS
performed in many of the problems suitable for pocket
R, M, maturity value
R, N, number of periods
and J, loop index
RJ I , coupon value
1 + Y, where Y is yield
GREAT R.
rate as decimal fraction

FOR LINE PROGRAM STEP COMMENTS

01 LBL "BOND"
XMAS 02
03
FIX 2
STO 01
Set dollars and cents format
SAVE M in 01
04 STOP Input N
05 STO 02 Save N in reg 02
06 STOP Input I
07 STO 03 Save I in reg 03
08 STOP Input Y
09 100
10 / Convert to decimal fraction
ATTACH E STYL E CAS ES FOR CARRY ING AND PROT ECT ING A COM· II 1
PLETE COM PUTER SET-UP . CONSTRUCTED OF THE HIGHEST OUALITY
LUGGAGE MAT ERIAL WITH SADDLE STITCHING W ILL ACCOMMODATE
12 +
EQUIPMENT IN A FULLY OPERAT IONAL CONFIGURATION ALONG WITH
13 STO 04 Save 0 + YJ in reg 04
MANUALS . WORK ING PA PE RS AND D ISKS . NEVER A NEED TO REM OV E 14 RCL 02
EQUIPMENT FROM CASE . SIM PLY REMOVE LID . CONNECT POWER AND 15 CHS
OPERATE . LID CAN BE REPLACED AND LOCKED FOR SECUR ITY AND
PROTECT ION W IT H OUT D ISCO N NECTING CABLES FULLY TESTED
16 Y/X o + yr N

17 RCL 01
18 M* O + N
yr
• AP101S Apple and Single Disk Drive .................... .... .... .... ...... Sl09 19 0 Initialize sum to 0
• AP 102D Apple and Double Disk Drive ... ............ ... .. .... .. .. .......... 119 20 LB L 01 Top of summation loop
• AP103M Apple , 9 inch Monitor and Double Drive ....... ............ 129 21 RCL 04 (l + YJ
• RS201 TRS-80 , Expansion Unit and Double Drive .. ..... .... ....... 109 22 RC L 02 J
• RS202 TRS-80 Monitor and Accessories .... .. ..... ....... ...... ............. 84 23 CHS - J


P401 Paper Tiger Printer ....... .... .. ... ...... ... ..... ..... ............................ 99
P402 Line Printer Ii-Centronics 730 ..... ...... ................. ............. .... 89
24 Y/X o+ yr J

• CC90 Matching Attache Case ................. .......•... ........ ........ .......... 7S


25 + New summation
26 DSE 02 J= J - 1. ..
27 GTOOI .. . Unti l J = 0
C~MPUTER CRSE C~MPR NY 28 RCL 03 Then recall I
5650 INDIANA MOU N D CT COLU MB US OHIO -1 3213 29 Times summation
161 J I 868·9<1 6·1 30 + Plus second term = result, P
31 END

2S2 December 1980 © BYTE Publications Inc Circle 173 on inquiry card .
Listing 2: Texas Instruments TJ-59 benchmark program to 056 43 RCL
calculate the present value of a bond with "periodic coupons. " 057 06 6 Plus first term .. .
Th e results of the comparison with the HP-41C are given in 058 95 Result is P
table 1. 059 91 RIS
060 00

REGISTERS

RI M, maturity value
R, N, number of periods, A subjective conclusion I drew after programming
and L loop index both calculators is that the HP-41C is much easier to pro-
RJ I, coupo n value gram and debug because of its line-oriented, mnemonic
R, 1 + Y, where Y is yield display. The results of this comparison are given in table
rate as decimal fraction
R. scratch register for 1.
summation
Sample Program: Codebreaker
DISPLAY KEY Because I am a games enthusiast, I decided to write a
LINE CODE ENTRY COMMENTS game program as an example of an HP-41C program. I
programmed a variation of the popular "codebreaker"
000 76 LBL type games, where the calculator generates a random
00 1 11 A
002 58 FIX Set dollars and cents format code and the player attempts to guess the code . The
003 02 2 flowchart for this program is given in figure 2.
004 42 · STO To begin, the player first decides on the number of
005 01 1 Save M in reg 01 digits for the code, from three to five digits. Assume that
006 91 RIS Input N
007 42 STO a three-digit game is chosen. The calculator will then
008 02 2 Save N in reg 02 secretly pick a three-digit number with no two digits the
009 91 RIS Input I same. The user then enters a three-digit guess.
010 42 STO After evaluating the guess, the calculator displays the
011 03 3 Save I in reg 03
number of digits that are exactly right and the number of
0 12 91 RIS Input Y
013 55 I digits that exist in the true code but are not in the proper
014 01 1 Convert to decimal fraction position. For example, if the secret code is 108 and 802 is
015 00 o the guess, the display will show:
016 00 o
017 85 + 802 RT:1 MP:1
018 01 1
019 95
020 42 STO indicating one entirely right (RT) digit (the 0) and one
021 04 4 Save (1 + Y) in reg 04 misplaced (MP) digit (the 8).
022 45 yx o + y)"N ... The user continues guessing until the correct answer is
023 43 RCL
Text continued on page 258
024 02 2
025 94 +1-
026 65 x
027 43 RCL
028 01 1 TI-59 H P-41 C
029 95
030 42 STO Number of data registers used 5 4
031 05 5 Save MOO + y)" N Program size (as displayed) 59 lines 31 lines
032 25 C LR Program size (internal representation) 59 steps 41 bytes
033 42 STO Total memory used/total memory 99/960 69/441 (69/2233)
034 06 6 Percentage of total memory used 10.3 15.6 (3.0)
Execution time , seconds 43 37
035 76 LBL
036 44 SUM Top of summation loop Benchmark equation programmed :
037 43 RCL
038 04 4
yX
p = /
N
E (1 + yr J
+ M(1 + yr N

039 45 J=1
040 43 RCL
041 02 2 Data used:
042 94 +1- -J M = 20 ,000 , N = 50 , / = 1400, Y = 8%
043 95 o + yr J

044 44 SUM New summation Answer: P = 17,533.30


045 06 6
046 97 DSZ J=J-1... Table 1: Results of the HP-41CI TJ-59 benchmark. The pro-
047 02 2
grams of listings 1 and 2 are the basis of the data given
048 44 SUM ... Until J = 0
049 43 RCL above. The difference between the two program-size figures
050 03 3 Then recall I for the HP-41C is due to the fact that it combines several pro-
051 49 PRO gram steps into an assembly-language-like instruction when
052 06 6 Times summation displaying it. The figures in parentheses refer to the HP-41C
053 43 RCL filled with its maximum amount of memory; the figures just
054 05 5 2nd term before them refer to the HP-41C as purchased.
055 85 +

254 December 1980 © BYTE Publications Inc


COMPARE NEXT
GUESS DIGIT
TO
CORRESPONDING
ACTUAL DIGIT
( START

IN PUT
DESIRED
NUMBER
DIGITS, P ~ SAME
.?

NO
YE S INCREMENT
# RIGHT
COUNT, RT

J
ALL
INITIALIZE NO P DIGITS
LOOP TRIED
?

YES

PICK FI RST YES DISPLAY


RT'P GUESS,
RANDOM
DIGI T, R ~ # OF GUESSES
NO
j 1
INITIALIZE
( END

LOOP
SAVE NEW
RANDOM
DIGIT, R

GET NEXT
GUESS DIGIT,
D
PICK NEW
RANDOM
DIGIT, R
J
1
IS GET NEXT
YES R SAME
AS ANY SAVED ACTUAL
DIGIT DIGIT, A
?

<)
NO

ARE INCREMENT
NO ALL P YES
DIGITS # MISPLACED
SA~ED DIGITS, MP

YES NO

I
INITIALIZE
ALL
NO P DIGITS
TRIED
~
YES

INCREMENT ALL
NO P DIG ITS
GUESS
COU N TE R TRIED
?

YES

INPUT NEW CORRECT FOR


GUESS AND DUPLICATIONS;
VALIDATE MP'MP-RT

DISPLAY
INITIALIZE GUES S,
LOOP RT, MP

Figure 2: Flowchart for the HP-41C Codebreaker game . Listing 3 gives the HP-41C keystrokes for the equivalent program.

256 December 19BO © BYTE Publications Inc


Circle 146 on inquiry card.

I nt roduc in-=:;!
the
SYSiBffiS,

Hie. 82143R
• Quantity Discounts
Available
THE HP-41C's
• 9O-day Warranty
• Ask about our unique WHISPER QUIET PRINTER,
"Guaranteed Custom
Programming"
ZENITH DATA SYSTEMS
UST OUR PRICE
Z89 MICROCOMPUTER SYSTEM ... .. . . $2,895 $2,495
48KB Memory KEY FERTURES
Z19 Video Terminal (24 x 80)
2 Serial EIA ports
Single 5" Diskette Drive
Z19 Smart Video Terminal .. . . SPECIAL . $ 950 $ 795
24 lines x 80 col
Reverse Video
Numeric keypad 127 STANDARD CHARACTERS
HDOS Operating System (with BASIC) . .. . $ 150 $ 145
Microsoft Basic ........................ . $ 150 $ 145
Word Processing for Z89 System ...... . .. . $ 395 $ 375
SINGLE WIDTH
Dual 5" Diskette Drive for Z89 Syst em ... . $1,195 $1,095 DOUBLE WIDTH
To Order: Send Check or Money Order to: PK Systems, Inc., ll3 North UPPER CASE
Center, Bloomington, IL 6170l. Allow two weeks for personal c hecks to
clear. For COD Orders, add 5% for handling and service charge . Rush lower case
orders, add $50.00
Shipping: Freight collect, FOB Bloomington. We ship UPS, air freight, or
motor freight.
PK Systems is an Authorized
Service Center.
,:$..
_ -.: 51 r'Yt1 !:, ,, "]1
Dealer and Zenith

SPECIAL CHARACTER
CAPABILITIES
Photo 3: Sample thermal printer output. The 82143A peripheral
printer is capable of printing both uppercase and lowercase
letters, as well as numbers, symbols, and user-defined special
characters, all in two print densities . The printer can also be
used for program tracing or equation plotting. (Print sample
courtesy of Hewlett-Packard.)

Text continued from page 254:


obtained; the number of guesses made is then displayed
and the game is over. Since the game displays results
from only the most recent guess, pencil and paper are
good accessories for keeping track of previous guesses
and results.

Examining the Program


Several interesting capabilities of the HP-41C are ex-
plored in this program (see listing 3). Line 02 places a text
string into the alphanumeric display register, which holds
from zero to twenty-four characters. Line 03 causes the
register's prompting message to be displayed and halts for
user input. Lines 04 thru 11 validate the user input and
save the desired number of digits, P, in register 00.
Lines 12 and 13 initialize the display format as integer
only with no decimal point displayed. Lines 14 thru 16
tell the player how many random digits will be picked.
Line 17 is a call to subroutine ROlG, which returns a ran-
dom digit, 0 to 9; I used the random-number generator
described in the HP-41 C Standard Applications Hand-
book.
Text continued on· page 262

258 December 1980 © BYTE Publications Inc Circle 186 on inquiry card.
Listing 3: HP-41C Codebreaker game program. This program choQses a random 3- to 5-digit number with nonrepeating digits and
gives the player clues about the code, based on the player's guesses. This listing uses the same conventions as listing 1.

REGISTERS 52 STO 06 Save guess in format O.ddddd


53 0
Ro Number of digits (positions) to play, P, 3 ~ P ~ 5 54 STO 09 Initialize count of "right" digits
RI First digit of actual code number 55 STO 10 Initiali ze count of "misplaced" digits
R, Second digit of actual code number 56 I
R, Third digit of actual code number 57 ST + 12 Increment guess counter
R, Optional fourth digit of actual code number 58 RCL 00
R, Optional fifth digit of actual code number 59 STO 07 P
R, Current user guess, normalized to O.ddddd format 60 LBL 05
R, Scratch for loop control 61 RCL IND 07 Actual code digit
R, Scratch for indirect register access, loop control 62 XEQ "GDIG" Get digit from user's guess
R, Number of exactly right (RT) digits in current user guess 63 X*Y? Compare corresponding actual digit
RIO Number of misplaced (MP) digits in current user guess 64 GT006
RII Seed for random number generator 65 I
RI2 Count of number of guesses made by user 66 ST+ 09 If match, increment right count
67 LBL 06
68 DSE 07 Repeat for all P digits
LINE PROGRAM STEP COMMENTS 69 GTO 05
70 RCL 09
01 LBL "MM" Program name 71 RCL 00
02 "NO. DIGITS?" 72 X=Y? If number right = P ...
03 PROMPT Prompt user to enter no. of digits, 3 to 5 73 GTO 14 .. .exit, game over
04 STO 00 Save P places requested 74 STO 07 Else set up for " misplaced" counting
05 3 75 LBL 07
06 X>Y? 76 RCL 00 P
07 GTO "MM" If less than 3 places, re-prompt 77 STO 08 Set up inner loop count
08 RDN 78 XEQ "GDIG" Get digit from user guess
09 5 79 ENTER/
10 X<Y? 80 LBL 08
II GTO "MM" If P greater than 5, re-prompt 81 RDN Recall guess digit
12 FIX 0 Show no fractional part in display 82 RCL IND 08 Digit from actual number
13 CF 29 Suppress display of decimal point 83 X*Y?
14 "1M PICKING" 84 GTO 09
15 ARCL 00 85 I
16 AVIEW Tell user how many random digits 86 ST + 10 If same, increment "misplaced" count
17 XEQ "RDIG" Get first random digit, 0 to 9 87 LBL 09
18 RCL 00 Recall no. of places, P, 3 to 5 88 DSE 08 Repeat for P positions, inner loop
19 1000 89 GTO 08
20 / 90 DSE 07 Repeat for P positions, outer loop
21 I 91 GTO 07
22 + 92 RCL 09
23 STO 07 Set up loop control in form I .OOP 93 ST- 10 Correct "misplaced" count is (MP - RT)
24 LBL 01 94 XEQ "SHOG" Show guess in display
25 RDN 95 "f- RT:"
26 STO IND 07 Store new digit in array 96 ARCL 09 Show no. of digits exactly right, RT
27 LBL 02 97 "f- MP:"
28 XEQ "RDIG" Get candidate random digit, 0 to 9 98 ARCL 10 Also show number "misplaced," MP
29 RCL 07 99 GT004 Go get new guess
30 INT 100 LBL 14 Come here on end-of-game only
31 STO 08 Last position filled 101 XEQ "SHOG" Show correct guess
32
33
LBL 03
RDN Recall candidate
102 "r. "
103 ARCLI2 Show count of guesses used
34 RCL IND 08 Recall existing digit 104 "f- TRIES"
35 X = Y? If candidate is same as existing digit ... 105 AVIEW
36 GT002 ... then go get a different random digit 106 BEEP Ring the bell to celebrate
37 DSE 08 Else check next existing digit ... 107 RTN End program.
38 GTO 03 .. . until all existing digits checked 108 LBL "SHOG" Subroutine to display guess
39 ISG 07 Then fill next position with candidate ... 109 RCL 00 Recall P
40 GTO 01 .. . until all P pOSitions filled 110 STO 08 Number of digits to display
41 0 III CLA
42 STO 12 Initialize count of guesses made 112 RCL 06 Recall normalized guess, O.ddddd
43 "GUESS?" 113 LBL 12
44 LBL 04 114 10
45 PROMPT Get P-digit user guess 115 Shift out next digit
46 10 116 ENTER/ Save on stack
47 RCL 00 117 INT Discard fraction
48 Y/X 10' ll8 10
49 X< =Y? If guess greater than P digits ... ll9 MOD Get units place only, 0 to 9
50 GTO 04 ... then go get legal guess 120 ARCL X Display digit
51 / Else normalize valid guess Listing 3 continued on page 262

260 December 1980 © BYTE Publications Inc


Listing 3 continued: the loop is on lines 39 and 40, with line 39 incrementing
121 RDN Recall shifted guess register 07 until it reaches 3.
122 DSE 08 Repeat till all P digits displayed Register 07 is used inside the loop as the subscript for
123 G TO 12
124 RTN Return from subroutine an array of size P in registers 01 thru P, each to contain
125 LBL "GDIG" Subroutine to return I digit of guess one digit of the code number. An inner loop, controlled
126 RCL 06 by register 08, compares all previously selected digits to
127 10 the new candidate digit, and rejects any duplications. The
128 RCL 07 Register 07 = desired position in guess
logic of this code selection segment of the program can be
129 Y/X
130 illustrated by its BASIC equivalent:
131 INT
132 10 10 OEF FNR = INT(RNO*10)
133 MOD
134 RTN Return from subroutine
135 LBL "RDIG" Come here to get random digit, 0 to 9
136 RCL II Seed
137 9821 100 0 = FNR
138 110 FOR I = 1 TO P
139 .211327
140 +
120 N(I) = 0
141 FRC New random seed, 0 to I 130 0 = FNR
142 STO I I 140 FOR J = 1 TO I
143 10 150 IF N (J) = 0 THEN 130
144 160 NEXT J
145 INT
146 RTN Return from subroutine, digit on top of stack 170 NEXT I
147 END
After the code is selected, the user's guess is entered.
Text continued from page 258: Each user guess is stored in register 06 in a normalized
The most interesting part of the program is contained format obtained by dividing the guess by lOP. For exam-
in lines 18 thru 40, which consist of two nested loops for ple, a guess of 012 would be stored as .012 in a three-digit
selecting P random digits with no two digits the same. game; a guess of 30987 would be stored as .30987 in a
Lines 18 thru 23 initialize the outer loop control five-digit game. This format is used so that function
parameters in register 07. For example, if three digits are GOIG (line 125) can extract the Ith digit, D, from the
1
desired, register 07 will be initialized to 1.003. The end of guess, G, by calculating D = MOD lo (INT (G X 10 )).
The balance of the program is fairly straightforward.
Lines 94 thru 98 illustrate how to simultaneously display
five individual numbers and two alphanumeric character
MAIL ORDER DISCOUNTS strings. Note that subroutine SHOG (line 108) displays
each digit of user's guess individually; otherwise, a guess
with a leading zero would not show the zero because of
the automatic leading-zero suppression of the calculator.
APPLE II PLUS 18K
Conclusion
I found the HP-41C far more pleasurable to program
$945
APPLE II PLUS 32K $995
and use than its predecessors, primarily because of the
alphanumeric display capabilities. The list prices of the
APPLE II PLUS 48K $1,059 HP-41C and its accessories are as follows:
ACCESSORIES HP-41C programmable calculator (with
DISK II DRIVE & CONTROl lER (DOS 3.3). .525 MI CROSOFT Z·80 SO FT CARD SYSTEM . 290
DISK II DR IVE ONl Y . . . . 420 VIDEX 80 COLUMN BOARD 63-register memory) $295
INTEGER BASIC FIRMWARE CARD . . _149 WIGRAPH ICS ANO SWITCH . 350
APPlESOFT II FIRMWARE CARD
M &A SUR·R·MOO RF MODULATOR .
. 149
25
DC HAYES MICROMQOEM II . .
SILENTYPE PAINTER W/lNT . CARD .
. . 315
. .... 510
82106A 64-register Memory Module 45
CENTRON ICS PRINTER INTEAFACE CARD lS5 LANGUAGE SYSTEM W/PASCAL . . .. . 420 Application Pacs, each 45 to 70
HIGH-SPEED SER IAL INTERFACE CARD .. 145 GRAP HI CS TABLET . 650
LEEDEX VIDEO 100 12" B&W MONITOR . 129 ALF MU SlC SYNTHESIZER . . . . 235 82143A Peripheral Printer 350
SOFTWARE 82104A Plug-in Card Reader 195
APPLE FORTRI-.N . ... 165 THE CONTROLLER BUSINESS SYSTEM . . 515
0053 .3 . . 49
65
THE CASH IER RETAIL MANAGEMENT ..... 199
VIS ICALC 120
82153A Wand 125
APPL E DOS TOOL KIT .
APPLEPLOT GRAPH & PLOT SYSTEM 60
85
APPLEWR IT ER TEXT EDITOR .
BASF 51/4 DISKETTE (10) ..
65
30
HP-41C Solution Books 12.50
CCA DATA MANAGEMENT . ff

82045A Thermal Paper (box of six rolls) 6


• WE WILL TRY TO BEAT ANY ADVERTISED PRICE 82120A Rechargeable Battery Pack 40
• WE PERFORM APPLE WARRANTY REPAIR

TO ORDER: Please phone using VISA and Master Card. Or send cash ier's check, I am able to find discounts of about 15 % off the list
money order or personal check (allow 14 business days to clear). VISA and Me
credit card service add 2%. Shipping, handling and insurance add 3%. California price in my area . Larger discounts can be expected with
residents add 6% sales tax .
ORDER HOURS: Monday thru Saturday 9·5 PST.
the passage of time . The HP-41C is manufactured by
Hewlett-Packard Co, Corvallis Division, 1000 NE Circle
computc:!r aga.lnc. Blvd, Corvallis OR 97330.
Authorized Apple Dealer & Service Center
Is the HP-41C a pocket computer? Well, maybe not
4688 CONVOY ST. , SUITE 105, SAN DIEGO , CA 92111 (714) 565-4042 quite-but what will the next generation of calculators be
like?

262 December 1980 © BYTE Pub lications Inc Circle 177 on inquiry card.

You might also like