hewlett-packard creatingyourown hp-41barcodeintroduction the objective of this manualis 1o provide a...
TRANSCRIPT
HEWLETT-PACKARD
Creating Your OwnHP-41 Bar Code
MANUAL
A eadicano
Creating Your OwnHP-41 Bar Code
Manual
March 1981
82153-90019
Printed in U.S.A. © Hewlett-Packard Company, 1981
Contents
Inreduction ... .o e 5
Section 1: Description of Bar Code Types 7Program Bar COde .................. 7Direct Execution (Complete Functlon) Bar Code 8Data Bar Code .. 9
Standard Data 9Sequenced Data .. 10
Paper Keyboard Bar C 11
Section 2: Physical Specifications 13
Size and Shape ............ 13 Paper and Ink Considerations .
Section 3: Sample Software ......Generating Program Type Bar CodePRGMBR Syntax ...PRGMBR Program Li
Generating Other Bar Code TypesFULFCN Syntax ......FULFCN Program Listing
Section 4: Algorithms .. TRChecksum Algorithms
Eight-bit (One byte) ChecksumFour-bit Checksum .......
Program Bar Code Algorithms .Labels ..ExecuteGo To ..Store and Recall ...Alpha Text Strings . .End ...........Header Algorithms .
Other Bar Code AlgorithmsDirect Execution (Complete Function Code) Algorithms.Numeric Data Functions .Alpha Data Functions..
Appendix A: Flowcharts
PRGMBRFULFCN
Appendix B: HP-85A Adaptations of PRGMBR and FULFCN . 67
PRGMBR . 68FULFCN .. .75
Contents 3
Figures1 Program Typs Bar Code .. 82 Direct Execution Type Bar Code 83 Numeric Data Type Bar Gode 94 Alpha Data Type Bar Code .. 95 Sequenced Data Bar Gode (Rev. F and Following) 108 Configuration of HP-41 Bar Code ...... 137 20-Mil Bar Code Having Excessive Stroke-width Error 148 Preferred Wand Orientation . 159 Different Module Width BarCt 16
Tables
| Bar Size Specifications ...Il Commands for Program “PRGMBR” .Il HP-41 FunctionTable ............ .IV Numeric Values for A-J, a-e, and The StackV. HP-82143A Printer Character Set
Introduction
The objective of this manual is 1o provide a technical base for generating HP-41 bar code, that is, the information
necessary for you to develop your own bar codeprinting capability tailored to your specific computer-printer/plotter
system.
The minimum system needed is as simple as a minicomputer with a plotter or a printer. An example system would be an
HP 85A Personal Computer using an HP 7225A Plotter or an HP 2631G dot matrix printer.
Auny mini (or larger) computer with a BASIC compiler that has 16K bytes of user memory will be able 1o compile andrun, with modifications for specific BASIC implementations, the sample software listed in this manual. The input
needed to generatethe desired bar code for an HP-41 program listing and/or HP-41 functions can be entered through a
terminal. As an alternative input method, the generation program may be altered to accept punched cards or paper
tape.
1f you usea plotter it must be ableto create solid, dense linesat least .015 " in width for a narrow bar and atleast .030"
in width for a wide bar. Alphanumeric capability is also desirable but not necessary.
The software provided in the main body of this manual was written in HP-9845A BASIC, and was used to print bar
code on a Diablo 1650 Daisy Wheel Printer with a ““Titan 10”” 96-character wheel. Appendix A contains flow charts for
these programs, and’ Appendix B contains the listings of the same programs adapted into HP-85A BASIC. A com-
parison of the differences between the HP-9845A and HP-85A BASICs may help you with your custom adaptations.
6 Introduction
You probably will havea different hardware configuration than was used 1o produce the two programsin this manual.
In that case you will not only have to adapt the language used but also it will be necessary to rewrite the sections that
actually print the bar code. For PRGMBR thesections that deal with the actual printing begin on line 1650 and line
4460; for FULFCN that section begins on line 5760.
You may find that at sometime you will need a higher guality bar code than your system can produce. If this situation
arisesit is reccommended that you contact:
George Lithograph
620 Second Street
San Francisco, CA 94107
(415) 397-2400
Section 1
Description of Bar Code Types
There are four categories of bar code used by the HP-4) and HP-82153A Wand:
@ Program Bar Code
@ Direct Execution Bar Code (Complete Key Phrases)
& Data Bar Code
® Paper Keyboard Bar Code {Individual Keystrokes)
Every bar code row has overhead (header) information includedin the left-most positions. This header provides the
meansforerror checking and signals the HP-41 asto which type of code the Wand isreading. A header can be as short
as 4 bits (single byte Paper Keyboard), oras long as 24 bits (program and sequential data). In thissection the physical
makeup ofeach type is outlined.
Every row also has two start bars at the beginning of the bar code row, and two stop barsat the end of the row. These
are used by thecircuitry within the wand module to determine scan direction. These start and stop bars are not included
in the figures for this section, but you must be sure to include them in your finished bar code row.
Program Bar Code
Program type bar code contains the necessary information to load program steps into the HP-41’s memory. Each row
contains the actual program steps, preceded by a three-byte header.
IIIII||Il||||IIIIl|||II|HI||II|||II|||I|||IIIII||II|||||||||I|I|||||||I||I||IIIIIII||l||IIII||IIIII|||||IIIIIIIIIIIIIII|III|I||I|I|IlHEADER PROGRAM INFORMATION
START sTopBARS BARS
You have the optionto make your program bar code privateif you wish. The HP-41 and the wand can work togetherto
provide a security system that will preventaccidentalalteration or reproduction of important programs.If 2 program is
made “‘private” in bar code, when it is read into the HP-41, it cannot be viewed,altered,or reproduced through normal
operations.
& Description of Bar Code Types
Inevery Program bar code row, thefirst field in the header contains the checksum. This is a running eight-bit sumwith
end-around carry of the current row and all preceding rows. The second field, containing the next four bits in the
header, indicates the type of program; non-private or private. If the field is set to ‘1,the program is non-private; if
thefield is set to *‘2” the program is private. Thethird field which specifies the row sequence number (modulo 16),is
four-bits wide. This field triggers an error message in the HP-41 if a row of Program bar code is scanned out ofse-
quence. The fourth field, which contains four bits, specifies the number ofbytes at the beginning of the current row
that are part of a multiple byte function carried over from the previous row. The fifth field concludes the header. This
field specifies the number of bytes at the end of the current row thatare part of a multiple byte calculator function that
begins, butis not completed, in that row. The remainder ofthe barsin the row contain the actual HP-41 program infor-
mation.
A B C D E F
HEADER PROGRAM INFORMATION
8 bit Checksum {(End-around Carry)
4 bit Type Indicator (Set to One or Two)4 bit Sequence Number (Mod 16)4 bit Number of Leading Broken Function Bytes
4 bit Number of Trailing Broken Function Bytes
24 bits = 3 Byte Header
F Up to 13 Bytes of Program Information
moow>
Figure 1. Program Type Bar Code
Direct Execution (Complete Function) Bar Code
Many HP-41 functions require multiple keystrokes. With Direct Execution type bar code, thuse keystrokes can bereplaced by one row of bar cods. A row of Direct Execution bar code has two bytes of headerinformation plus up totwelve bytes of the function code.
As with other types of bar code,thefirst eight bitsof the header contain the checksum. This is a local, end-around carry
checksum. The next four bitsin the headerareset to the value “‘4”” to indicate the Direct Execution type. Thelast four
bits of the headerfield are not used, and should beset to zero.
A B C D
HEADER COMPLETE FUNCTION CODE
A 8 bit Ghecksum (End-around Carry)B 4 bit Type Indicator (Set to Four)Cc 4 bit Unused (Set to Zero)
16 bits = 2 Byte HeaderD Up to 12 Bytes for Function Code
Figure 2. Direct Execution Type Bar Code
Descriptionof Bar Code Types @
Data Bar Code
Data type bar code can contain either a number or an alphanumeric string. A number may have up to 29 digits,
however internally the HP-41 has only ten digits in the mantissa and two digitsin the exponent. An alphanumeric string
may be as long as fourteen characters (ASCII bytes).
Standard Data
‘When numeric data is read it is loaded into the X-register. Alphanumeric data is either appended 1o the current con-
tents of the Alpharegister, or the Alpharegisteris cleared before thestringis loaded. The wand function
overrides the normal destination of the data by storing whatis scanned into the HP-41 data storage registers indicated
by the contents of the X-register. (Referto page 11, , in the HP 82153A Wand Owners Manual.)
The Data bar code overhead information is contained in the leftmost twelve bits for the numeric data type and the left-
mostsixteen bits for the Alpha data types. Forall data types, the first byte is an end-around carry checksum. The type
field (next fourbits)is set to ““6”” for numeric, 7" for alpha-replace, and ‘8" for alpha-append. Figure 3 illustrates
the numeric data bar code. The Alpha types (7 and 8) have an additional four bits of overhead which contain the
number of Alpha charactersin the bar code string. (Refer to Figure 4.)
A B c
HEADER NUMERIC DATA
A 8 bit Checksum (End-around Carry)B 4 bit Type Indicator(Set to Six)
12 bits Header (1-1/2 Bytes)
c Up to 29 Digits
Figure 3. Numeric Data Type Bar Code
A B C D
HEADER ALPHANUMERIC DATA
A 8 bit Checksum (End-around Carry)B 4 bit Type Indicator (Set to Seven or Eight)c 4 bits Number of ASCII Characters in String
16 bits - 2 Byte HeaderUp to 14 Alphanumeric Characterso
Figure 4. Alpha Data Type Bar Code
10 Description of Bar Code Types
Sequenced Data
Sequenced data is an additional format for all data bar code types. It has in the header of each row a twelve-bit
sequence numberthat is used by (WNDDTX] to prevent loading data out of order. Sequenced data bar codeassures that
the data is alwaysloaded in the intended order. (Using the wand function [WNDDTX] this format is readable by revision
“F"* and later wands.*)
Thefirst byte of sequenced data bar code is the checksum. The next four-bits contain the typeindicator, which is set to
+49” for numeric, ‘10"’ for alpha-replace, or *‘11* for alpha-append. Next is the twelve-bit sequence field. This field is
ignored by the Wand whenthebar code is scanned normally (not under control). Please note that the alpha
types, 10 and 11, do not have a character count within the header.
A B C D
HEADER DATA
A 8 bit Checksum (End-around Carry)B 4 bit Type Indicator (Set to Nine, Ten, or Eleven)
[ 12 bit Sequence Number
D 24 bits =3 Byte Header Figure 5. Sequenced Data Bar Code (Rev. F and Following)
*Thefirst marketed version of the HP 82153Wand was revision £. There 1s no functional difference betweenrevisions£ and except for the use of theadditional sequenced data bar code types. To determine the revision letter of your wand remove all modulesfrom your HP-41, then plug in the wandand press - Therevision letter will appear in the display.
Description of Bar Gode Types 11
Paper Keyboard Bar Code
This type of bar code represents one keystroke. The number pad keys are represented by a one-byte (8 bits) row. All
other keys and one byte functions are represented by a two-byte row.
The error checking is accomplished for these shorter bar code rows by using a slightly different configurationthanthe
other bar codetypes. Forthe one-byte code, four bits represent the keystroke and the other four bits are mirror sym-
metric to the keystroke representation pattern. The two byte rows have twelve bits of data and fourbits of checksum,
computed as a sum of the data in four bit nybbles with end-around carry.
A sample program is not included to generate Paper Keyboard bar code. Since these are short rows, with values that do
not change, a simple program using a table lookup is recommended. The physical description forall the keys follows.
ONE BYTE PAPER KEYBOARD
a a aabbbob—_—— ——
A B
FUNCTION VALUE OF A VALUE OF B
0 0000 00001 1000 0001
9 1001 1001. 0101 1010
EEX 1101 1011CHS 0011 1100<~ 1011 1101
12 Description of Bar Code Types
TWO BYTE PAPER KEYBOARD
aaaahbocccdddddddd—_——— —— ———
A B C D
1. Programmable Functions: Found in the following locations in the HP-41 Function Table (Table 11,
page 45).Row 4 column 0 through Row 9 column 15Row 10 columns 8 through 14Row 12 columns 0, 14, and 15Row 13 column ORow 14 column 0
Four bit Checksum (End-around Carry}
0000Eight bit Function Code(such as ABS, Row 4 Column 2=01000010}
oow>
o
2. Alpha Characters (Keys)A = Four bit Checksum (End-around Carry)
B =20C = 001D = Eight bit ASCIl with Most Significant Four Bits Doubled. {For example the ASCII for
“A” is 01000001. With most significant nybble doubled the bar code value for the
character A becomes 10000001.)
3. IndirectA = 10(1010)B =20C = 2(010)D = 128 (10000000)
4. Non-ProgrammablesA = Four bit Checksum (End-around Carry)B =20C = 4(100)
FUNCTION VALUE FUNCTION VALUE
D = CAT 0 SST 8
GTOL 1 STAYON 9
DEL 2 PACK 10
GCOPY 3 DELETE "
CLP 4 ALPHA 12
RIS 5 PRGM 13
SIZE 6 USER 14
BST 7 ASN 156
5. XROMA = Four bit Checksum (End-around Carry)
B =1C = fffD=gghhhhhh
fffgg =ROMLD. Numberh =ROM Function Number
For Example: has ROM 1.D.=27 and ROM Function= 5. Therefore ffigg= 11011,and hhhhhh=000101.
Section 2
Physical Specifications
There is a wide variationin the appearance of readable bar code. However, some properties are shared, and cannot vary
beyond certain limits. This section contains a description ofthe characteristics of readable bar codeso that you will be
able to judge the acceptability of HP-41 barcode.
The performance of bar code depends heavily on print quality. The printed characters must exhibit high contrast and
good definition. Stroke width and location should be maintained asclosely as possible totheir nominal values. Hewlett-
Packard Corvallis Division concurs in general with the recommendations of ANSI X3.17-1977 ““‘Characters Set and
Print Quality for Optical Character Recognition’” (OCR-A)*. Many of the recommendations in that document are
“‘based largely upon expert opinion and judgement and are not fully substantiated by extensive test data and measure-
ment”. Also contained in this section is a discussion of the special characteristics of HP-41 bar code which differ from
the recommendations of OCR-A.
Size and Shape
All four categories of bar code that are plable 1o the HP 821534 Wand look essentially like that shown in Figure 6.
The information contained in the barsis encoded using narrow bars for *“zeroes’”” and bars twice as wide for “‘ones”’.
These bars are separated by spaces which have the same width as the narrow bars. The bars containing the information
are always preceded by two ‘0’ bars and followed by a ‘1-0”” combination. These ‘‘start’’ and “‘stop’’ sequences are
used bythe decodingelectronics to determine scan direction. This allows HP-41 bar codeto be scanned either forwards
or backwards.
~—— eSTART BYTE 1 BYTE 2 BYTE 3 BYTE 4 STOPBARS BARS
THE NUMBER OF BYTES MAY VARY FROM 1 TO 16
Figure 6. Configuration of HP-41 Bar Code
There will always be an integral multiple of eight-bit bytes between the start and stop bars, but there cannot be more
than sixteen bytes in any given row. If there are too many or too few bars in a row of bar code, the decoderin the wand
module discards whatit has read.
*Available from American National Standards Institwte, Inc., 1430 Broadway, New York, NY 10018,
13
14 Physical Specifications
[ WIDTH* TOLERANCE SUGGESTED VALUES |
g W+ .002" W—%005" 0.022" + 0.003”
0" W-.002" WA%OOSH 0.018" + 0.003”
1 2W - 002" W‘°5'°°5" 0.038"= 0.003"
SHY H > 036" “Bar widths are arbltrarily reduced by .002" to allow for the differances betweenbar width perception of the wand and the human eye.
Table 1. Bar Size Specifications
The dimensions shown in Table I may be varied widely, but we have found them to be a very good compromise between
compact code (which occupieslittle area but is difficult to read) and extensive codes (which is easy to read butrequires a
lot of space). Printers have found thatit is easier to maintain location than stroke width. If there were no error in
placing the bar, and no voidsin the bars or spotsin the spaces, then the bar width could vary as much as 10%ofthe
width of a zero bar without severe loss of readibility, and as much as 20% if degraded readability were acceptable.
Figure 7 shows examples of bar code having excessive stroke-width error.
STROKES TOO NARROW STROKES CORRECT STROKES TOO WIDE
ZERO WIDTH: “0” =0.014" “0” =0.020" “0”=0.026" 0.020" “8”=0.014"
SPACE WIDTH: “8” =0.026" “8
Figure 7. 20-Mil Bar Code Having Excessive Stroke-Width Error
Physical Specifications 15
It might seemreasonable 1o make the bars and spaces narrower and narrower, but the optics in the photodetectoris
such that the wand “’sees’” a spot between 0.011”t0 0.016* in diameter. Bars smaller than this will often read; because a
bar only 0.004 " to 0.009” wide will sometimes be detected. However, such bars usually read only when the wand is held
in a particular orientation. To read very narrow bars, the wand mustbetilted as shown in Figure 8 until the spotoflight
it producesisin the best possible focus. All bar codeis moreeasily read when the wandis held in the *‘preferred orienta-
tion”, but marginally-narrow bar code cannot be read in any other way.
d < 0.5 mm0 = « = 30° MAXPREFERRED ORIENTATION IS:10° < o < 20°AND TIP SHOULD TOUCH THE PAPER DURING READING
Figure 8. Preferred Wand Orientation
Paper and Ink Considerations
There is yet another reason to hold the wand in the preferred orientation; it has been found that the surface of some
paperis specular or mirror-like. Bar code printing on such paperis likely not to read if the wand is held perpendicular to
the paper. The smooth surface reflects so much light that even black bars appearto be white. Accordingly,it is wise to
choose a paper that does nothave a glossy surface. Unfortunately, itis also necessaryto avoid rough-surfaced papers,
because excessive variation in paper reflectance can be troublesome as well.
The wand electronics determines the difference between bars and spaces by measuring their relative contrast. Print
Contrast Signal or PCSis defined to be the difference between white and black reflectance divided by white reflectance
and expressed as a percentage where Rw = White Reflectance and Rb=Black Reflectance:
Rw-RbPCS = Rw X 100%
It is desirable to maintain PCS as high as possible. The wand’s response to bar code is also dependent on batiery
voltage. A battery level near the low-level-detect threshold might prevent reading bar code having a PCS below 60%,
while fresh batteries might allow 30%-PCS bar code to be read. Bar code having a PCS as low as 20%can sometimes be
read with fresh batteries by paying particular attention to wand orientation.
Since people see a broad range of colors,it is not usually possible to judge PCS by eye. Thelight-emitting diode in the
wand produceslight having a wavelength of 700 nanometers,close to standard wavelength B680 mentioned in OCR-A.
16 Physical Specifications
Variation ofreflectivity within bars and spaces can cause misreads. The amount of permissible reflectivity variation is
between 10 and 20 percent. Reflectivity variation, an inherent property of paper and ink, also results from the presence
of voids and spots. Voids in inked areas and spotsin un-inked areas should be minimized, but we have found that voids
of not more than 0.005” spaced no closer than 0.009” usually do not cause a misread. Bar code containing voids and
spots will not be readable with as much freedom of orientation and speed as will clean bar code. Because the wand’s
response to low-level signalsis a function of battery voltage, noisy bar codeis usually easier to read with low voltage
batteries.
The opacityof paper determines whetheror not bar code can be adversely affected by printing on thereverse side of the
paper. Opacity of paper suitable for optical character recognition exceeds 60%, but Hewlett-Packard Corvallis Divi-
sion recommendsthe use of paper exceeding 85% opacity. Paper porosity is probably important for reverse show-
through also, because the effective opacity will be reduced if ink can move into the paper.
The following plot shows the PCS that perfect bar code would appear to have when viewed through paper having par
ticular values of RO and Rinf. Since wands can often read bar code with a PCS as low as 30%, it is probably wise to
avoid papers with reflectivity less than 70%. Papers of lowerreflectivity might have excessive show-through.
p= P= P= P= P= P= P= P= P=09 08 07 06 05 04 03 02 01
INFINITE-PADREFLECTIVITY,
Rinf
o o
ST PR + L L —
0.1 02 03 04 05 06 07 08 09 10U
SINGLE-SHEET REFLECTIVITY, RO
All of these characteristics interact in ways thatare very difficult to quantify. The best way 1o test bar code readability is
to try to read bar code samples with the wand held in various orientations and with baitery voltages ranging from 4.1 to
I TR IW=.010" W=.020" W =.040" .
6 volts.
Figure 9. Different Module Width Bar Codes
Section 3Sample Software
Generating Program Type Bar Code (PRGMBR)
PRGMBR allowsyou to type in numbered HP-41 instructions and will insert the instructionsinto a textstring forlater
use. The line numberof the HP-41 instruction may be from 1 to 2233. This number determinesthe order of execution
of the instructions. The number 2233 is maximum because it is the largest number of bytes available in program
memory. If an HP-41 program is very long, a renumbering command can be used to create gaps in the numbering
schemeto allow forlater insertion of HP-41 instructions. Instructions can also be deleted or replaced. In addition, you
can save an entire HP-41 program in a file forlater use. Other features include the single word commands to compile
and generate bar code for an HP-41 program, save and retrieve the compiled HP-41 machine language, and list or
delete the entire program. The syntax and action of each command is given in Table II, page 18, and will be printed out
by the program if a ““??” is typed in response to the prompt symbol.
PRGMBRisstructured with a main routine that generates the prompts and decodesthe input. A jump table in the main
routineis used to call a series of other routines which perform the commandfunctions. Thelimited decoding done by
the main routine is performedonly to determine if a command or an HP-41 instruction has been given. The subroutines
will then be able to retrieve the HP-41 program by linear inspection of the pointer array. Replacement, deletion, and
renumbering of instructions, therefore, only involve manipulation of the pointer array. (Insertion of an instruction
requires that the instruction number—an integer—mustfall between two existing instruction numbers.)
PRGMBR SyntaxIn almost all cases, the syntax of the HP-41 instructions(recognized by *“PRGMBR”’)follows that of the HP 82143A
thermal printer and of the HP-41 program listings distributed by the HP User’s Library. The few exeptions,dictated by
the difference between ASCII and the HP-41 character set are shown below:
HP-41C Character Substitute ASCIl Character
) g« “@”* o
Single quotesinstead of double quotesare used for inputting HP-41 Alphatext and Alpha labels. The alpha append
instruction is indicated by an ‘A’ preceding the single quotes and characterstring. See Table V, page 54, for the
character set and their decimal values.
17
18
Sample Software
Commands for Program “PRGMBR”
COMPILE — Compiles the current HP-41 program and loads the compiled code into the
array M.
DELETE n — Deletes the instruction given by n from the current program.
EXIT — Halts execution of the bar code generator or of the line number generator.
GETPROG — Retrieves compiled code from a file on cassette tape {routine promptsfor a filename).
GETTEXT — Retrieves program instructions from a file on cassette tape (routine prompts fora file name).
LIsT — Lists the entire current HP-41 program.
NUMBER — Automatically generates instruction numbers for HP-41 program entry. The
starting number and size of the incrementare requested by the routine. Thisroutine is halted by typing “EXIT”.
RENUMBER — Renumbers current HP-41 program instructions (routine prompts for the oldstarting number, new starting number and size of the increment).
RUN — Generates the bar code from the compiled code (will not run unless compiled
code has been generated).
RUNPRIVATE — Generates bar code for a private program.
SAVEPROG — Stores compiled code for the current program on cassette tape (routine promptsfor a file name).
SAVETEXT — Stores instructions of the current program on cassette tape (routine prompts fora file name).
SCRATCH — Erases the current program.
?? — Displays a list of available commands and syntax rules.
Table II.
sample Software 19
PRGMBR* Program Listing
1915]2528
|| HF-41 USER LANSUAGE COMPILER ARL BrRk CODE GEMERAYLON FROGRAN! THIS FROGRAM FROMPTS FOR HUMEEREL HF41 INSTRUCTIGHS AMD STORES THER' FOR LATER COMPILATION CINITIATED OH COMMAMDY. THE INSTRUCTION! NUMEERS MAY EE FROM 1 TO 246 (THE TOTAL HUMBER OF BYTES AYAILABLE! FOR USE 1M A PROGRAMY AWD MUST BE INTEGERS. THE CONPILED E WILL! BE USED T DRIVE A BAR CODE GEMERATION ROUTINE WHICH MILL CALCULATE! THE BIT FATTERN FOR A ROM OF BAR CODE. THIS EIT FATTERM WILL APFEAR! WITHIN f LOOP, AT WHICH FOIMT THE USER WILL EE AELE TO CALL HIS 0Ni PLOTTING ROUTINES TO GEMERATE HP-41 BAR CODE. THE COMMANDS! FYAILABLE IM THIS PROGRAN ARE:! 13 "HUMBER": GEMERATES LIME MUMBERS FOR HF-410 INSTRUCTIONS! 23MLIST LIZTS THE IMSTRUCTIONE CURREHTLY ENTERED! 33"RUN": CHECKS FOR PRESEMCE OF COMFILED CODE AND FRODUCES|
||!!|''''
@
oTHE EAR COLE BIT FATTERH,
43UCOMFILE": COMPILES THE CURREMT TEXT INTG MACHINE CODE53" RENUMBE ALTERS THE 41 IHSTRUCTION MUMBER SERUENCE£)"SAYETERT": SAYES THE CURRENT TERT oMPHUGETTERT": RETRIEVES THE TEXT FROM C23 "SAYEFROG": SAYES THE COMFILED MACHINE CODE oM2)"GETFROGY: RETRIEVES THE COMFILED CODE FROM TR1EOYERIT": HALTS THE USER LANGUAGE COMPILER FROG113"DELETE": DELETES THE MAMED IMSTRUCTION MUMEER FROM THE
CURRENT TEXT.123"SCRATCH": ER THE CURRENT INSTRUCTIONS EMTERED132RUNFRIYATE": GEMERATES EAR CODE FOR A FRIVATE FROGEAN
eR RARARRRARARRSRRRAR E ARAR R ARARAR ARRrTHTEGER T,J,K,L,",R,R1,0,01, 020800, T,P{224a0 MY2240),11,F1 KiczzdasINTEGER Fi,F2,F3,F4,F5,F6,F?,F8,F3,E,E1,E2,E3¢(15),E4, 1¢1INTEGER 1S,B1,B2,B3,T5,H1,HZ,F5,L5,05,53 163, BO1320 1, ¥2, 3DIM T$0681, TI$0361, 7230301, 550501, AF1500], BELS15]DIM $1$0273011, 151645061, HI$I3], H2$03], HaS[5, CFcE0I 1]IINT! MAIN FROGRAM: WRITES FROMPT FOR TEXT OR COMMAMD EMTRY AMD EITHER! DECODES THE INSTRUCTION NUMBER AMD EHTERS THE TEXT INTO THE TEXT! ARRAY, OR USEZ THE COMMAND JUMP TRELE TO JUMF T THE CORRECT COMMANDOn ERROR GOTO 4258
7IGCHRF (3LR$(27IR0HRE (837
ECHR$ (2 VSET UF DIABLC COMTROL CODES
TE=Tig=Tos=""!FOR I=1 TO (RERD LOCHL UHEELS & STACK REGISTER MHEMONICE IMTU £1%READ $1$41)
HEXT 1FOR I=1 TO 183 {RERD SORTED IHSTRUCTION MMEMOMICS IéTO I#, INSTRUC.READ 1$¢17, 1141 IYALUES INTO I1 FOR TRELE DRIVER
FOR 1 TO &8 {READ IN YALID CHARACTER TRELES FOR CHARACTER CHECKRERD C$(Ix,020 |CHARACTERS IN C©f; CHARACTER CODE IN ©2
NEXT 1
VIMITIALIZE ARRAY OF FOIMTERS IMTC TEXT STRINGVINITIALIZE COMPILED FROGRAM ARRAY
MEXT Io n
PINITIALIZE TEXT $TRING FOINTER AMD FLAGE
IMPUT "DO 70U MANT # LIST OF THE AYAILABLE COMMANDET*, Ti%IF €T1$="H") OR (TI$="NO": THENIF T#="SCRATCH" THEM 35@
GOTO 35088 IFRINT OUT REFERENCE TABLEwrtesy BYTE Publications, Inmc. Copuright 1989,
20
3aw35a3585
o 0@@
535698TaETes7ie715
Sample Software
! BEGIH FROMPIER SECTLOM: ASK FOR COMARND R LHSTRULTIGHTHFUT 50, THI=FOS0Ts," ") VEET I TO FIRST WORD OF IHFUT
{SET PRIVACY FLAG T INDICRTE A MUM-FRIVATE PRUGRAN
IF I=8 THEM S LOME MORD COMMANHTT1$=T$01,1-1] TEXTRACT FIRST WORD OF IHFUTIF T1#<»"DELETE™ THEM 485 |ZHECK FOR A DELETE COMMAMET1$=TRIMECTHOI+11)I=LEN(T1$3+1=1IF [-134 THEW 518 VCALCULATE INSTRUCTION HUMBER VALUEFOR J=I-1 TO 1 STEF -1
IF (T1$07,J1<"@ OR 4T1$0J,J1%Wy (NUMCT LS00, T30 -5 180KK=kl
HEXT TIF %>2248 THEN S1@
IF D<{r1 THEN 485 IDELETE IMSTRUCITON IF FLAG [& SETPiyi=-1GOTO 258
TRIMFCTSLI+4112 TEHTER TEST AMD DELIMITER IWTG TEST ARRAY dAHD
FETFE" LY IFOINTER AT THE IMDEX GIVEM EBY INSTRUCTION MU
» THEN S8
&FoyasTT=T+LEWiT#1+1
GOTO 258
! ERROF MESSALES
FRINT "2?7 - GIWE MNUMEERED STATEMEMT OR A COMMARDY
GOTO 358FRIMT "STATEMEMT HUMBER “HLUE TOO LHARGE"
s0To 358! #%% COMMAND JUMF THELE #%%
iF T$="NUNEER" THEM &73
IF T$="LIST" THEN 785
IF IM" THEHW %251F PILE" THEM 1855IF THEH 3528IF T$="RENUMEER" THEM 3718IF T#="SAVET " THEMN 3843IF T$="GETTEx THEH 3335IF T$="SAYEPROG" THEN 4855
IF T$="GETPROG" THEN 4148IF T4="SCRATCH" THEW 235IF T$="ERIT" THEW STOFIF T$<>"RUNPRIVATE" THEN &03
pE=2GOTo 225
FRINT "?% - UHRECOGNIZABLE COMMAML®GOTO 358 IGO0 BACK TO FROMPTERVg s % o® % % % % EMD OF MAIM FROGRAM + % # % & & « & + & = =
Uos s & % 0% % 8 % CAUTOY ROUTIHE % % % & # % % & % % » & & % & & %
| THIS ROUTIME AUTOMATICALLY HUMBERS THE 410 INSTRUCTIONS AND| THEM IMT2 THE TEAXT ARRAY. TO LEAYE THIS ROUTINE, TYPE “EXRITIHPUT “GIVE THE STARTING WHRLUE AMD ZE OF THE INCREMENT",¥,x1
IF ¥:»2248 THEN 739
PRIMT "33y IFRINT THE PROMPT AHD THE LIME MUMBERINFUT T35
IF T$="EXIT" THEN 338 FLEAYE ROUTIME AMD GO TO MORMAL PROMPT
A$=ASLTHE" 1" PENTER INSTRUCTION INTO TEXT ARRAYPOyT=T+LEHCT$2+1
W=VHRLLOTO &75FRINTER 13 & IERRORPRINT "STATEMEMT HUMEER YHLUE TOO LARGE
AGE FOR =TATERENT HUNEBER
IH3UBHINTSONTINELESTHOTLONMLSHYW3IHL8328470T+51=01H3HL8¢
=51ArTTSANHTLHODMOTLINYLSHTMIHL<83410511HIHL@8841SETT
SEFT0109AacTy
HILHAOD13538FSOHITHATLINYLEHTHIHLFiSETTWIHL
SITEHIAEAILHTLNGTS43430931493TGLNI.W.WOYST40M¥345HHELGCT+TEIW=CT+28715SE@1
JILOMELEHTLM3WFHL40SNINNIS3Z3IHL4049405H534435iMHE“HOTLOMHISHTLHIEEND3HL3137dW020L0315344353044023TWAHi
IHL0L138ST4LHHL3L0NDWIHD33I83IHIHL804SHILMAOD4334audHodi3003YTBOOIHTSHOTLONYISHTGH07THOTE03SHOTIHISHWH]HOTLOAYLENT|
"4ILX3K
G=10dZRTN0I=1¥0d
AHHEHH¥3LiHd1193HL1000BLH(HSEO0WWASYH3LH00DWNSHIIHDLAELS|
BLHE3LINA00M0d40MOT1JMELENTLSHIdLagls|G1HA3LHAO0T3143THO4THILHHSHITIHHLLHHLS|@IHHILMA0D31TCHIdTHILHYdOHIGH3TLEHLSE
6LW¥3LHA0DMO¥IA0DHHELHHLS|©WMILHAOTCLEWILSYTJOHISSO0M40#LMd
@LdHILNN0DHIOWITMOTLINELSHIL1dd£LY$3LNING3LAFMOII00HHELAHLE]
BO1HHIINIOLGM.AHHEEHBIHDI3714M07LaHLS]@iHH3LHAGDHEILINY
1470LA
LEHITh-dHHILNTEdL1353
T51d3LMId4wowLHIdd
®E13T3INSHILSIDTHWHATOHLoLHMIddT4H=4HIHL@<
AIHLNOD250
UHHT0HdIHLHTS3IAE30H3TMANJHL
FLEHASHBT,THISNLNIddPEEHTLNIHd
M707EHIE0L¥3INIEdL35&51¥3ILHINA#RgiedrerBSHTOEHITIHL0LLADS3LIMNHOILD3SSIHLszssss|
$17.7353740SHILIHEEHIB2MHET08dIHL403TLTL3HL33LNT.LrdHTB5E0L09
wilSHI4I370dWAT38LSNHWHA90EdH.LNTHdHOTLHTTANADSNOTAZHSH04#33HBbeHIHLT=2d4A1
CLE5.WDTT3H.YHIAMANMOY3T0THHE3HLbi€.5T.NIT73H:LHIMA3Si
AMINHDIHLHIMIFSWOTLOMHLENTLSHT3HL4043TWAN3NIT3HLCi€.57.NI073Hi
SHIT43HL40HIGUAH3NIT3Mia3IHLWDS3LAG40#3TWANFHLCTig1TIMLHIODLHHLLHH3I3SHOILGMHOIHT|
iiii
GaS8
LH3MDESLHIHATD3IHLMIHOILINCL23,HIT73H:LH3W9
H
@ H3IHLO*511dJOLEOMEL4BLSMYHIWTJ3043H40$314d£9NIANTINI*SLHIW-0353L4E3TNI4007WMIHLIMSHH3dddMa3Lllbd1193FHL"3000#HTTb-dH
GHILNIS3443dHHILIYd1393HLGLHILISLH3ANODQMYABYHMLW,3HLNIO713HWHATOES13TAMA0IHTLNOYSTHL33IHILNOHHOTLHH3INIDHIB30034ud
ss%%ox%#%%%&%JHIINOHHNA,#*%¥%%¥£%%%=oso=eINTLANELT40ANZ¢foE%%%%o2£|
01DI1%3M
FTLHTLHIAS[SSSERETIESCECESSN
43LHIOO1764B41Ly3LLnoiG188MWIHL@3¢Ivd4137261H3IMICdHINOHHL43150HREE0LHo4
1%303HLHI073KWHE904d4LHIYHNDFHLSIST7IHILOOY#%%%3%%%&%%INILNOHL3I7.%*3£5%£5%|P
L
2sowows
e¥o%xINTLMAOHLOLAH.40ON3¥*3¥%%%=5|M4THUMOH)HNNL3EEEINL 1zesmemyogajdweg
22 Sample Software
175183 THEN 1z88 VCDUNTER LF MOK-HULL LeST. AND CAECK FUR LENGTH##FPROCESS UME BYTE [HSTRUCTIONS =+
| OCHECK FOR AM ALFHA EXECUTE OF A GOTC ALFHA! PIMSTRUCTION. (GET SI2E FROM SECOMD BYTE)IF CMCB1)€>28) AND (MCE13<>38> THEH 1215E3=McBl+12 MOD 18+1
S+1GOTO 1435
tOCHECK FOR A DIGLT ENTRY IWSTRUCTLIONTHEH 1278 IF Blidles OF «ilcBlis
I=Bl+1
IF (Melsg OR (MDD » THEM 12I=1+1 ISTER THROUGH IRSTRUCTIONS UMTEL END OFGOTO 1225 IDIGIT EMTRY HAS BEEM SEEMB -Ei1-1TS=TS+1IF B3¢»E THEN 14335 CCHECK FOR SIHGLE DIGIT [HSTRUCTIONTS=aGOTO 1435'
ALL GTHER OHE BEYTE [NSTRUCTIONE
CPROC
TS=0GOTO 1435
! *xPROCESE TWO BYTE INSTRUCTIIF MCELX2287 THEM 1378 CHECE FOR ALFHAIF €MCE1D<1%20 OR €MOEL) 2852 THEM 1343TS=TS+1
a ICHECE FOR THE EHD IMSTRUCTION2 THEM 1
IF B1+2Ba=2GOTO 1435
3= CE LGOTD 1438
THIRL EYTE
T3 Wop 1 IHLPHA LABE
CTHOOEVT IPROCESS SHORT FORM GT LONG
THREE E¥TE IHSTRUCTEIOF
IFRGCESS LONG FORM GTOC
sxFROCESS& THEH 1@ THEN 1
GOTO 1435CB1) HOD 16 IPROCESS ALPHA DRTA EXTRY INSTRUCTLONS
=TS+l LGGET LEMGTH FROM FIRST BYTED! BAR CODE ROW =SETUF SECTION: TAKE DATA FOR THIS ROW AMD! CALCULATE THE HEADER DATA AND OTHER YARIAELES
¢ CHECK FOR A COMPLETED ROM (A FILLED BUFFER.THEH 1&3%
VUPDATE FARTIAL FUMCTION C
16 AND <BE1<E LUNTERS
MOD 18=18+T7S MOD 16
THEMN 1473
S1¢33=HL MUD 1é=1d+Hi WOD 156! ENTER FRIV VALUE AHD SEWUEHLE HUMBER
S102)=PS* 16453 MOD 16
2 T0 EZ ICALCULATE CHEC CH CUMULHATIVE S0 MODS+51¢13 HOD
IF ©s5>» & THEM ©5=C3 MOD 25e+1HEXT 1
1588 §1(13=051515 ! COWVERSION SECTION: COMYERT THE CUREENT ROW OF SEGHENT IHTO A1528 ! EIT PATTERH REPRESEHTING THE BAR CODE.15381535 TO B2 VCOMYERT DECIMAL DATA TO & BINARY PATTERN1548 (11545 FOR Y=2+1+8 TO F+([- 1% STEP -1
Sample Software 23
B WOD 2H=d D1V 2
HEKT vHEXT 1
PROL STRRT HAHD
oF EITE
! AT THIS FOINT, THE HERAY -EB° HULDE A OSERIEZ OF ARD @REFRESENTING A SINGLE ROW OF 410 FROGRAM BAR O THZLUDINGTHE START AHD STOF EI OTHER TATA WILL BE Fo iH THE
'|! WARIAELES B2, 83,15 AND IS AS EXPLAINED ABOYE.' #*¥*THIS 15 THE EBAR CODE GEMERATION AND OUTFUT SECTION USED Eress! ##4HF FOR EAR CODE GENERATION OW A DIAELO 1 TATEY WHEEL*##4%%' #%4FRINTER WITH A TITAN 18 3&-CHARAGCTER METALLIC T " WHEEL##%+%T1%=FHF$(53+1-1,L5,15)>FRIMTER 9FRINT LSIHGL g+4GOSUE 4468FRINT USING "3FRINT *IF 53 MOD 1 THEN FRINT CHR$:123FRINTER I3 18 'RESET FRIMTER To CRT| EEE END OF DIABLO OUTFUT SECTION +ner=! CLEANUP SECTION: THIS SECTION RESETS VARIAELES TO FREFi GEMERATION OF THE MEXT ROW OF BAR CODE.
170 18 !ZERD OUT THE 1& BYTE EBRR CODE ROM BUFFER
VEET FRIMTER TO DIRBLO LU
|GEMERATE EBRAR FRTTERM FROM B17S 3A, LEA,215A, 2A"JHLE, He%, BS HES
“E FUOF.
TO 132 1ZERD
OUT THE BIT FRTTERN RRRAY
IREZET EUFFER POINTER TO'UFDATE FIRST IMSTR. COUNTER TO CURRENT IHZTR.
THEW LS=L5+1 ICHECK FOR THE START OF & NEM IMSTRUCTIONTHEH 1885R CODE GEWERATLION COMPLETED"
!GO BACK TO PRONPT IF BRR CODE GENERATION HAS! BEEN COMFLETED
# 4 %+ % % % % % 4 END OF M7OROUTINE # % » * = 5 % % 5 # =BoEE x4 & x & % "COMPILE ROUTINE % % = % % % % % % = % % % % %
HE-41 INETRULTION IHTERPRETATION ROUTINE: THIS ROUTIME INTERPRETSTHE INSTRUCTIONS EMTERED IN THE TEXT ARRAY AMD LOADS THE MACHINECOBE INTD THE “M° ARRAY. THE IMTERFRETE TRELE DRIVEM EWCEPTFOR THE INSTRUCTIONS MHOSE OFERANDS CHAHGE THE LENGTH OF THE
RUCTION GTC sLELYS OR HEQ-S3, DIGIT EMTRY INSTRUCTIONS,OR IHSTRUCTIONE IMYOLWIMG ALPHRNUNE THE PROCEZS MAY BEABORTED IF AN ERROR IS EMCOUNTERED BY TYFIHG “AEORT- IH RESFOHETO THE ERROR MESSAGE.
E
PETART MACHIWE CODE ARRAY INDEX AT 1ILODF THROUGH THE INSTRUCTION FOIMTER ARRAY
FOR A WALID POINTERT=FHIF(AS,PCTY FACT THE INSTRUCTION FROMN THE TEXT HRRATE4=H1 PSAYE CURREMT MACHINE Y POINTERSCANNER SECTION: THIS SECTION SCAME THE INSTRUCTION AND SENDSTHE DECODED TEXT TO THE IHTERPRETIMG ETS
SEVERAL FLAGS (F1-F&) FOR THE FOLLOMIMG COHDITIONS, ECTIVELY:ALPHA APPEND INSTRUCTION, AMY TEXT INSTRUCTION, AMY ONE WORTINETRUCTION, ANY ALFHA OFERAND,ANY TMBIRECT OFERAMD, AND ANYDIGIT EMTRY INSTRUCTION.
PIMITIALIZE FLAG
AHD TEXT YARIAELES
24 Sample Software
THEH 1355 CADD A HULL [WSTRUCTION BETWEEN ADJACENT LiGl1PENTR'Y IHSTRUCTIOHE
IF «T&="END": OR (Ts='.ENB. " THEN[
3 AND (T$[1,21¢" THEMW zagw
[CHECK FOR ALPHA APPEND TEAT Ir
FOR A TEAT ENTRY [H2TRUCTIONA" THEM 55
TRUCT IO
L=LEHCTS) IFIND ENB OF TEXT AND CHECK FIR ERIF L<18 THEN 2azeFRINT “"ALFHA STRING TOO LOHG IH LINE # ";JGOTO 2238
IF T#CL,L1=""" THEH z@4@FRINT "ERFOR IN ALFHR REGISTER ENTRY INST
Tlan BT LIME #
ET TEXT FLAG5OTOFOR I=1 TO LEM(T#) ICHEDT1$=T$01,1]IF (T1$¥="a") AHDIF ¢iTi$="+"> ORIF CT1$=" ") OR iCUTO 21es
FOR A DIGLT ENTRY INSTRUCTLOM
%) THEM 2685="y AHD C(LEHCTS$) THEN 2885
OF (Tig=".") THEM 2885INOT R DIGIT EMTRY INSTR.:
TIMUE =UHM
ISET DIGIT EWTRY FLAG
Lo FOR AW OFERAMD GF THE [WSTRUCT1OHISET FLAG AND FETURM IF OMLY ONE HORD LUMG
TUIS=TRIMECTEIPI+11) VGET FIRST OFERAMD AND CHECK FOR AN ALFHA STRINHGT$=T$01,F1-11L=LENCTIS)
IF (T1$01,1343" 7% QR (T1$0L,LI<x" "> THEW 2175IF L>% THEN 2B19 |CHECK FOR LEMGTH OF GPERANTTi#=T1%0[2,L-1]Fa=1
GOTO 2275YGEY SECOND OFERAHD AND CHECK FOR IHDIRECTION
Te$=T1$01,P2-1]
IF T2s="IND" THEN 2214FRINT "OFERAND ERROR IN LIME # “3JGOTO 2238FS=1 VSET IMDIRECTION FLAG AMD ExTRACT HUAERIC OPERAND
2215 TI$=TRIMS(T1S(P2+1ds2z IF LEH(T1$3=2 THEH 22732225 PRINT "ERROR IH HUMERIC OFERAND IH LIME # *2 GOSUE 34802 GOTO 19382 ! IMTERFRETING SECTION: THIS SECTIOH THKES THE TEXT HELL IN2 ' T#,Tt% AND T2%, INTERFRETS THE INSTRUCTION AND EMTERS THE MACHINE
' COLE INTO THE ARRAY “M° AT THE POSITION GIYEM BY THE POINTER M1<' AN ERROR CAUSES A MESSAGE TO BE FRIMTED WHICH RERUESTS A CORRECTION,IF Fz<»1 THEN 2385 VCHECK FOR A TEXT EMTRY INSTRUCTIONMeMly=24@+L-2 IENTER LENGTH OF TEXTH=1
59
IF F1e:1 THEN 23 'WML a=MOnIo+1 PALL COUMTER FOR EXTRA EYTE IF RPFEMD INST.
Mi=H1+1M{M1=127 IFUT IH 2HD BYTE
Sample Software 25
Mi=rlclFOR
COHECE PR YLD CHRRHDTERS sHL sLD 0 INST.
2=F} IS ENTRIF a BFRINT "INYALID CHARACTER IM LABEL OR TEXTGOTH o ' IF ERRC
E:
MMy VEMTER WRLIDMi=hi+1
<x1 THEN 2 PCHECK FOR DIGIT EMTRY LIHSTRUCTLoH
Fa=gIF (TH[1, 10400+IF T#01,13Mimle=22M=+l
AWD CT5C1,11¢3%="3 THEH
" THEN ICHECK FOR MIn
TLOOK FOR EXPONENT
IF L1=8 THEM L1=LEH¢I13)8 THEH L1TO L1 VEHTER MAHTISSA IMTU BAL
IF T#L01,13<>". " THEN 2433 1CHECK FOR THE DECINMAL FIF F3=1 THEH 2538Fa=1
LHE LODE RARRATIMT
MOl a=26Mi=H1+1GOTO 251%
TF CTH0I, 104 0"s OF «I1$00,10:75";MEMLO=HUMCTSOT, 11-32Mi=H1+1
HEWT TIF C(L1=LEWCT$3) AND ¢IF ¢I=L1> OF (I=L2> THEN 2555PRINT "DIGIT ENTRY INSTRUCTION ERROR IH LIME # 37GOSUE 3488GOTO 2468TE=TRINSCTSLI1) EMTERIF T#L1,11¢3"E" THEHM3 =27FH1=M1+1TH=T$L2]IF T$01,1325"-% THEM 2608 'LHECK FOR MEGRTIVE EAPOHENTML =28M1=f1+1TF €T$01,10="="; OR (T$C1,13="+"3 THEW T=T$iz]TE=TRIME LTSSL=LEHCTS) VADD EXFONENT T8 MACHINE LULE ARRATIF L>2 THEW 253FOR I=1 To LIF ST$CI,13<%@") ORML =HUMETH0T, 110 -1=H1+1
HEMT 1
355 CHECK FUR ERRURS [ MANTISSA
TSI, 11375 THEH
G0TO 3235L=LEHLT1§ IOTHER IHST 0 CALCULATE YALUE OF OFERARDE
THEH = TOME WORD FLAGTHEN 'ALPHA OFERAMD FLAG
K THEW z7as THUMERIC OFERAND SEEHFRIMT “HUMERIC OFERAHD TOO LOHG IM LIHE # *;7J
8THEN 2748 VCHECK FOR DOUELE DIGIT OFERANL
WECHUMCT LS00, 110480 % LE+MURAHD (Y 93 THEN 2385
RECT MUMERIC OFERAND IN LINE #
26 Sample Software
LOTo 2238
FOR I=1 TO 28 VLALLULATE BTHOK REGISTER OF LUCHL LHBEL YALUEIF T1 01+ THEN w=1+181
HE®T 1IF %<»3 THENMCTI8 -
195 CALCULATE #IHGLE DIGIT OFERAND “ALUE
IF Cyr=8) AND (v(=9%3 THEH 25@5FRINT "IHCORRECT STRACK OF SINGLE DIGIT OFERAND IN LIME # TGO0TO 2238
| CHECK FOR SFECIAL COMMAMDETHEN +128 |HDD INDIR I0H EIT (HISH ORGLER BIT. TO OFERHNLE
CRUGTOMY AMD CTECHUHERY X THEN SAZEICHECK FOR CGTOC OR CHESS COMMANDIF FS<>1 THEM ] ICHECK FOR “GTO IMIDC HEQ IHDMCM1=174IF T#="GT0" THEM TSET HIGH BIT FOR B OIMDYMiM1+1Mi=r1+GOTO 2339
ALFHA LABEL COMMAND
IF F44>1 THEM 2335 PETART HITH "GTO
IF 7% B THEH Mells=3eL=LENCT1$MOML+1r=24@+L CRDE LEMGTH TOFOR 1 Ta L
IF CHECK FOR WARLIDFRINT "IHVALID CHRRACTER 1M ALFHA LABEL"GOTO 8
MOM1+I+10=HE¥M1GOTO
IF (W3r14s R CT$="KER") THEN ORTFORN HUMERIL G10:MCHLa= 17744 VSECOND EVTE COMTATME UNCOMPILER FOIMTER
BYYE (HI GRLER EI F HE#
IN ALFHA STRING
[LONG FORF <3 BYTEY HUMERIC GTO OF MUMERIC RES24
YSECOND BYTE AGAIN COMTRINS FOIMTERITHIRD BYTE CONTARINE REGISTER MUMEBER
THEH MeM1:
L3ETO" THER 1CH FOR STORE IHMSTRUCTIONIF w315 THEN 3855 ISHORT FORM (OME BYTE) STORE (HSTRUCTIONMI EEEEEERYM1=M1+1
PLONG FORF 2 BYyTEs STORE
RUCTION
IF T<3"ROL" THEN 3149 PCHECK FOR RECALL IMSTRUCTIOM15 THEW 3115 LSHORT FORM ©1 BYTEY RECALL Ir
RUCTION
TLIONG FORM 2
TE RECALL IHE
RUCTIOH
GOTO 3325IF T#<>"LEL“ THEN !
IF F4<>1 THEM 221@ PHLFHAE LAEEL IMZTRULCTLON
Sample Software 27
PUMLOMPILED LABEC CHALW FOINTER I[N SECUND BYTE
1410 =8LENMIT1%:
TKEY
GHMEHT BYTE (SET TO ZERO FUR BAR COLES
GOTO 2988IF 214 THEMMCM12 =14yMi=Mi+1cOTO 33MLyMOMi+L" 1+2
IADD CHARACTER DATA TO MACHINE CODE RRRAYISHORT FORM CONE BYTE:X HUMERIC LABEL
HUMERIL LABEL
Q
PALL OTHER COMMANDS ARE TRELE DRIVEN
a
SFHSH, T, T3
IF 238 THEHFRINT "UMRECOGHIZRELE IMSTRUCTION GIVEN [H LIHE # "5JCOTO 2238MoMLs=1 ORE IMETRUCTION TYFE IH MACHINE COLE ARRAYM=+
| | CHECK FOR CTION4 TF CI18Z2<d4) OF (1102551433 OF& FRINT "ERROR: EXTRANE OPERAND IH& 50T8 IF 144 THEM ICHECK FOR THO TRUCTION2 IF 144; 10 oR Y 273 PRINT "ERROR: MI OFERAND "S GOTO
27 ML=y136 MI=Hi+135 MEWT T L wEND OF THE INSTROCTION LECOLE LOUF=<»45 1 % , = * « = »
3355 McMio= VAR FIMAL EMD INE UHCOHFILED FOINTERFIEE MIMI+LI=6 N SECOND EYTE3 MCHLE3 M13 FRINT "COMFLLATLON CONFLETED"
Fa=1 USET COMFILATION BOME FLAGGOTEH 358
| »#+ERROR CORRECTION SUBROUTINE#%FRINTER 15 18Mi=E4 IRESET MACHINE COLE AREAY (U OLL YALUEFRINT “THE IMSTRUCTION GIVEH WMF
FRINT “"GIYE THE CORRECTED INSTRUCTION (WITHOUT LIME WUNEER:INFUT " (TO ABORT THIS COMPILATION, TYFE <REORT Y THIF T$="RBEORT" THEM 358AE=AsLTEe" 1"Felo=TT=THLEH.TH0+1
TURHD% F v % % o+ % o= % END OF CCOMPILES ROUTINE % % = 2 % % % % % % & # +
# % % % % % % * FROGRAM COMMAHDS s % 2 ¥ ® % ¥ %| THIS ROUTIHE L OUT THE COMMAMDS AYAILAELE IM THIS FROGRAM AMD
HTHX OF THE COMHAHDS AND OF IHSTRUCTION EMTRY
"COMMANDE AYAILABLE IN THIS FROGRAM: "
PRIMT " COMFILE - COMFILES THE HF-41 PROGRAM CURRENTLY EMTERED®PRINT " DELETE rn ~ DELETES THE HUMEERELD I UCTION FROM THE PROGRAM®PRINT » EXIT - HALTS THI% PROGRAM OF HUMEER GEMERATOR"
STOF
28 Sample Software
FRINT * GETFRUL RETRIEVES THE COMFILEL LULE FRUN CRSSETTE TAFESFRINT * GETTEWT - RETRIEYES THE FROGRAM IMSTRUCTIONS FROW TAFE"PRINT * LIST - LISTS THE ENTIRE HF-41 PROGRAM CURREMTLY IW MEMORY®FRINT * HUNEER - GEHERATES HF-41 INSTRUCTION WUMEERS - STOFFED BY
3 FRINT * TYPING “E#IT "3545 FRINT FENLUMEER - RENUMEERS THE HF-41 PROGRANM INSTRUCTION HUMEERZ™3 FRINT * FUH - GENERATES THE BAR CODE FROM THE COMPILED CODE"3555 FRINT * RUNFRIYATE - GEMERATES THE EAR CODE FOR A FRIVATE PROGRARMY39 ' SAVEPROG - STORES THE COMFILED CODE OH CASSETTE THFE"
565 PRINT SAVETEXT - THE FROGRAM LISTIMG OH C TTE TRFE" Ar
S5&6 PRIMTs74 THE EHTIRE HF-41 Fi
PRINT * SCRRTCH -
PRINT * 27 - OUT THE COMMAHDE AYAILAELE *FRINT * *FRINT “SYHTRX FOR INSTRUCTION EHTRY:"
FRINT * A)INSTRUCTION FORMAT:FRINT * r CHF-41 IHSTRUCTIOHX"FRINT * CBLANK AZ DELIMITERZ)®PRINT " EXSFECIAL
PRINT * 13 USE INSTERD OF THE SIGHMA =(iNPRINT * 2r USE IMSTERD OF THE AMGLE ZIGHPRINT * 3) USE INETEAD OF THE “MNOT ERUALY 2IGH"
FRINT * 43 USE STHGLE QUATES 73 IMSTERD OF DOUBLE SUGTES®FRINT * CoTEXT FORMAT EXT El CHOTE BLMBLE @uar :FRINT * oR A7 <TEXT EHTRY: CFIR RPRENDING TEXT»*GOTO 358D% % % % > % % 3 % % EMD OF COMMAND LIST ROUTIME % % = = = = = % & »I % % % % % % % 5 % % 'REMUMEER® ROUTIHE oA oE ox o! THIS ROUTINE REWUMEERS THE HP-41 IHS HG THE| RRRAY OF FOINTERS INTO THE TEXT STRING. THE STARTIHG OLD WALUE, HEK||
e
STARTING YALUE AND IMCREMEWT ARE REWUESTED, AND AH HUMEER OYERFLOW
4@y OF REMRITING OVER EXISTING INSTRUCTIOHS WILL A 2T ROUTIMEIHFUT “ENTER THE OLD STARTING #,HEM STARTIMG #, AHD Ik RFOR I=¥2+1 TO Wi-1 ICHECK FOR OVERKRITTEM IMSTRUCTIONSIF FCI 1 THEH =715
FRINT “ERROR - ATTEMFT MALDE TG OWERWRITE EXISTIHG IHSTRUCTIOG070 358
HERT IFOR I=1 TO 2248 LCRERTE TEMPORARY FOINTER ARRAY
KicIy=FCls THEN Fili=-1
EF %3 |TRANSFER VAL LD FOINTERS BACE TO FOINTER AR
THEH 358 ICHECK FOR EMD OF FROCESSINGIF K1ck»<a THEW 3745
=K1KHEXT 1PRINMT "ERROD IHSTRUCTIUN HUMBER CUT OF BOUMDE®FOR I=1 TOPCIr=K
HEXT 1GOTO 358# % % % % % % x » = END OF “RENUMBER ROUTIME + = = = = = = » = z %'
Pox s o % ¥ 4 % 5 % % “SAVETEXT ROUTIHE # % % % % = = = = = + % 3 £ #
¢ THIS ROUTIHE SAYES THE TEXT OF THE HF-41 IHSTRUCTIONS (THE SOURCE! FILE> QW CASSETTE THFE.IMFUT “GIYE THE WAME OF THE FILE TO EBE SAYED: ",T1%
ERTE Ti#,T DIY £4+458ASSIGH #1 TO Tis$PREIMT #1;P (%) !FRIMT #1;A$,END
SIGH * TO #1
AYE THE FOIMTER ARRAY AHMD THE T[EAT STRING
% % % % x x END OF “SAVETEAT' ROUTINE = = = = % % » = = % % #
Sample Software 28
e e e s s w2 % 2 CGETIEAT TIHE # + « # « % = = = + % % % = =! THIS ROUTIME RETRIEVES THE TEXT IHSTRULTIOHS CE FILES FROM! CRASSETTE TAFE AND REZETS THE END OF TEXT FOIMTER.IMFUT “GIYE THE MAME OF THE FilLE TO BE RERLD",T1#ASSIGH Ti% TO #1,1IF 1431 THEM Z3&@FRINT "FILE HANGOTO 3:}IF @ THEH Z93@FRINT “FILE 1S5 FROTECTED OF OF WRoin [7FE"
HOT FOLHD®
GOTO 25@
RERD #1;Fc% {RETRIEVE THE FOINTER ARREAT AHL TEAT STRINGREAD #1;A%
T=LEN(A$> 'RESTORE FOINTER TO END OF TEATGOTO 258 D% % % % % = % % % ¥ ¥ END OF “GETTEXT’ ROUTIME = = = =Dox % E %ok & B % % % EFROG’ ROUTIHE % % % % = = = +! THIS ROUTINE SAVES THE COMPILED CODE «(THE JOE FILE: IM THE “M° ARRAY! OH CASSETTE TAFE FOR LATER USE.
S IMFUT * GIYE THE MAME OF THE FILE TO BE SAVED: ",Ti%4868 CRERTE Ti$,5604065 ASSIGH Tis TO #1
FRIMT #1
PEAYE THE HUMEER OF BYTES IN THE FROGRAM
% EHD OF “SAYEFRDG T ROUTIME = % % % % % % & % % »¥ GETPROGY ROUTINE # % % % & % % % % % % % % & » +
! THIS ROUTINE RETRIEVES THE COMPILED PROGRAN FROM CRINFUT "GIVE THE WAME OF THE FILE To BE READ",T1%
Fa=1 PSET THE COMFILED FROGRAM PRESENT FLAGASEIGN T1$ TO #1,1IF I<>1 THEM 4178 |CHECE FOR FILE ERRORSPRIMT "FILE MOT FOUND®GOTO 35@
IF 1=8 THEW 4138
FRINMT "FILE FROTECTED OR OF WROMG TYFE®GOTO 359
IGET THE HMUMBER OF EvTE= It THE MACHINE LUDE ARRAYM
ASSIGH #1 TO =GOTO 358
P# % % % %+ = = % v END OF “SAYEFROGY RUUTIHE = = * + % = % 2 = %| # 2 % % % » + » ERRUR COHDITION HAWDLIMG ROUTIME % » « % # « % 2 #E1=ERRN |5AYE ERROR MUNEERE2=ERRL ISAYE LINE WUMBER WHEREIF E1< THEN 5FRINT "MO TARPE IM TAFE DRIVE. FLERSE INSERT TAFE"GOTO 358IF E1<{rE4 THEH 42%PRINT “HOT EMOUGH ROOM OH THPE. PLERSE USE AHOTHER TRFE"GOTO 358IF .E1< >33 THEN 4385PRINT "TRFE 1% WRITE FROTECTEDL. FLERSE FIX®GO0TO 358IF E1<»53 THEN 432@
FPRINT "IMFROFER FILE WAME (SHOULD BE 51X CHARRCTERGOTO 256IF E1<>54 THEN 436@PRINT "DUPLICATE FILE HAME"
IF (E2<>3358) AND (E2< 40603 THEM 4345IMFUT “DO YOU MISH TO USE THE OLD FILE? ", T2%IF <7z "y DR (T2$="YES") THEM 435&
42345 GOTO 358
4358 IF E2=35356 THEN 35554355 IF E2=48685 THEM 4865
OR LESS"
YOOLNTHIFUAHBSLYIANGTHOTLINAGSTHL SHOLLOMASLHWA0SH3GunN€%=ssoeoxvxo=oxoxxo3asxoxxoxx|
LOETH[LYER
¥ALTUTIM3LL401¥311395C1-r+1°1+1180=55r
SESEMIHL.io=LTE0+IT8Y41@50LT=r404
(851835UIT£4393LHT
€1#39ILNI$KIFIH430THOTLINNS3HL0LQ3SSHdWIAHTi
EHLLHd}LHIOdEHL&HDLUSLNIGdHQIlJflHLSNIEHLLSHELRBHNBAHH&H\\
Zu
L¥3LIHL48SHOOTWOILTHASSIHL IHGILINASHOTLOHHIXIROTLIMNYLZHIOILTHIAFTHOTLIHAS ssssxs
SRE%EX%R¥OFBBG3¥E3EG3%E%XBRXEREBB|H3
HLHTLIHLHI
SHLHDfuowHIHD
#r#IO00HILIHEEHDTHYiH1HTWLHTKLHITLTHLHTBLHT
dYERTFLAN0YSY1HDTOMPZT HEINHIBTSESt
CHIEBTTSHLISHTBST95TPRINTHIHTGe5tSHHYBET“THADBT*0L84°221254HLIHT5
14°e.£1IB488T-%v3HIHT&I30°987T-0HIHDFITITEETTHIDBLHD
TIMITAHSPESMELEPSTOLSHHIHTSET440KSRFATHEETS00HHiHD@
AT629F5etTaesHIRE&TLEHRALTHINS92THIWGTHOMINHHOTLANELSHI%3i@
Plafams,LtLeweWtHLEDBAtzLTReg3tHIHT%
TYILIEMUHDHILSIOIHIHLEONH13FHTTHONTexsi@31&
9
JTTIHTER0
=0
HOIHE
FOEOF¥X¥6OF¥%F&&E%%¥¥%HIHI¥¥%##»%¥¥¥¥%|
Se&¥soow&xvWOLMMENIGHNTLIHAJHT40O3£5=x¢o3%o2o5|HANLIYT1w3H
WCO<CBEA=$ENIHLT=(1F41"CoREE=EHIHLB=CIsd41
TTOSHMT0MEST733N¥IIOHEHHTBTNELTLJHLHO¥HEHOTLH343HL|7a1T=1H0d
TO
TFE
owo
owTToot
o
SHNETEiSdHT7LdA3n¢i
SHHTTHITLA34TtdHdMOdMHNCTi510HY3LIHSi
iiiii
JHL CONIHLS3HLOLHOSHNETEIHHSHMHETHITLA344043340HLI34300FHLSILUHILEIHODQMY8.AHH¥YJHLWOH4H¥3ILLHD1193HL$300330
LT"H3LHIAL133IHMASIHI@527OTEHII3HLMOMILLTHM3171LIHYILIHGT0T#HTIHLSHILNISIHL434IMIELEHSILHEINIDIYNTII084SIHLs%3%¥o3&o3&xATIHNINITOHINLEMHILLIHAHHT&£=¥®£3¥£3
Svowvoxoxowsx5sw6FUIIAOHHOHAT40AHI#5%o+o=o%o2o3&%
&IUTTIHHIISTET3E.BWONMI.LHIHD
aremyjogoidwes 0g
Sample Software 31
FEe 1 HHRACTER = 1R iHG. Is USEL OMLY 1M TnE LIRBELG FRIMTOUT SECTION.3 RAMETER WEEDEL 1:
' 13 AM INTEGER MWUMEER T0 EE COMYERTED IMTU A CHARARCTERLEF FHWF$CINTEGER H»INTEGER I,J,KDIM H$LS]IF M»=1@ THEM 4&4a ICONYERT ONE DLIGIT MUNEERSHE=CHRS (H+483
B RETURH H$IF H>=1@8B THEMH$=CHR$CH DIVRETURH H$IF H»1888 THENI=H DIV 1&gJ=H mMOL i@@ DIV 18HE=CHR${ I+48)LCHRS (T+4 2 LCHRECH MO (6+38)RETURH H$I=H DY iB@@J=H MOD 1888 DIV 188K=H MOD 1@& DIV 1@
RIMG
PCOMVERT TWd B1GIT;eCHRS N MOD 18+48)
H PR3 I+4800CHRECT T 420 L0HRICE+ 480 ROHRE (1 MOD 1G+48)
3 RETURH H$
4915 FHEWD
4525 & %+ = % % % x & & = = = s x' .t ROM AND IHSTRUCTION PRINTOUT FUMCTIOM: THIS FUNCT1OM! CREATES A STRIMG CONTAIMIHG THE ROHUMEER AND BEGIMNING
4545 | AND EWDING FUMCTION MUMBERS. IT IS5 USED OHLY IH THE BISEBLO||!'
FRINTOUT SECTION. PARAMETERS MEEDED ARE:12ROM HUMEER
FIRST IMSTRUCTION HUMEERZrLAST IMSTRUCTION HUMEBER
4970 LEF FHP${INTEGER R, INTEGER I,INTEGER FuDIM R$L3E]
RE="ROM "&FNFSCRIL" ("RFMF$CL2IF I=F THEN 43335RE=RFL" - "LFHF$CF)RE=REL "RETURN R$
FHENTDs E % xw s = E &+ aa + P B! BINARY ARCH FUNCTION: FUNCTION SEARCHES FASSED CHARACTER ARRAYi FGR PASSED AND RETURNE INDEX OF KEY FOUMD INM ARRAY OR @ IF' HO KEY WAS NI, FARAMETERS RERUIREL ARE:' LYINDEX OF FIRST POSITION CINTEGER! 23 IMDEX OF LAST TION <INTEGER:! 33KEY TO BE FOUND ¢(STRINGD! 4)STRING ARRAY IH WHICH THE SEARCH 1% MADEDEF FMSC{IMTEGER I,7,08,R$C22INTEGER F,L,HF=1L=JM=CFeLy DIV 2 PFIHD CEHTER OF ARRHT
=AECM) THEN RETURH ¢ PIF KEY HRS BEEN FOUWL, RETURH [HIEIF QE>A$CM) THEN F=mM+1IF Q$CASOME THEN L 1IF Fi{=L THEH 58578 VCOMTIHUE SERARCH THROUGH AFPROPRIATE HALF
IRETURM & IF ZEARCH FAILZRETURH 1
FHEND| sEsssessssrs END OF BAR CODE GEMERRTIO FROGRRAN *#4s2%%ss4aasssass
32 Sample Software
Generating Other Bar Code Types (FULFCN)
This program producessingle rows of bar code containing complete key phrases (irect Execution — type 4), numeric
data (Types 6 and 9), and/or alpha data (Types 7, 8,10, and 11). It prompts the user for input and responds to a “?7”’
by displaying theinstruction set on the CRT. FULFCNdiffers from PRGMBRin that a row of barcodeis generated
immediately after each completed line of input.
Wheninputting a complete HP-41 function the user types the function asit would appear in an HP-41 program line
{without line number). If the user wishes to produce data bar code the inputis typed as follows:
HP-41 Type Bar Code Input Expected by FULFCN*
Numeric Data DATA 123.45Alpha-replace Data . DATA "HELLO"Alpha-append Data DATA A’THERE’Numeric Sequenced Data DATASEQ 123.45 1
Alpha-replace Sequenced Data DATASEQ 'HELLO' 2Alpha-append Sequenced Data DATASEQ A’'THERE’ 3
*The number 123.45 and the alpha lettersare the “data;" the individual numbers 1,2, and &in the sequenced data are the sequence numbers that will be placed in the bar code.
FULFCN is 4 table driven program with all the functions containedin a data table. (Each entry in the table includes the
function plus four parameters.) When the data table is read in, the function name is placed in string ““T$”’, the first
parameter is placed in array ‘“‘Datar”, the second parameter into array ‘“Datac”, the third parameter into array
“‘Arg”, and the fourth parameterinto array ‘‘Alpha’’. Thefirst two parameters correlate the functionto its position in
the HP-41 Function Table (Table 111, page 45). The third parameter indicates the number of argumentsallowed for that func-tion. The fourth parameter indicates whether or not an alpha argumentis allowed.
When the inputstring is given,it is parsed into three strings using spaces as delimiters. At the end of this parse routine
““F$” contains the function name, ““A1$"’ contains the first argument, and “‘A2$” containsthe second argument. If
there were no arguments input, strings ‘‘A1$”” and ““A2$" are blank.
At this point “‘F$” is examined.If it contains a “*??”” then the instruction set is displayed, followed immediately by a
prompt for input. If ‘“F$*’ contains ‘“DATA” or “DATASEQ”the program branches to the section that generates
Data bar code. Otherwise the string ““T$” (which contains the function names from the data table) is searched. If the
function namein ““F$” is not found in *“T$”, a message that the function was not found is displayed and the user is
prompted for another instruction.
FULFCN Syntax
The syntax of the HP-41C instructions recognized by "*FULFCN’” isthe sameas that recognized by “*PRGMBR”. The
same execeptions are found in this program: “E£”, ““ 5>, and ““#** are represented by the ASCII characters “&”",“@”, and “#" respectively. Also, single quotes instead of double quotes are used for texts and alpha labels. The
Alpha-append instruction is indicated by an ““A”’ preceding the single quotes and character string.
Sample Software 33
FULFCN Program Listing
THIS PROGRAN FROMFTS THE USER FOR HF-31 [/FE © Tt Wiol BETEANSLATED INTO A CHARARCTER STRING REPRESENTIHRRARARRERFEEFFR I LRILA I U R R LRI R A SRAR
''s'' : If @ INFUT STRING! AE @ DUF STRIME YARIAELE||||||!'
Al% © FIRST ARGUMENT STRIHGSECOMD ARGMEHT STRING
F$ : FUNCTIOH HAME STRIHGOUTPUT STRIMG i7"z AMD & =
cMy: DECIMAL YALUE OF EBYTE<M: IM EAR CUBE.sum: CHECK S0M
HUMEER OF EYTES I CODE
LEHGTH OF IWFUT STRIMG
LEMGTH OF FUNCTION STRINGLENGTH OF ARGUMENT STRING
INDEX WARIABLETyp=: BAR CODE TYFE HUMEERIi«»: DIGITS FOR DATA TYFEJ : IMDEM VARIABLE
'i'''' K IHIDEX VARIAELE' ¥g t DUMMY YRARIAELE' T3 : TABLE FOR FUNCTIONE HAMES! Datar(+3: DATAR FOR FUNCTIONSi b ci%3: DATA FOR FUNCTIONi Argl*s: NUMBER OF RRGUMEHi INDICATES IF ALFHR ARCUMEH' EBIMARY BALUE OF DUTFUT STRIMG
DECIMAL WALUE OF BYTE f%)
Rl HUMEERUMH HUHEER
ALLOWEDR FOR FUNLTLUN
Alphais ARE ALLOWED
Ear (%)Tec(xa:E$: OUTFUT STRINGLine: OUTFUT LIME HUMEER
''DoARRRRRRRNR AR SRR RS A S n s st Esa stttbt
'
MAIH FROGRAMNT
OPTION BAR3E 1FRINTER I3 9DIM 130983, A1$0581, AZFISAI, FEO1AD, BSIF1S], xE018], TSDIM A$0SH]DIM Bytedler, D360, Datari2sDIM Bar<15@0OM ERROR GOTO &138Lire=a
LB, B5H15012
sDatac
2560, Ar
! READ IH TAELE FOR HF-41 FUNCTIONSFOR I={ TO 256
READ T$(I2,Nataril>,DataIF T#I)="*END*" THEN £3&
HEAT 1 |IF THE LOOF EXITED NORMALLY THEN *END= M7BISP “ERROR IN TABLE DATR. MISSING “#EMD=STOF
1), Rrgtls, Alphacls
FOLRD
| COME HERE IF THE TAELE WAS RERD CORRELCILY! TOTAL IS THE MUMBER OF EHITR
| FROMPT LSER FOR IMSTRUCTION REGUESTIHPUT “WOULD YOU LIKE IMSTRUCTIONS 7%,
$01,11 | JUST CHECK FIRST LETTER$="H" THEW 1888UIF IHPUT 1% ANYTHHG OTHER THAM “NOY THEW DISPLAY INSTRL
"THIS PROGRAM FROMFTS THE USER FOR HF-41 EAR CODE TYRE"CCOMMAN TUST TYPE THE COMHAMD AS TOU WOULD OM THE"
"HP-41 WITH THE FOLLOWIMG EXCERTION!
Total= It THELE
" FOR HUMERIC DATA 1ODATA %, .88 *ALFHA REFLACE DATA : DATA “®&.. . &&°"ALPHA AFPEND DATA @ DATA ##...%%""SEQUEMCED DATA USE THE FOLLOWING FORMAT: "
34 Sample Software
85 i DHIASER LATA SEus”
354 FUR [HSTAHCE, DATRSER 1 45364
a SIMILARLY, ALL ALPHA TEXT STRING ARGUMEN L i56 YARE DELIMITED WITH “=."29R YFOR CSIGMA,ANGLE, AND HOT ESUAL [H TEXT STRiNGS 0 B, AHL®1@ U RESPECTIVELY."11a1z "FOR FUMCTIONE WITH THE GREER LETTER913 “ht, AMD m-L "14 "FOR THE HOT ERUAL Z1GMH USE #, AHD326EEL] MENTER: FOR INSTRUCTIONS AT AMHYT TEEE]
1 CENTER =3TOF T TERMIMATE THE FROGR
wSRR
EG
“TERMINATE ALL ENTRIES WITH THE COMTINUE| PROMPT LSER FOR IMSTRUCTION TG
BE COLED 7*,1%STRIMGE IM CHSE THEY
INFUT “FLHCTIONFE="" 1 IMITIALA1
fAg=1nI #rssxnsras PARZE OUT THE FLNCT M EHY
I3=TRINSC1$) ¢ DELETE LEADING ANDL=LEHCI$)IF Is="#5T1F 1%
fF* THEN PRINTER IS 18“* THEM STOP
1F L2 THEH 230FOR I TOL i 1 FUNCT
IF CI,T1=" " THE < FifF$=F$41501,1]
HEXT 1
LUTO 1558 ¢ IF HERE, THERE ARE MOAFSTRIMSCISII, L] ! DELETE ANY LEADING-TRAILIF TL=LENCAS)Y | CHECK FOR TENMT &T IF
| TUMF AHEAD AMD F TIF (RS0, T1="""> GR LRELL, 1 At oA
FOR I=1 70O L I OTHI
IF A$CI,I3=" THEN 13441$8AF0I, 1)
IF HERE THERE GHE ARGUHENT ENTERELFRRSE QUT THEALL ARGUNEHNTHIS LOOP PARSE
F oASLI, 11 " THEW IFOR I=1 TO L-f ! SERRCH TEST STRING FOR EHDING
IF A$CI,11=""" THEH
HEXT 1
AlE=f% HERE I[F THERE I3 GHLY OME AREGLUREMT AND IT WASGOTO 1558 A TEXT STRING
HERE IF THERE THO ARGUMEHTS AND THE FIRET WASA TEXT STRIMG
1348G4sEesEErasaananrs END O
SEE IF THERE1598
E ROUTIME #x+4%xINDEED AH INSTEL
GOTO
EELEMCFE OLEMGTH OF
EM(R1%: ! LEHMGTH 0OF
EHMCR2E LEMGTH OF
TRING
ENTARGUMENT
Sample Software 35
P00 THENW 798 MERHS TG REPEM]DIRTAY THEM 365& tOIUNMF AHERD IF IT 1='IAT @Y THEM Z&
HEHHARHAEERE HERE FOR FUNCTI TYFE CODE ##s##sitsashanhshtsnanns! SERRCH FOR THE Ib UCTION IH THE THELE
v 2zF#=T$(Z) THENF$<T$(Z THEHF$>T#$0Z» THEHse=Y THEM 1739
FOINTS Td THE CORRECT TRELE FOSITIAN
tOIF THIE| FLAG THAT THE Fiif
HOT FOUND IW TAELE",F3
A OUATLH THENFOUME I TRELE
BE@ LISk "FUMCTIIISF
07O | PROMPT FOR RHOTHER Ik HCTIoN| HERE FOF A ECT FUNCTICH
2138 | TUMF AHEAD TOHS WITH ARGUAENT:IF Arg(2s:8 THEWg i HERE FOR FUNCTIF (Lal=a) AMD ¢LaZ=83 THEN 2618DISP “THERE SHOULD BE MO RRGUHENTS FoR TDISF "PLEASE ENTER THE FUNCTION AGAINGATO asE
WITH HG
But=(2)=64 FOR FULL FOHNTHE FUHC
S€18+Datacid) i Euued
I M IZ THE HUMEER TES| CALCULATE THE CHECKSUM| CALCULATE DUTFUT STRING HERE
3 ! RETURH TO PROF FOR A TRUCT LanFoE oxoF womow ok o om % R B X R 3 E E F £ E ¥ E E X E X OE F ¥ F o
| HERE FOR FUMCTIONS MITH ARGUMEMTSCHECK THE TwPE OF RRGU
9 | OCHECK FOR ERERL FOR
GOSUE 48IF <RL>4: OR 4RIF ArgoZi=2 THEH
| 111811111111 HERIF Lal>@ THERDISF "ARGUMENT REGUIRED,GATO 238
IF A1$="IHD" THEM 3818IF Al=8 THEH
AFGLMENTS
2 ARGUMENTS£1111111118183111111
T UAZ EMTERED
| IMDIRECT ARGUMEMTS! OMUMERIC ARGLMEMT! ALFHA MUMERIC A! ALFHA HUMERIC AR! OSTRCK ARGUMENTS''
LRMEMTSUHEHTS .5 THEN
THEM
IF HONE OF THE REGWE REGUMENT §FES WERE FOUNDTHEM IT [$ AN ALFHA ARSLNENT
SIHGLE ARGUMENT, ALPHA TYFE RIALHISLALRIALALALAIF Alphac2r=1 THEN 2 | CHECK TO ZEE IF ALFHR ARGLDISF “ALFHA ARGUMENTS NOT ALLOWED FOR THIS FUMCTIGH®ISk ENTER FUNCTION RGAIN"SOTC 3
Byted
! 1AIALAIALIAL HERE FOR
#16+0atac iz
1 oStactt OF THE ALPHAVEnd IS THE Byts NUMEER FOR THE LASY EYTE OF THEU ALPHA ARGUMENT TEXT STRIMG''
E SE18LEHCALS)
GOTO 248
£ INIHIHIHIN HERE FOR SINGLE ARGUMEHT, MUMERIC TWPE IWIHIHIMIMIMIMIHIN1NIF R1<»4 THEM 2598 | CHEC OFERATION
A THEHTHEHTHEHTHEHTHEH
CREATE ALFHA STRINGH 1= THE HUMEER OF BYTE
IH THE COLE
36 Sample Software
THENZE" THEM
“"LEL" THEM zgWALCAL$) )
AHT THEMARGUMENT OUT OF RAMGE
©OLHECE FOR! OCHECK @! CHECE FOR
B8 | CHECK FuR
WGE OF ARLUMENT
| MEVE JUMPEL HERE A-1| WEWE JUNMFED HER a-s
©OSET FUHCTION CODEECL FOR PROFER FLN OF FUNETIONS
! THAT HAYE DIFFEREMT! RRGUMENT TYF LIKE: HE@, 5TQ,
DIFFERENTL
IF Fi="2ER"IF F$="GTO"IF Fe="LEL"Eytedd
H 15 THE WUMBER OF BYTES L# COLE
HERE FOR DEL,GTO.
E#latar(Zy+Datac 2’
"GTO. ") ANDIF <F#="GT."» AND
TO. " AND
Byretds=VALIALEY DIY 2Eyte(Si=VALAT$: MOD =
| ZET CORRECT ES EBYTES IN THE CODE
INDERECT #IHGLCHECK FOR ARG2 CIHDC v, T#
DISF "MISSING
3IE4H GOTO 995
tOCHECK FOR STACK ARGLMENT
tOUHELK FOR MUMER L ARGURENT. Gy ALE| AND HUMERIC FRGLMEMTS AR LOWED 30 IFAH?THING ELSE 1% ENCOUNTERED, FLRS THE ERROR
F IMFROFER ARGUMENT FOR “IND- ", 1%
THEM 3178 '
FANGE FUR ARGUMENT
; ZEG"> OF cF$="GTO") THEN Byts(3g+x
GTO" THEM Eyteid)
4 EYTES [N CODE
& HERE FOR THO ARGUMENT FUMCTIGHS 2zzAHD <LaZ>@3 THEW 3378 | JUMF AHERD @ ARGUMENTS
YTWO ARGUMENTS ARE REGUIRED. FLEASE EMTER FUNCTION AGAIH®GOTO 93@IF Al=1 THEM
(A1<»@) OR
CHZC a0THEH 3338
atarZieté+latac (20 +YALLALSY DIV 4
EITE FOR GTL. .
Sample Software 37
ALwrlE, MU 4asd+¥ALLAZE, #Ol 64
GOT
DIsFGOTO
2256TINFROPER FiRST ARGUMEMT.
FUNLTLGH RSHIN
SEC UHEMT MUST BE HURERICCOND ARGLMENT. CTION AGALN
[RRRRRRERES
CAzny DIY 1@RES(Asr> MOD 18
<8 THEH Up={REEytsidr=lps16+DnStart=5 !
HUMEER OF THE FIRST BYIE 1N
STRINGEnd IS THE Bute HUMEER OF THE LAST BYTE IN THE
Erd=LEHCAL$+4STRING
CREATE RALFHA STRIH 15 THE HUMEE®
GUSUE SeiaH=d+LENCAL1$)GOTO 2848
EYTES [N TRE CODE
REEREEEREA IR AT R ATA ARARRAR EAR AAE AR IR AR IR A AR A BAA| HERE FOR DATA TYFE EAR CODE
SOSUE 4898 | CHECK FOR THE ARGUMEMT TYFEIF LEHCA1$) THEH 4108IF (A1:4Y CAZ>41 THEN 334 HECK FOR ERRORSIF A1 THEMN Zg@@ HLUMER: TYFE DATAIF THEH 4341 t ALPHA REFLACE TYFE TATAIF THEM 4171 ! ALPHA AFPEML TYPE LATRHOHHHHHHNN N HMERIC DATA M M M N N H MM S Mo 8 NN N NN
! HERE FOR MUMERIC TYPE LRTH! SET THE DIGITEIF LEM{A1$2¢>1 THEM
a
!
C=ST0 THEM Dols=vAL oHTHEW DlTHEM Delx
AI$0I,1 - THEM DIAL$0T, 1 E" THEM T¢ICDCIXCRY OR cBCIxsl4r THEN 4189 FESIT LOGOF On 1
ALSCI, TR1%LI,1
FER Lluil
HENT 1IF F$="DATASEQ" THEMN 4 Y IF LEMCR1$3>1 THEM 28
1641918%16+D001
&6,@
GOTO 2848
©OSET TYFE CODE. SINMCE Twit DIGITS CAN EEFRCKED IWTO A SIHGLE BYTE, A MULL HAS TO EE
| APFENDED IF THERE ARE AM EVEH NUMEER OF DIGITS
IF LEM(A1$) MOL 2=8 THEN Bute2)=6x1&+18 | TH A HULLJ=z I J TELLS WHERE I DewsIF LEHCA1$) MOD 2=8 THEW J=1 | J TELLS WHERE I DeEsk=3 ! K IS THE Bute POINTER
FOR I=J TO LEM(A1%» STEP 2 | THIS LOOP SET IHTO ButeB E#DCIa+DCI+10¥
H=2+LENCALS: DIV 2 U N I3 THE MUMEER OF EYT
38 Sample Software
HUMEBERS
| Bptei23 AMD ¢ ORRE THE TvFE AND SEQ # 35| K I3 THE Evts HUMBERI T 15 THE POIMTER IMTO Dis4871 L JUMF AHEAD FOR AN EVEN BUMBER OF DIGITE
! HER AW DDD HUMBER OF TIGITS
#18+Dc10LEHCA1%) STEPLESDCTS+DCI+10
LOTHIE LR IHTO Byreiss
HEXT IH=3+LEHCA1S) MOD Z+LENCALS) D1y MLGOTO 26468 ! JUME ERCE T DO
| ERRGR IH MUMERIC DRTHDISF “ERROR 1N WUMERIC DATA",I$GOTO 338
| AR AFAAAARARARARAGALFHA AFFEMD A A A A A A A R A A A A B H At HERE FOR ALFHA APFEWD IATH
UF THE BRR CODERHD GUTPUT
IF F¥="DRTAZEG" THEM 4311Byte(2i=128+LENIALE) Bytsi2) THE MUMEER UOF
! SET THE I1 EQUIVALENT OF THE rart Start IS THE Byte MUMEER OF THE FIRST EYTE
IN THE TEXT STRINGEnd I% THE byte HUMBER OF THE LAST EYTE IM THETEXT STRIMGSET THE Butes WITH THE
Erd=LEHCAT$)+2
P Seia
|EST OF THE EYTES WITH THE A
||!'''
EHCRLISI+2 H IS5 THE LEMGTH OF THEGOTO 2848
S=q=VALIAZE) | HERE FOR DRTASED RLFHA258
N=LEHCA1%2+3GOTO za4@
MR AFAAAARAAA A ALFHA REFLACE A H A R A s AR AAHHRHAHRHAIF F#="DATI @Y THEH 4441
Bute{20=112+LENLALS)Ztart
t By w27 1% THE NUMEER OF ChHARMCTERS
! MUMEER OF FIRST Eyts IN THE TEXT STRINGEnd=LENCALIS) | MUMEER OF THE LAST Byte IM THE TEXT STRINGGOSUR S&1d ! OASEIGH I CHARALTERS TO E
EHCAL$1+2 ' LEHGTH OF COLE IH
Bute
[
070 4313#triEsrkeresasaraers EHD OF NALN ROUTINE swessssctssrratrnnannsenatARRRRbbbRebbbbbbt
CHECKSUM CALCULATION ROUTIME
Byrs(@i=10%16+(Seq-1) 01y 258GO
'4526 !
454m 1 THI$ ROUTIME CALCULATES AW EIGHT EIT CHECK''
ur FOF AN H BYTET BE IMITIALIZED TO THE HUMEER OF BYTES IH THE COLE
OUTINE IS CALLED.ERR COLE. H MUEEFORE THI%Z
CkamFOR I=2 TO H t W IS THE HUMBER OF EYTES IM COLE
Ckam=Ckam+ByterlsDISP "BYTE " I,Buteill
HEXT I
DIY 256+Cksm MOLDIY 256+Ck=m MOD o
o
ksm
SUM *, Bytedl)
RETURH
Sample Software 39
RATTTR TR T T TT T AT T T TR T AT T kTRtBARRRRRRRRARRS
ARGUMEHT TVFE ROUTIHETHIS ROUTIME DETERMIMES THE TYFE OF THE UHENTRETURMS THIS IHFORMATION TO THE MAIH FROGRAM INM HI FOF THE FIARGUMEHT AHD A2 FOR THE SECOND. THE ARGUMENT TYFES ARE ZEFIHED AS
MERMIHGHUMERIC IATHALFHA REFLACE LATHALFHA APFEMD DATHA THROUGH Ta THROUGH =STACK ARGUMENTSERRORS IH ARGUMEHT=
Lal=@ THEN RETURHNF$ " KRONYLal»2 THENWLa2»z THEH1235 AND ¢“HRGUMENT S TOOH
IF AL$="IMD" THEM S2d4@ 'IF ©Lal=1) AND CAL$="E") THEM S@aqFOR I=1 Lal
#I=HUMCALSCOT, 100(14433 OR (R1XS720 AND (H1s3655 THEH 4958
PHE COND ARGUMENT
Sz48 | CHECE FORIF Lal»l THEN S85&IF (HUMIRIE24y AMD <LIF CHUMCRLI$2 236 AND (MUKIF Al$="X" THEN Al=4
SECOHD ARGUMENT
THEW Al=THEN F
IF THEHMIF THEHM
THEMTHEHN
AL CR1S$La,20=" "0 AHL (A1ELLAND R1SLLa1,Lail="""> THEW Al ,11
IF A1>8 THEN S160
1ISF DATA. CH FOR MISZ1HGAL=5
RETURHF THEH
THEMTHEM
.S THEN A1$=A1%IF COFE="ETO"Y OR VO OHMD CuHL=d. Ok LAL=3 THEH Si2 Lal=LEM<AL#:
| HERE FOR SECOMD ARGUAENT9 THEM RETURH
FiR I=1 T0 LaZH1=HUMCAZ$LT, 1]
IF €(X1{43) OR »OAND 3 THEHWHEXT 1GOTO 5478
IF La2>1 THEHW %
ENTHENe THEM"2t THEM
IF Rz§="L"IF (HUMCAZ$) 2640 AND CHUMOAZE)C - W THEH RA2=3
40 Sample Software
IF CMUMORZEGOTO 5476
ARD L HUMCHZF 18
IF (R2%01,1 " AND THEH RIF (R2$01,1 "3 ANDIF Az:8 THEW 5470
DISP "ERR
IH DATA. CHECK FOR
OR THPROFER HUMBER®
RETURNIF A2=1 THEN R23=A2
THEN A2THEN Az#=AZS THEN A2THEN Az%
La2=LENCAZFYRETURN[! ALPHA STRIMG PLACEMENT ROUTIHE
1111
[2,La203, La
TeererebrrRrTieT e
Start T EndBute(Jr=HUMCAIFLE, K1IF ALK, K1="@" THEN BytIF AL$CK,KI="#" THEM BytIF AL$0K,kI="&" THEN Bute(lr=12:(=41
HERT TRETURHAAbRRRTTR T T T T T r ettt b e T ATe
OUTFUT STRING GEHERATION
-1
v 2
FOR I=1 TO £=HIF Barili=B THEW EF=HF& .IF Baril: THEH E$=B$&°:>
HERT 1B$ RESTS
! PRINT TITLEFRINT 1%,CHRES: RF(310LEHR COALEL SET HAL
'
PRINT BUFFERCDATAY> OR (F$="DATASEQ") THEM PRINT UslHG
¢ DATA") OF (FE="DIATASER") THEM =036IF Arg{Zr=@ THEN FRINT USING £814;B#IF ArgiZr=1 THEN PRINT USING ;BEIF THEN PRINT HG JE$IMAGE 288AIMAGE S5aRFRINT CHR$(271%
o
HRE$ (a3| CHECK FOR A FILLEDL PAGE
Line=line+l
IF Line<{15 THEH RETURH 1 IF THERE 12 LINES, Reiukd
FRINT CHRSC12) ! SEND OUTLine=@
RETURH
| RSEARAR Rrr e nt RARRSRSRAR RRS ni d A AR RERR! ERRORSIF ERRM<>18 THEN 5258
DISF "IHFUT STRING WA TOO LOMG, FPLEASE CHECK IT."
UISF "CHECE LINE HUMEER ",ERRLDISF vI= v, 1DIZP "LENGTH 0OF A¥F "L LEHCAE:
DISP "LEMGTH OF Al$= ",LEMC(A1$,
H1HTHIHTHiHT
IHIHTHiHT
woOHIHD{H1HTHidgdHiddP(WLHLHTHLHIHLHTHLIHTHLHTHiHOH1dTHLHTHiHO
SHLHT
HiddHlddHlddHLWTHLHIH1HIHIHTH1lHDH1HTH1HTH1HTHLHDHigdHigd
HldlHLlYTHlHIHLlEIH1HTH1HTY1HLHTH1HTHidmHiddH1lHdHigdBlddBidd
f2f1a0WidgTpUI0KWLIHT
HigdBLlddHLHTHLHTHLHDHIHTBTHigdHidgdHlddHIHTHIHT
=)
BE@
Iaremyoseidwes
T
a@g@ag@gaE
BHEDONOO
ORDD0D
0P0D0l
T3ITFHLHIWGMTMITNE0dd3741
‘afod3LH3‘p1efTm3
-‘mca
HIHT3791i
TFAA35,HITUANINIT3.d3dUNH40433,
33,A3EMAN3HIT
B2IEHIHLB2a1EsHIHL
ST39TONAHSFHHLOMIT.4511
Dm0
SDDD
LS
@D
[oo
a2
Section 4
Algorithms
Checksum Algorithms
All rows of HP-41 bar code have a checksumin the lefumost positions of the row. All but the Paper Keyboard have an
8-bit end-around carry checksum. The two byte Paper Keyboard bar code uses only a 4-bit end-around carry checksum.
Following are the algorithms for checksums stated in a block-structured language.
Eight-Bit (One Byte) Checksum
The checksumsfor all HP-41 bar code, except Program bar code,are local checksums and are calculated separately for
each row. For Program bar code (Type 1 and 2), a running checksum is used. That is, the checksum for each row is the
sum of that row plus the sum of all previous rows.
Let X be a running checksum. (This would be cleared at the beginning of each row for all butTypes 1and 2.)
Let N be the number of bytes in this row of bar code.
Let Y be an array holding bytes two through N.
Let Z be a temporary variable.
Let / be a pointer into the byte array ¥
BEGINIf TYPE <> 1and TYPE <>2 Then X=0Fori=2to N DoBEGINZ=X mod 256 + Y(l) mod 256X=2Z mod 256IfZ > 255 then X=X+1
ENDY(1)= X mod 256
END
43
44 Algorithms
Four-Bit Checksums
Four-bit checksumsare found only in Two Byte Paper Keyboard bar code. They use end-around carry but are summedin 4-bit nybbles.
Let SUM bethe calculated checksum.LetY be the array that holds the two bytes.
Let/ be the pointer to the Y array.
LetK be the loop counter.
BEGINSUM=0I=1BEGIN
IfK > 1Then /=2If K=2 Then J = ¥(I) DIV 16
Else J = Y(l) MOD 16SUM = SUM MOD 16+ JIf SUM > 15 Then SUM=(SUM MOD 16)+1
ENDY(1)=SUM+16 + Y(1) MOD 16
END Program Bar Code Algorithms
In orderto write your own software to generate program bar code you will need a good understanding of the HP-41and the internal structures of program memory. The HP-41 Owner’s Manual and Programming Guide is a goodresource, particularly appendix D, Program Memory Storage Requirements and Last X Operations. Other important
referencesforthis section are Table I11, The HP-41 Function Code Table (page 45), and Table IV, The Numeric Values
for A-J, a-e, and the Stack (page 50). It will also be helpful to refer back to program “‘PRGMBR”’ to see how these
algorithms are implemented in a working program.
In arow of Program barcode, the code for a simple one byte function appearsin program memoryas a combination of
the row and column location of that function in Table I11. For most two-byte functions (for example, a function with a
numeric argument) the first byte contains the function’s location in the table; the second byte contains the value ofthe
argument.
There are also several functions that are not asstraightforward and need further explanations. These are enumerated
following Table III.
Algorithms 45
LOwW ORDER 4 BITSv s
. ' 2 . 5 s . s W w e a so wow aioo waor cecoz Levos aLos teLos Lecos eLor tevos sLos teLio| weLn eLie teLis L
agn gto | 2 s . s 6 : s 9 o eex enimy arou xeaue
= roLoo RoLor Revoz AoLos AcLos RoLos meLos Reuor AoLas RoLos Acuio moLn AoLiz| Rowws Aoiis RoLis
2 som ston ston stoo stoos stoes s1o0s sToor stoes sto0s so10 st | s1012| S0 18 STO 14 STO0 15one
4 + - - ’ Xe¥r|X=¥2|X<=¥2[ I+ - HMS+ HMS- mOD % %CH P-R AP BYTE
s wo @ [somr| v ows & s w0 o1 s cos tan asw aces aman oec
a6 wx aes eact xe07| x>0 |tdiex| x<on| x=00 wr emac o-m R0 aws wa o ocr
£7 a |xesv| m ast| m eon [wenx ox xevr [xsve| son |x <o wean soev aview oogS5 oee aap Grap |Ewremi| stop A eeee cua aswe pse cuno aorr aon ore |erower| aov5
o ReLon St0nn ST+ a| ST an ST o | STan 156 an 0SE nn view an [2ReG an|ASTO an|ARCLm| Fixn scin Enen TonEn
10 xeom xeow xeom xrom xrow xaom xeou xmom s | crmn Froan [roreml Fstan Foran |STOXEQwoBvie
“ 000 61001 67002 67003 6TO0s GT005 61006 GTO a7 GT008 6TO 08 GTO 10 GTO N | GO 12 BT 3 BTO 14
2 - ALPHA LABEL AND END INSTRUGTIONS = <> mn| LBLon
" THREEavrew“
1 e vexr vexr re vea e rexr rea e re| rea e e orer rea fuero1 2 3 3 S o 7 5 o e || e R R S| [eeve
Table III.
Lables
function is found inthree different locations in Table 111
Short Form Numeric Labels. Thefirst place it appearsis at Row 0, columns 1 through 14. This is a short form
numeric label( 14), which requires only one byte in program memory.
Long Form Numeric Labels. Row 12, Column 15 represents numeric labels with argument values greater tharn
fourteen, (this includes the local Alpha Labels A-J, and a-¢). Thefirst byte in this two byte label contains the function
location 12,15 (11001111) and the second byte contains the argument value. For the local Alpha Labels the values of
A-J and a-e are found in Table IV, page 50.
Global Alpha Labels. These labels are found at Row 12, Columns O through 13. Their structure in program
memoryis as follows:
1200 0000 15 xx 00 00 cecee ccee eeee e ccee—_—— —_— =L = —_—
Byte: 1 2 3 4 5 6 xx+3
Byte 1 = Function Location (11000000)Byte 2 = Uncompiled Label Chain (00000000)Byte 3 String code + (No. of ASCII Chars. + 1)(1111xxxx])Byte 4 = Reserved for Key Assignment (00000000}Byte § = 1st Character (ASCII Value)
Byte xx + 3 = Last Character
46 Algorithms
Execute [XEQ]
function is also found in three different locations in the HP-41 Function Table (Table 111).
Numeric and Local Alpha Execute. This function ((X nn) is found at Row 14, Columns 0 through 15.
14 00 00 00 xx xx—_— —— ——
Byte: 1 2 3
Byte 1 = Function Location (11100000jByte 2 = Uncompiled Address (00000000Byte 3 = Argument Value
Global Alpha Execute. This function ((XEQ]«) is found at Row 1, Column 14.
01 14 15 xx cce esse eses CCCC
Byte: 1 2 3 XX +2
Byte 1 = Function Location (00011110}
Byte 2 = String Code + No. of ASCII Chars. {1111xxxx)Byte 3 = First Character (ASCII Value)
Byte xx + 2 = Last Character
indirect Execution. This function ([X
nn) is found at Row 10, Column 14.
10 14 1x xx—_————
Byte: 1 2
Byte 1 = Function Location (10101110)
Byte 2 = Argument Value with the Most Significant Bit Set (Txxxxxxx) Go To
The function has four locations in the Function Table. It has both short and long form numeric, as well as
GT0 and
Short Form Numeric Go To.(
nn for nn <15). This is found at Row 11, Columns 1 through 15.
11 nn 00 00—_—— ——
Byte: 1 2
Byte 1=Function Location + Argument Value (1011nnnn)Byte 2=Uncompiled Address (00000000)
Algorithms 47
Long Form Numeric and Local Alpha Go To. ((GTO| an for s>14). This is found at Row 13, Columns 0
through 15.
1300 0000 nn nneee
Byte: 1 2 3
Byte 1 = Function Location (11010000}Byte 2 = Uncompiled Address (00000000)Byte 3 = Argument Value (nnnnnnnn)
Indirect Go To. ((G
INDJ nn). This is found at Row 10, Column 14.
10 14 0n nn
Byte: 1 2
Byte 1 = Function Location (10101110)Byte 2 = Argument Value with MSB Cleared (Onnnnnnn)
Global Alpha Go To. (
«). This is found at Row 1, Column 13.
0113 15 XX CCCC seess oses CCCC
Byte: 1 2 3 XX+2
Byte 1 = Function Location (00011101}Byte 2 = String Code + No. of ASCII Chars. {1111xxxx)Byte 3 = First Character (ASCII Value)
Byte xx + 2 = Last Character
Store and Recall (STO], [RCL
Both ofthese functions have two numeric locationsinthe table as well as one alpha location. In both cases to make the
the most significant bit of the second byte (the argument value) is set to one.
Short Form Numeric (
through 15.
n; nn <=15). These are found at Rows 3 and 2, Columns 0
RR CC—_——
Byte: 1
Byte 1= Function Row Number+ Argument Value
Long Form Numeric
nn,
nn; nn >15). These are found at Row 9, Columns 1 and 0.
RR CC nn nn—_— ——
Byte: 1 2
Byte 1 = Function Location (10010001 = [ASTO]; 10010000 = [RCL] }Byte 2 = Argument Value (nnnnnnnn)
48 Algorithms
Alpha ([ASTO] nn, [ARCL] nn). These are found at Row 9, Columns 10 and 11
RR CC nn nn—_—— ———
Byte: 1 2
; 10011011 = [ARCL])
Byte 1 = Function Location (10011010 =
Byte 2 = Argument Value (nnnnnnnn)
Alpha Text Strings
This function is found at Row 15, Columns1 through 15.
15 XX ©CCC sses oo ccce———— ——
Byte: 1 2 xx+1
Byte 1 = Function Location + Number of ASCII Characters (1111xxxx}Byte 2 = First Character (ASCIl Value)
Byte xx + 1 = Last Character
End
Each bar coded program must have an [END| function as the last three bytes of the program. It must be set to the
following values:
1200 0000 0215——e——
Byte: 1 2 3
Byte 1= 11000000 (Decimal 192)Byte 0000000 (Decimal 0)Byte 3=00101111 (Decimal 47)
Header Algorithms
The preceding text covers the HP-41 program memory configurations ofthe various calculator functions. At this point
it is important to understand the specific algorithms needed to make the header of each program bar code row.
Thefirst byte of the headeris the checksum which was covered beginning on page 43. The second byte has the typefield
and the row sequence numberinit (refer to Figure 1, page8). Thetypefield is set to ““1”* for non-private and to 2"’ for
private bar code. In the sample program “PRGMBR”’a counteris kept which labels each bar code row with a con-
secutive row number. Using this row number the internal sequence numberis generated as follows:
Sequence Number = Row Number (Minus 1) Modulo 16.
In any Program type bar code row, the third and last byte of the headerspecifiesthe leading broken function code bytes
andthetrailing broken function code bytes of the row (page 7, Program Bar Code). In orderto calculate these values,
the following is needed:
1. One incrementing counter (T5);
2. One decrementing counter (B3);
3. One variable (H1) to hold the number of byiesleft over from the previous row; and
4. One variable (H2) to hold the numberof bytes left over from the current row.
These counters and variables are all initially set 16 zero. Here is a flow chart ofthis procedure.
INITIALIZE VARIABLESB3=T5=H1=Hz=0
e
GET PROGRAM BYTE. DECREMENT B3
3 NOB3 <>0
Tes ‘CLEAR THE BYTE COUNTEROF THE CURRENT FUNGTION
T5=0)
ves sB3 <0
LOOK AT VALUE OF PROGRAM oBYTE AND DETERMINE HOW MANY
BYTES REMAIN. SAVE IN B3
INCREMENT NUMBER OF BYTES THATBELONG TO THE SAME FUNGTION
(T5=T5+1)v -
sBAR CODE ROW oBUFFER FULL ORALL OF PROGRAM
READ2Yes
PUT THE BYTES REMAINING FROM PREVIOUS ROW (H2) INTO H1SAVE BYTES REMAINING FROM GURRENT ROW IN H2.GOMPUTE 3RD BYTE OF HEADER AS: H1+16+T5 MOD 16.
COMPUTE GHECKSUM. PRINT BAR CODE ROW.INITIALIZE BAR CODE ROW BUFFER POINTER,
is
PROGRAMCOMPLETED
7
Algorithms,
49
50 Algorithms
Other Bar Code Algorithms
Direct Execution (Complete Function Code) Algorithms
Thevalue of the barcodeis derived for the most partdirectly fromthe position of the functionin the HP-41 Function
Table (Table 111, page 45). All functions in rows 0 through 8 are one-byte functions and, with the exception of (G
« , require bar code rows of only three bytes in length (two bytes header and one byte function code).
and
Rows0, 2 and 3 as shown in Table III are not used. These are short forms of the functions and they have analogous
long forms that are to be used instead (Row 12, column 15; Row 9, column 0; and Row 9, column 1; respectively).
Thedigit entry functions contained in row 1, columns0 through 13, are handled by type 6 or 9, Numeric Data bar code.
Data bar code types 7, 8, 10, and 11 handle the alpha entry functions contained in Row 15.
Forfunctionsthat are able to have an indirect argument,the indirection is shown by setting the most significant bit of
the argumentbyte to one.
The numeric values for the stack arguments (X, Y, Z, T, and L) as well as A4 through J and @ throughe are found in
Table IV,following:
Numeric Values for A~ J, a—e, and the Stack
A B C D E F G H | J
102 103 104 105 106 107 108 109 110 11
a b c d e X Y z T L
123 124 125 126 127 115 114 113 112 116
TABLE IV.
The first byte in the bar code row is always the checksum; the second byte is always the decimal value 64. Following is a
breakdown of how the values for the remainder of the bytes are formed from the HP-41 Function Table (Table III) for
the different functions.
The programmable function values are derived as follows:
Algorithms, 51
Position inHP-41 Contents of:
Function Table
Row Column Function Byte 3 Byte 4 ces Byte N+4
1 13, 14 GTO, XEQ (Row No.*16) + 1st ASCII Nth (last) ASCII(Alpha) (Column Number) Character Character
4-8 0-15 Referto Table Ill (Row No.x16)+ N/A N/A{Column Number)
9 0-15 Refer to Table lll (Row No.«16)+ Numeric Value of N/A{Column Number) Argument
10 0-7 XRCM (Row No.+16)+ (Rom I.D. mod 4) N/A[(Rom I.D. *64 + (Rom Func.
Number/4)mod 8] No. mod 64)
10 813 Refer to Table IlI (Row No.*16) + Numeric Value of N/A(Column Number) Argument
10 14 GTO/XEQ IND (Row No.+«16) + Numeric Value of N/A
(Column Number) [Argument (If GTOmsb=0, if
XEO msb=1)
12 0-13 LBL, END (Row No.=16) + 1st ASCII Nth (last) ASCII13(LBL) or O(END) Character Character
12 14,15 Refer to Table Ill (Row No.*18) + Numeric Value of N/A
(Column Number) Argument
13,14 0-15 Refer to Table 1l (Row No.#16) Numeric Value of N/A+ 0 Argument
52 Algorithms
The non-programmable function values are derived as follows:
Non- Contents of: (N =The Number of ASCIl Characters)Programmable
Function Byte 3 Byte Four Byte Five . Byte N+3 Byte N+4
CAT 0 Catalog N/A N/A N/ANumber
GTO. 1 Argument(right justified) N/A N/A
GTO.. 1 15 255 N/A N/A
DEL 2 Argument {right justified) N/IA N/A
COPY 3 1st ASClI 2nd ASCII Nth ASCII N/ACharacter Character Character
CLP* 4 1st ASClI 2nd ASCII Nth ASCIHI N/ACharacter Character Character
RIS 5 N/A N/A N/A N/A
SIZE 6 Argument(right justified) N/A N/A
BST 7 N/A N/A N/A N/A
SST 8 N/A N/A N/A N/A
ON 9 N/A N/A N/A N/A
PACK 10 N/A N/A N/A N/A
DELETE 11 N/A N/A N/A N/A
ASN 15 Ax 16+ Bt 1st ASCII N -1 ASCll Nth ASCIICharacter Character Character (N<7) “Thisthree byte barcodeby itself will clear the program where the PG (program counter) is located. If there is an argument It is an Alphastring
1A= ABS{Keycode) DIV 10, B = ABS(Keycode) MOD 10. If Keycode <0 then A= [ABS(Keycode) Div 1048] MOD 16
Numeric Data Functions
In orderto pack as many digits in as short a bar vode row as possible, the sncoding scheme chosen for the digitsuses only four bits per digit, as follows:
DIGIT CODE
0000000100100011010001010110011110001001
NULL 1010ter 1011e 1100- 1101“E” 1110
illegal J 1111
OCBNOTUHWO
Algorithms 53
Since we are using a fourbit BCD code for thesedigits, it may be necessary to add a digit to make the bar code conform
to the “‘n*8 bits” requirement(refer to Section 2). A special case is for standard numeric data (Type 6). When only one
digitis inputit is necessary to add two nulls so that the minimum bar code row length is three bytes.
In all other, casesit is necessary to count the numberof digits in the input string. If the datais standard numeric and
the number ofdigits is even then add a null. If the data is sequenced numeric and the number of digits is odd then
add a null.
FLOWCHART TO CONVERTASGII INPUT STRINGTO INTERNAL 4 BIT NUMERIC REPRESENTATION
START
“AS=INPUT STAING IN ASCHSET COUNTER N=1
GET NTH ELEMENT OFA5,‘CONVERT ELEMENT TO ANINTEGER VALUE& SAVE IN X
PUT X INTO DNy
PUTVALUE 11"INTO Dty
PUT VALUE 12"INTO DIN)
PUT VALUEINTO DNy
- S PUT VALUE*ERRoR INTO D{N}
NCH
ooESN=LENAS)
'ADD A NULL TO D ARRAY
WALUE 10)N=N+1
INTEGER ARRAY D WITH N NELEMENTSREADY TO PUT —{> conmmueINTO BAR GODE ARRAY
54 Algorithms
Alpha Data Encoding
The encoding for the alpha characters is ASCII (with the few exceptions necessary to vonformto the HP 82143A
Printer character set). The values are listed in decimal form in Table V following:
34wS.F.T.dG.aFoo
1@,ti.x120w
&
¥F o
a <i ¥& =
& ha — i
A & J
a H ko E 1o - ~o I io E oE F i12.," G 113.a= H ii14.r
£ I 115.=
¥ i 116. ¢117.u
i 118w- 119w# 1280 %* 7S 1217= sa 2.z& 21 w; a2 i< 8 *2 = =* = -
+
‘Table V. HP 82143A Printer Character Set
Appendix A
Flowcharts
55
56 Flowcharts
PRGMER
sTART
READ DATA TABLESINTO THE PROGRAM
-
INITIALIZE TO RECEIVEAN HP-41 PROGRAM
15500
WANT70 SEE ALISTOF COMMANDS,
—_/ PRINT COMMAND
st7z
GIVE THE PROMT AND2 WAIT FOR INPUT22H3zgo 3
3 Y& 23 3 -
g/ pant contentso8] /THE TEXT STRING ARRAY,
3
GET STATEMENT NUMBERTRIM THE BLANKS.SET DELETE FLAG,
COMMAND JUMPTABLE
. W w o && i3 & gl & @b g 3| g &l 5 iH | 8 & H £l 33| g| 9 g 3 & 3g 2 B & g 7 QIVE ERRORg 2 MESSAGE: z
3 s¢ DELETE FLAG
| SET
DELETE THEUNE
TRIM THE BLANKS FROM
INPUT AND PLAGE INTO THE41 PROGRAM MEMORY ARRAY
NUMBER’
INPUT STARTING 41PROGRAM LINE NUMBERAND INCREMENT VALUE,
41 PROGRAM YESLINE NUMBERT0O BIG
7NO
Flowcharts
<
INPUT THE OLDSTARTING LINE NUMBER,THE NEW STARTING LINE
NUMBER ANDTHE INCREMENT SIZE
MAKE SURE TO NOT
OVERWRITE AN EXISTINGINSTRUCTION
PRINT THE PROMPTAND 41 PROGRAMLINE NUMBER
PLACE POINTER ARRAYINTO A TEMPORARY ARRAY
INPUT THE 41PROGRAM INSTRUCTION
DOES oINPUT ves=“EXIT”
7
NO
PLACE THE 41INSTRUCTION IN THEINPUT ARRAY AND
INCREMENT LINE NUMBER
RENUMBER AND STOREBACK INTO POINTER ARRAY
“RENUMBER
58 Flowcharts
RUNPRIVATE
SET PRIVATE FLAG
~HAS41 PROGRAN NO.ALREADY BEENS
COMPILED,
Yes
INPUT TITLE FOR
/(60 CHARACTERS MAX)
PRINT THE TITLE ANDNUMBER OF THE
PROGRAM REGISTERSREQUIRED
//PRINT MESSAGE THATPROGRAM MUST BECOMPILED FIRST
INITIALIZE THE VARIABLES
GET41 PROGRAM BYTE
sTHIS THE
FIRST BYTE OF >VE° -A FUNCTION
7No
DETERMINE HOW MANYBYTES REMAIN FOR THIS
FUNCTION AND
INCREMENT THE NUMBEROF BYTES READ THAT
REMEMBER ITBELONG TO THE
CURRENT FUNCTION
FINISH COMPUTING THEVALUES FOR THE
HEADER (BYTES 1,28 3)
PRINT THE BAR CODEROW, INITIALIZE THE
BAR CODE ROW BUFFER,
Flowcharts 59
F Tiess)
INTIALZE
ARRAY INOEXFORJ= 1 T02233
409,ERROR CORRECTION
SUBROUTINE
/ ouTRUT wessace/" THAT GOWPILATION
/ s COMPLETE
s SET FINAL END WITH TEXT ENTRY o2ND BYTE UNCOMPILED IRSTRUCTION, LErARPPEns,
(3355) ?
o SET ALPHA APPEND
FLAG
FIND END OFTEXT STRING GET FIRST
OPERANDOPERAND
SET ~ONE WORD SET DIGIT ENTRYFLAs
INSTAUCTION FLAG s .TEXT STRING T, YES700 LoNG
o
sTHERE
A SECONDOPERAND
TRIM BLANKSFROMOPERAND. SET ALPHA FLAG
SET INDIGRECT FLAGTRIM AWAY BLANKS
sTHE OPERAND ™VATHIN BOLNDS
o PRINT
ERROR MESSAGE
60 Flowcharts
TEXT ENTRYWSTRUCTION,
ENTER THE LENGTHOF The STAING.
sTan
WSTRUCTON
ves
o
OOAT THEChaacTER
ENTER THE CHARACTERINTO THE MACHINECOE aRmAY
‘TerE oreCHARACTERS
PAINT ERFORESSAGE
— 1ADD THE Exina BvTE FoR"THE APPEND CHARACTER
s7 rrieRe anSXFONENT
s& mestDG AR &
SEGATIVE EXPONENT
ENTER EXPONENTINTO mACHINE08 AFRAY
PUT CORRECT VALUEFOR -IN ARRAY
7" e£RRORShGE
PONT 10 THEFRST NUMGER
INSTRING
00K 7OAN EXFONENTF THERE 1S ONE SETTHE EXPONERT FLAG
ENTER ANTISSA INTOWACHING CODE ARRAY
PANT ERRGRESSAGE
€RROR CORFECTION‘SUBROUTINE
s
2
[ encuiateOF The iR
HE LENGTHARGLMENT
AT ERRORWESSAGE
THERE LESS™. vesTRO >BiGiTs
F NECESSARY GALGULATESTACK On LoCAL LABEL VALUE
CALGULATE VALLE OFTHE T1%0 DIGIT DPERAND.
BNESSAGE
Flowcharts 61
ADD INDIREGT @iP NECESSARY
s~THE ALPHA .OPERAND FLAG
sTHIS FUNCTION)70" OR “XEQ)
L0AD FUNGTION‘GODE VALUE INTO5B
SHORT FoRMNOMERIC
NUMEER OF CHARS SET oPeRAND.
VALUES
AR) YES CuARACTERSe o VALTHIS FUNCTION) 1skte FORM NUMERIC o
SET VALUES INTGMAGHINE CODE ARRAY PRINT ERROR/ MESSAGE
SET LONG FORMNUMERIC VALUESINTO"MACHINE CODE
‘ARRAY
B
esSorm U sHoRT FoRdWity CALGES W pLack — PUT LONG FORMVALUESI PLACE
w2sn)o 00K UP VALUES|
OF FURCTIONSTN THE TABLE
s
s, o THEFURCTION ™0s N THE TRBLE.A ALPHA 5Lage ERRoR
MESSAGE
PUT SHORS FORMVALUES IN PLACE
SET THE FUNGTIONCODE VALUES FORi FUNGTION
ARE
‘AL AsciCHARACTERSCoRRECT
e OPERANDS1N ORDER AND.
CORRECT.
ERRORMESSAGE
SET GoRmeCTErRoR 5OFERANDVALUESMESSAGE NexT b
——— &0 oF_msTAucTionDECODE L00P. %00 FiNALEND ISTRUCTION SET COMPILATION FLAG
62 Flowcharts
GETPROG
INPUT THE NAMEOF THEFILE0 BE READ
SETTHECOMPILED FLAG
Yes PRINT ERRORMESSAGE
7 THEFILE NO.BE READ <
PRINT ERRORTes MESSAGE
/" READ aNpUT)THE/ Nimadncr brrcs/NG acaman
READ(INPUT) THE41 MACHINE CODE
ARRAYLo
CLOSE THEFILE
SAVETEXT"
INPUT THE NAMEOF THE FILE
SAVED
WRITE THE POINTERARRAY AND THE INPUTTEXT STRING ARRAY
SAVEPROG
—rINPUT THE NAMEOF THEFILETO BE SAVED
//
CREATETHE FILEAND OPEN IT
WRITE THE NUMBEROF BYTES IN THE
41 PROGRAM
WRITE THE 41MACHINE CODE ARRAY
GLOSETHE FILE
“GETTEXTl
/" INPUT THE NaMEOF THEFILE/
/ TO BE READL 7
sTHE FILETHERE
PRINT ERROR YESMESSAGE
[THE FILEBE READ
PRINT ERRORMESSAGE Yes
FEAD (INPUT) THE
POINTER ARRAY ANDINPUT TEXT STRING
ARRAY
cLosETHE FILE
RESTORE POINTERTO THE ENDOFTHETEXT
FuLFGN
sTaRT
DISPLAY INSTAUGTIONSET FoR FULFCN
READ ATINTG VARIABLES
TouLpINSTRUCTIONS
o
PROMPT USEROR NPUT
TNITIALIZE VARIAGLESDELETE LEADING &TRAILING BLANKSFROM INEUT STRING.REMEMBER LENGTHOF INPUT STRING.
sNPT STAING
USING SPACES SOELMITERS, PARSEouT THEARGUMENTS (F NY)
agETiEReARGUNENTS
GUTPUT SUBROUTINE(GOsUB 5760, a
TRLEADING &TRAILING BLANKS
Flowcharts
PARSE OUT ZNDARGUMENT
sTHERE ONLYONE ARGUMENT,
1SOLATE THETEXT ARGUMENT
sTHIS AVAUDINSTAUCTION
No EnnonMESSAGE
REMEMEER THE LENGTHS OF:FUNCTION STRINGST ARGUMENT20D ARGUMENT ERroR
]
ARGUMENT TvPESUBROLTINE
RLLOWED
~haveves 7 AnGUMERTSSEEN INPUT
SET BYTE VALUESEAroRMESSAGE AND NUMBER OF BYTES
caLcuLATECHECKSUM(GOSUB 4580
83
64 Flowcharts
SRGUNENT TYPE1GoEuR 110
wonESEAGE
AKE SURE AN‘ARGIMENTWAe
TSTARGUENT .AlST,
WAKE SURE TSFUNCTION ISOTHARGUMENTSSRMMERE
ST vaLves FamT Bvies.
IWDIRFCTION
78T ARGUMENTSN D
iT 4 STaCGPeRATION
s3I0 THEPROPER SUMERICALSTACK ARGUNERT
ARGUNENT 15 NoTST o AaNGE
MAKE SURE 20D
[ST VALUES FonTESze
FIGURE GUT I THEREIOLVED 3DCOMATE BV7E
CREATE THE LRSTRING (GOSU5
ComruTe ToTALOMBER OF 5VTES
soSASrackRGORERT
s
XaS1GN ProPERAGHERIC VaLoEFORSTACK RGUENT
esure
76 THe GvTES
SETBYTE VALT0FT OF FUNCTION& ATGUNERTS ST NUVEER OFT BYTES TO 1
SETNUMGER OFoVTES 105
ST esRGImENT
SETNUMERE vaLLES
ALPHA ARGUMENT
SETTHE BYIE VALESFon THE FUNCTION
SET NUMERC vALLESFoReR
@
Se7evre vavesFo FNCTIONNG HRGUMENTS L[ serwoveerorOF viEe T4
CRERTE ALpiA| sosis serorCALCULATE ThENUMBER OF BViES
Flowcharts 65
e
STN convear wsers |THiSNUERC INTO INTERRALREPRESENTATION
s
SESEQUENCENUWEER, SET RESTREMEMAERNUMBER OF EYTES
SET THE SEQUENGENUMBER, COMPUTEBVTE TWG.
SETVALUE OF&YTES CHECKINGTO SEE IF MUSTADD A NULL, SETNUNBER OF BYTES
compurs SET sequeNcENUNEER, CONVERT seravies GONVERT T0 ASCISET NUMBER OF o¥TES
GALGULATE BYTE 5 GONVERT 10 A5G&‘CONVERT TO Ascil REMEMBER THE NUMOERAND REMEMBER THE oF BYTES NUMBER OF BVTES
I
66
Appendix BHP-85A Adaptations of PRGMBR and FULFCN
The adaptation of PRGMBRrequired 2 modified version of the HP 9845A program in orderto run on the minimum
HP 85A configuration: HP 85A Personal Computer; 16K RAM Plugin; I/0 ROM or Printer/Plotter ROM; and, RS232C
or HP-IB Interface.
PRGMBR was segmented into three separate programs according fo logical operations. Thefirst segment, BEGIN,
initializes all the variables and loads the necessary table data. The second segment, EDITR,is the interactive sec-
tion where the HP-41 program text is input. This section also allows the user to save, retrieve, and edit the text. Giv-
ing the command COMPILE during execution of this segment loads the third segment CMPILE into the HP 85A.
CMPILE not only compiles the HP-41 program but also prints the bar code. As soon as the HP-41 program has been
completely printed out in bar code this segment loads the EDITR segment back into the HP 85A ready for the next
program.
This particular adaptation does not include the ability to save and retrieve the compiled HP-41 program code.
The source files for these HP 85A programs are available on cassette tape or floppy disc from:
Series 80 Users’ Library
1000 Circle Blvd.
Corvallis, Oregon 97330
67
68 HP-85A Adaptations of PRGMBR and FULFCN
85A Adaptation of PRGMBR
! HF41C COMPILER! & BRAR CODE GEN FRGHMU FIRST OF THREE SEGHEHTS! THAT ARE CHAIWED TOGETHER[ THIZ IS AWM ADAPTATIOH OFi''
THE 2245A COMFILER FROGRAMTHIS SEGMENT 13 2TORED RSFILE "BEGIN"
OPTIOM BASE 1IMTEGER T.J
COM INTEGER L2086, P225, F5.1101B3;COM TFEEBY. T1#E2080. 724073090, [email protected]¢027], I$0E247. C$EEa1TS, Tid. T2%=""FOR I=1 TO Z& | READ LOCAL L
% STACKE REGISTER HMHEMGINTOD 1%
3 S1%CI1, 13HEXT 1FOR I=1 T0 183 ! REAU TEDTHST MMEMONICS IMTO I, IHS
bN
]eel
DEEDED&oS
30.F
£
@ E
bte
Loy
Daa
TRUL .d=1+E%(1-1)RERD IS$CJI.I1¢I3 | YALUES IHTO I1 FOR TAELE OFRIVERNEXT IFOR I=1 TO €8 ! REARD IM vALIO CHAR TRAELES FOR CHRAR CHECKPEAD CHLIT.C24I2 ! CHARS INC$: CHAR CODE IH CZMEXT TDISP "1ST SEGC DOWE®POPUT CHRIKIHG STATEMEMTS! HERE TO PROGRAM "EDITR"CRHAIH "EDITR"
PEHD
L OkDATAY! ¥LOCAL LABEL & 5HARS® &
8 OATR A,B.C.D,E.F.G.H,1.14.7.2S
THUK REL C 2
iINTH NNEMUHIP‘J % MUMERIC%ELHCH. 77 &+, 71, -, 7 "
"'*";b% "
DRTH HLUS. 93, /U4, 143, ADFF .9. AON, 148, ARCL . 155, ASHF . 13ASIN, 32OATA ASTO. 154, ATAN. 24, AVIEW.12€.BEEP. 134, CF. 1569, CHE. 84, CL.x,ll‘?
<FACT .38, FCT .{155, FRC. 165FC, 170, GRAD. 12 PI HME-. P4, H
Z8.HMS,R, 183OATA IMT. lw4,I1S8G.15&.1€,LN, 28,DATA MEAH. 124, MOD.
187, R-F.73OH, 117DRTA RMND.118.RTH, L3SCI.157,S0EYDATA SIGH. 122, 31IM.83,50RT, 82CETH. 148DRATA ST+. 146,57(STO, 145, 8TOF, 1E, 153DATA VIEW. 152, X#57. 99, K87221, K@%, 182, 8 ®e7aORTR X<, 86SvX!B?-l@Z
147,357,149STANL 21, TOH
! #\'u‘RLI[IDEX¥DATA * “.32.%,22.SlEZ6. %42, 74,43, 0,45, ., 46. 7,47
411’ CHARS
nbibdJ0ddJ1HATAdd0430004495JLHETINID-1ndITTdHO0T.LHINd#SUIUNANIHITWHADOEdTP&AIGWNNTE— H433uNNId.LHIHD
welIR3,OHIJALoLHIdd«Ad034
4018-SYIAWNNJYLSHI21vSJida3nIs-AJFWNH.IHIddwhdDWIWHIWHADO0Ed2T+IHTEH381517-L8177,IHIdd
wddHLWOM4LXILWUADOdd5139-1¥31139,1HIad
wd0LlHA3N3ITH3IGNANS40LS40MROddS1THH-~LIX3nLINIdd
bHAI0HdWOHdJWISHIO3IYIFUOH5313730~W4JiIN30.IMIdd
«03HMALHIATLNINENDWHY90MdJTdS3TIMHOD-3JIT4W00.LNIdd
ooLHIHdwiWHE9044SIHLN
I378071IHAHSONHMKWOD.,1HIddxoLHIMG
#AN5LSI7TSONHWWOZWIHdE|
w3TIdMIsNIHHI23TTdMD0LSNIADW.dSI0
w3IHOOLMIWDISHLIIOGF.40L53L.4310
SNOILD3SF3&HLiJHL40WHd3084ITIdW0TiGLHIHHD1HIOd4SIHLLHi
@9z0109TL®3N
CI-4°CI)dI$YTLHIdA©LX3N
a@sMIHLWiua=LAAJI$E41I4=
aso0l1=04ATeNIHLB>CIyd41
T2=HUWi8661IH04*¥INTLNOAi
0109«393H7T0013
ATEMA39WNHLHIW3LIHLS,LHIddST51A3INIEd
@azs0L09
BZTT
artta8ty
ecal
aeat
alat
=0=
@@
@it
%}=-
-O
RERED
®O
*
@a@
Ta8a
=)
Ottt
1LH:INIAfataLMIAD
AB2H3IHL£228<n41TSIW3LMIdd
TEMLNdNHIwLMIWIAIHI40IFZIZa
HEINTHAGNILIAYLEAnI0.dSI0$¥IHTINOA¥ki
0LGDoONHWKGO
33N8HZINTOIIAHN-SéwINIHdBEE00D
@29WIHLwind3INIdHET.<4013NIHL«lIX3.
@LTH3HLLHIL1WHEISBS9TMIHLL1X3113D,
89NOZTNSPUeHEWDHJOsuoneldepyveg-dH
BPSTHIHL1XIFL3IAH41BEETHIHLd43FWNNIA.4T
BIATNIHLwédw=%141BESHIHLw3TT4WO03w=%141
@2HIHLo1517.=%14dI884NIHLoH43FWNNe=%1FI
¥¥ITNIHLJWArONHWWOIREiA9z0L09
w30dHT0013MEAW39HNNLNIWILHL
«ONBUHWO3Y4018O3433HNH3IAT9-~
@8320109as¥ioBELEF
T+{FHINIT{CT+IJ$10%1N
@920109BsPkT-=(f>d@f¥
83pNIHLYi)fl41BEP
ABTRCEBP—L"CIETLIMNHD+=13AA5MIHLwiw
Erra$11l§30«B.>E0‘rI$TL41T-4315T0LI-I=404
AZ5SHIHL$<T1-1411=0
T+($TLINII=TCLT+I3FL0$1IHd=%11
@3FHMIHL«ILIN30<rFTL4TCT-I°13F1=%11
@55H3HL&=1dI=03n
u3$1lfldNI
4510HOI123%kiE!J.dl-lDNdN538i
81810103BETM3IHLWHILHED5.=%1dI
BTH3IHL«ONw=%7145wHe=3%T141
7L1NdHNIw&SOMHMWO]I37387I8MIHL
THIWHMN0A0d.4510T=64
40
0T
nu=%ZL7FTL"$.LILx3N
I—=(I)d
T
DEDODOE@
Tetek)
aHBAdLIN3IONHBWWOI301X3L4041dddS3LTHM:WHHT0HDHIHW|BTT
CaDEPESALT'LLZTSLBa513¢
F$ZLCAEIFTLEB5]51NOIa1CE@TITIGTHATIUINTUD’JaeATT‘T
THNATTH3D3UHIT35H3HOIL40
«~#3LI03.3714A30HA3340513HOSIHLSWHADO
AANTHAD334HL40adpioEdM33303H
HITOFAIATAMNODTIThdH
4CEERZad(@32
TI3CCERITN
“im®
o @0
rarsI DD
ImT
HP-85A Adaptations of PRGMBR and FULFCN
PRIMT "SRYETEXT - STORES PROGRAM TEXT ON CRSSETTE TAFEn
PRIMT “SCRATCH - ERASES EHTIRE 4 FROGRAM®PRINT " - LIZTS coMMANDS H'JF\ILHELE "PRINT "PRINT "SYMNTAX FOR IHMSTRUCTIO EMTRY: ™PRIMY ™ AX>IMSTRC FORMAT: FRIHT v 1C INETRCH"
PRINT "(BLAHKS ARE USED ASDELIMITERS)"PRINT " BYSPECIAL SYMBOLS:"PRIMT "1 USE '&' FOR SIGHMASIGN®
PRINT "2x USE ‘®' FOR AHGLESIGH®
PRIMT "2 USE ‘#°' FOR "HOTERUAL 'Y SILN"PRIMT "4 USE SINGLE QUDTESC') FOR DOUBLE RIUGTES™
PRINT * EXT FORMAT: '<TEXT EHTR HOTE SINGLE QUOTESi*PRINT "OR H'<TERT EMTRY>*(FOR RAPPERDING TEXRT:"GATO 264
! ¥'RENUMBER' SUE%OISP “EMTER OLD STARTING #.HEK STRARTING #.RND INCREMEMT
INPUT M1,42,V3FOR I=YZ+1 TO ¥i-1IF P(Iy=-1 THEM 13Z&8PRINT "ERRDR - ATTEMFT MADETO OVERMRITE EXISTIHG INST
RUCTIOHS"GOTO 268HEXT I
E=kK+1IF K:=2233 THENIF Ki1{K><8 THEN 143&PUIa=KICK?HEXT 1FRINT "ERROR: INSTRUCTIOW HUMBER OUT OF BCIUNDF "FOR I=1 To &
F K1)HERT IGOT0 Ze@! ¥TSAVETEXT' ROUTINE#DISF "GIVE MAME OF FILE T¢BE SAYED: "INPUT Ti%CREATE T1$.LEN<A$: DIV £4+5@AZSIGHE t TO TisPRIMT# | : A%FOR I=1 TO LENCAF>PRINT# 1 ; P{IXHEXT I
ASSIGHE 1 TO %GOTO zew
! RGETTEXT' ROUTINESDISP *GIVE THE MAME OF THEFILE TO EE RERO™INPUT Ti#%Ag=n e iASSIGHE 1 TO T1sREAD# | : AFFOR I=1 TQ LEMCASRERD# 1 ; P{I)HEXT 1ASSIGHE 1 To %GOTO 266t XERROR COMDITION HANOLIHGREOUTINEY
IF E1<568 THEN 1938PRIMT "TAFE IS WRITE FROTECTED. PLERSE FIwt!"IF E2=3858 THEHM 154@&
2949 THEN 1658
IF E1<:£1 THEN 1880FRIMT "TAFE OR FILE I3 FULL
. USE AMOTHER TRFE.“GOTD 1geEaIF E1<>52 THEH 1835@PRINT “THPE NOT IMN THFE DRIYE "GOTD 18IF E1<x THEH 13FRINT "DUFLICATE FILE HAME
GOTO 1598IF E1<*54 THEH 1258FRINT "FILE MOT THERE TRyAGATHGOTO 1ga@IF El=55 THEH 124aIF E1<>66 THEM 1PRINT "FILE CLOSED®GOTO 1266IF E14:57 THEHW Z@PRINT "FILE NHME E‘?GOTD 1PRINT "ERROR # "JEL:"SEEN PT LIME # ":EZGATO 26aEMD
! O¥FUHCTINON DEFIMITIONS! TEIM FUHCTIONDEF FNT#(D#:THTEGER L. MOIM D#CsA]FOR t=1 TO LENCO$.IF D¥CL.LI<H>"" THEH 21SaNEXT LDISF "TEYIHMG TO TRIM BLANKSTRING!™GOTO 268FOR M=LEM(D3, TO L STEP -1IF D$CM.MIC:"" THEHW 219@HEXT MGOTDFHTH
HF41S CUMPILER-CHFILETHIRD CHAIMED PROGRAM IH
POGROUR OF THREE IT COMPILEZ& ! THE 410 FROGREAM AHD GEHERR
TES THEg ! BRR CO0E IT I@ ! IM FILE "CHPILE™B OFPTION BASE 1@
ORED=
DIH Hi$E .COM INTEGER
S.11¢L7s \fl!'! THCeBl. T1%
?[15;1!5] SisLzv]
nN ERROR GOTO 4252Py 'COMPFILE' ROUTINE ¥PRIMTER I3 2Mmi=1FOR J=1 Tn 2233IF FoJdr<@ THEMFOR I=1 TO S&=P da+]IF A$CE,KI="1" THEH 1fHEXT 1T#=RA%LP(J).kK-11Ed4=p1
AHMER SECTIONTi%, Taf=" *Fl.Fz=8Y=-1IF F5<:1 THEHM 1355Mimio=@Mi=M1+1Fi1.F2.F2.F4.FS.FIF TH="END" OR T$=
& EMO " T
THEH 28535" AMD THL1. 23
<>UR'M THEMW Z@55IF THL1. CEMATTOTHEW ZgasT#=T$LZ3
oo
o-4~
L=LEMCT%)IF L4412 THEH 282PRIMT “ALPHA 3TRG IM LINE # “;.t5OTDIF THLL.LI=""" THEH 284PRINT “ERROR IH ALFHA RTER EWTRY IHSTRUCTION AHE & ", JGOTO 2239Fz=1 ! SET TEXT FLAGGOTO 2279FOR I=1 TO LEH(T%$)T1$=T#CI.I3IF Tlf="a" AMD Tis<{="3" THEH 2IF £71 OR Tig="-="1 AHDLEHMiT#2:1 THEH =
IF Tig=" » QR Ti%=$="." THEN 20885GOTO 2185
NG TDO Lo
"OOR T1
HP-85A Adaptations of PRGMBR and FULFCN 71
Fi=1GOTO 2275Ti$=FNT${T$LP1+115TE=THLL F1-11L=LEH(T1%5IF T1$C1,13<>J<xm " THENIF L>5 THEMT1$=Ti$L2.L-11Fd=1o
2=FIF FZ=a THEW 2T2$=T1$C1,P2-11IF TE$="IND" THEH 2z1@PRINT “"OPERRMD ERROR IN LINEog oyGoTo 225=1TI$=FNT$CTI$EP2+1T)IF LEM(T1$3¢=2 THEH 227SPEINT "ERRDR IN HUMERIC OPERAND IN LINE # “5JGOSUE 2498COTO 1938! INTERP SECTION
YrtOOR TisiL.b
B
IF Z<>@ THEW 2378PRINT ";NunL D,EHAKACTER 1N GOTO 3335IF Fe<>1 THEN 2&e8&F9=@IF T$C1,13<3*+° AHD T4C1.13<sv=" THEH 2435IF T$LL.13<:7-" THEH 2438
EWeTE>IF L2 THEM Li=L@-1FOR I=1 TO L1IF T$CILIJ<3" " THEN 243%IF F9=1 THEM 253@
GOTo z251eIF T#LCI.I13< "'3" UF TECI.Id"an Z4a
IF LI=LEM{T#) AHD L2=8 THEN
IF I=L1 OR I=L32 THEM 2555
72
HP-85A Adaptations of PRGMBR and FULFCN
PREINT "DIGIT EWTRY IMSTRUCTION ERROR IM LIME # ";.JGOSUR 3408GOTO 2420T#=FHT$(T$LIT>
1AL E" THEM 2538
Mi=Mi+1T¢=T$LZ]IF T#C1.13<;"-" THEM 2&a@M{M1¥=2gMi=M1+1IF T$E1.113=
=" Uk T$LC1,1d="+7 THEM T#=T#L[2]TH=FHTH(T$YL=LENC(TSIF L»2 THEM 2%FOR I=1 TO LIF T#CI.IX<"a" OR T$CI. 135"" THEN 253&MCMLID>=MUMCTSOI, 132 -32Mi=Mi+1MEXT IGOTO 2335L ~LEHfT1$)
THEN 2265THEM 2885THEHW 2785
PRINT "NUMERIC OPERAND TODLONG IH LINE # *;JGOTD 2333IF L<Z THEN 274@Y=ONUMOTISEL, 130423518+ NUmCTISCZ, 23048IF W ANB 3 <{=93 THEH 2845PRINT "IMCORRECT WUMERIC OFERAND IN LIME # ";JGOTD 2333Y=@FOR I=t TO 26IF T1$=S14L1.13 THEN ¥=I+181
a
HEXT IIF Y<>i THEH 28@5M=HUM(T1$3-48
IF Y:=0 AND V<=3 THEN 25@sPRINT "IHCORRECT STACK QR SIMGLE DIGIT OPERAMD IM LINE# "5l
GOTD 2333IF F5=1 THEH Y=U+1Z8
SUGTO" AHD T$<: "KER"ze »1 THEMN 23c6
MCMLx=174IF T4="GTO" THENSET HIGH BIT FORM{Mi+1d=y
-1z !INOY
IF F4<>1 THEN 2955 |MiMi>=29IF T$="XEQ" THEN M{M1.,=38L=LEN{(T1%>MEML+1y=248+1FOR I=1 TC LD$=TI1$ECI.13GOSUB 43@aIF Z<»8 THEWN 2535FRINT “"INVALID CHARACTER INALFHA LABEL™
GOTO 23233MCMI+I+13=C2(2Z
HEXT 1Mi=Mi+L+2GOTO 2335IF Ys14 OR [#="XEQ“ [HEN 22
Mopl+lM{M1+2Mi=H1+3GOTOD 233
TO" THEN 3eg@IF ¥>15 THEN 3@55
35 MOMid=d4g4YMi=Mi+1
S GOTO 3335MiMix=145MOMi+t
CL* THEM 314wIF ¥x15 THEW 3115MML=32+4Mi=M1+1GOT0 3MiML> 144M{Mi+ 1=yMi=t1+2GOTD 2IF T% LBL" THENMIF F4<>1 THEHW 3ZiaMeMly=132MCMLI+1=0L=LEM{T1%$>MIM1+Z 41+LM{Mi+32MLI=H1+2GOTD 298@IF Wr14 THEH 3235M{MLa=1+4Mi=M1+1GaTo 3735
0060]
TPe
ADNDEED@A
O=LENCTH)GOSUR 437¢IF 2<>@ THEW 331@PRINT "UNRECOGHIZABLE 1HSTRUCTION GIVEN IM LIME # ";.GOTO 2332MEMEa=T162)Mi=Mi+1IF T1423<F3 THEM
PRINT "ERROR: EXTRANMEOUS 0PERAND IN INSTRUCTIONYG0TO 2233IF I1¢Z><144 THEM 3335IF I1¢23<144 OR I1¢R W= THEW 3327PRIMT "ERROR: MISSING OPERAHO® .GOTO 2333MiMLa=Y
54 OR 110223143 0OR
5 FRINT ™
Mi=M1+1MEXT 1} ' $END LLODEMiMir=1N\l11+1\‘
LOOR
! IN ZHD BYTE
U"COMPILATION COMFLETE
GOTO 3588! FERR CORRECTION SUB¥PRIMTER IS 2Mi=EdPRIMT “THE IWSTRUCTION GIVEN HWAZ : A+, E-13PRIMT “GIVE CORRECTED IMSTRUCTION (WITHOUT LINE #7 *DISP * (TO ARBORT COMPILE. TYFE ‘ABORT': "IHPUT T%IF T#="RABORT" THEN 4115
- LEHCA®+1AS=AERTHL" 1"RETURHN! KR'RUN' ROUTINE®%OISF "EMTER THE TITLE OF THE PROGRAM (6@ CHARS OR LESSSuIMPUT T#
! ¥URITE TO A FRIMTING DEYICEH1$=CHR$ (7 ILCHRF (L 2RCHRE
2% ' SET UP DIABLOD CHTRL CQDESH2%=LHF$(77)&L,HF‘$\ 337Hag="
PRIMNTER I5 Z | % FOR DIABLOUSING RSEZZc IWTERFACEPRIMT CHR$(12)PRIHT USIHG “18X.5@8R8" ; T%PRINT " ©W=z DIV 7IF 52 HOD 7r@ THEN
GISTERS NEEDED: "=PRINT * =
! SET PRIMTER BACK TO 25a! REND DIABLD OUTRUTH
B3 F1.F3.F4,F5,F7.H1 . H2.F9=n Fa=3F6=1FOR 1=B{I:NEXT I{ IHSTN TRANSLATION SUES1OF2+13=M(F1+13}Fi=F1+1F2=F2+1F3=F3-1IF F3<>@ THEN 3548F5=@&GOTO_3865IF F3<B THEN 2655F5=F5+1GO0TD 3865IF S1CF23<>@ THEN FP=F7+1IF MiF13>143 THEN 277@! %1 BYTE INSTNS¥IF MCF13<»29 AHD MC(F1:<>32@THEN 3788F3=M(F1+1) MOD 16+1F3 +1GOTD 2365
TO 132
HP-85A Adaptations of PRGMBR and FULFGN 73
37EE IF MOFLx<16 OR MuF12>28 THEH 3I¥508
I7A5 I=Fl+t3718 IF MOIx UF MOIXYES THEN
Ivel COTOD 2865
! %2 BYTE IIF MOF13>z@7IF M{F1241392HEH Ze1@FS=F5+1IF F1+2<32 THEN 3589
FGOTO 38435F3=MIF1+2: MOD 16+2GOTO 3865F
S5=F5+1Zg2@ GOTO 38552825 | ¥3 BYTE IN3T#%383@ IF M(F13:240 THEN 3&5e
2
a T+l2845 FEITD 2285
16
3868 ! BAR CODE ROM SETUP2865 IF F2{1& AND FL<SZ THEN 6@
3
2878 H H”
= H3230 °1(3‘AH1 MDD 1exie+FS MAD 1
IF H1<=F2-3
3893 91(3 =Ht MOD 16*%16+HI MOD 1
=F2-3 THEN 3285
qlf'-‘)F:‘_:*!F-*F‘i MDD 1&
F2 MOD £
! COMVERSION SECTIONFa4=F4+1FOR I=1 TQ FzK=S10IFOR ‘¥=2+1%5 TO 3+<I-1:%8 357EF -1B{Ya=H MOD 2
A DIV 2HEXT ¥
S NERT IBoly=@B(ZECFE%8+30=1
S BCF2E2+d4) =04@a6 ! ¥BAR CODE OUTFUTH4885 I=F4+1-1
@ ROM “&FNF${I38% ¢ “aFNF
=F7 THEN 4883
HP-85A Adaptations of PRGMBR and FULFCN
Tis=T1%8" — “GFHF$<FT:Ti1E=T1$a" "PREINTER I5 2 | LU FOR DUTFUT DEYICE (PRIHTER<FLOTTER:FRINT USING 28A" ; TisAg=n »
KCE-CrlietC1+0D-Cx
IF T$LCC,DF=I$EC1,013 THEN 4458IF T#LC.DIA>I$ECL.D13 THEN X=Z+1
FOR I=1 TO F2¥g+4 IF THLC.DI<ISCCL. 013 THEWN ¥
IF BCI)=8 THEM A$=A$&":> =2-1" IF €<=Y THEH 437@IF BiIx=1 THEW AS=AEL">>>; GOTO 435@&
" E=Z+14029 NEKT I RETURN4828 PRINT USING "3X.3R.18A.215R END
CZA" G Hif.H4E, A,48325 PRINT ™ *4248 IF F4 MDD 18=8 THEN PRIHT ©C
HREFC124845 | RESET PRINTER T 25a4858 | CLEANUP SECTIOHN:4855 FOR I=1 TO 16 | ZERO 0OUT 1g
BYTE BAR CODE ROW BUFFER4268 S1CIr=a
! ORFUNCTION DEFIHITIONS®! MUMBER FORMAT FCHDEF FNF£{M>DOiM HECS]IF H:=1@ THEN 4248HE=CHRE$IN+48)GOTD 4218IF N>=108 THEMN 4866HE=CHR$CN DIY 18+42)8CHR$HNMOD 1@+4583
GOTD 4916IF N:1@B8 THEN 4836I=H DIV 1838J=N MOD 1aé DIV 1@H HRECI+48I4CHRE { J+d4 B8 50HEf{H MOD 1@+48)GOTO 4518I=H DIV 138&
418@ IF F3=8 THEH41@5 IF F1<S2 THEH 4110 PRINT "BAR l:UDE’;éNERHTIUN J=H MDD 1888 DIV 1B
COMPLETED" E=HN MDD 188 DIV 164115 CHAIN "EDITR" NE=CHR$(I+485%CHR$ J+48340CH4138 14258 PRINT “ERROR # " ERRN;* 3EE
H AT LINHE # *:ERRL255 PRIMT * COMPILE<RUM ABORTED
RECK+H4SORCHRECN MOD 16+48)>FNF$=N$FN_END
| TRIM FUNCTION®¥DEF FNT#:{D$>INTEGER E.FFOR E=1 T {ENCO$>IF D$CE.EJ<"" THEN Sz2@HEXT EQISP “TRYIWG TO TRIM BLANKSTRINGE"
C.CA>C302. 2T THEH %=2 G218 GDTO 4115
FOR F=LEMID$> TG E STEP ~1IF D$LF.F1<:"" THEH 5268HEXT F
oIy z<CA=CHLZ.ZF THEN RET
C.CACCHLZ. 2D THEN =2w ] =
-
= & o
LhLE
BR
BhRAE
B
4 “o=Y THEW 4385 GOTO 52662%a Z=8 FHT$=D$LCE.F1350 RETURH FN EHNDITE Z=CE4Yr DIV 2 END
HP-85A Adaptations of PRGMBR and FULFCN 75
85A Adaptation of FULFCN with Data Table
I RSKS FOR HP-410 COPAMOS To MRKE 41C EAR COUE.
S OPTIOH EBRSE 1& OIM T ALFESET., £58l.F
$L1u1.BFLS15T, ¥WEL103. THLF3I2T7 DIM RFCSBA, TI$C3IRT, I3$05127= DIM BLcl . |r.0iclzznh. o
122».AL¢ 203015 DIM B2O150:.WSL1IT
1@ | READ IH 41-C FUMC TAEBLE185 ASSIGH# 1 TD "41FCHE®187 0O ERROR _GOTO 3884116 FOR I=1 TO 122128 J=it+akiI-1D138 READ# 1 TCIR. D141 DECT .
AL{Is . AZCED138 ME¥T I166G ASSIGH# 1 TO %128 T2=1-1125 OH ERROR GOTO 41381 OISPF “HOULD ¥OU LIKE HELFPT®
IHFUT X%213
¥ N" THEM 428FRIMTER IS 2FRIHT "THIS FGM ASKS ¥OU FURHF-41C BAR CODE TYFE COMMAH
og. "258 FPRINT "TYPE THE COMMAND AS ¥
OU WOULD 0OW THE 410 WITH FOLLOWING EMCERPTIONE:PRINTFRIMT "FOR HMUMERIC DATA: DATA ¥ *E ¢
228 FRIHT "FOR ALFHA REPLACE DATA: DATA '#% *¥
FRIMT “FOR RLFHR AFPEHND DATHDRTA A'*¥ xS
B PRINT "FOR ZEGUEHCED DARTA USE FOLLOMING FORMAT "
Z1E@ PRIMT " ORTASER SEU#: k. %X
32@ PRINT * FOR IMSTRMCE., DATRASE@ 45: 1 234 OR DATASEQ 13‘TESTCM
339 FRINT * SIMILARLY. ALPHR TEXT STRIMG ARGUMENTS . LIKEKEQ 'S@R'"FRIMT " ARE DELIMITED WITH *
PRINTPRINT "FOR FUHCTIOH MAMES USIHG "PRINT "USE &''RREG 1B' OR 'C
PRIMT "IN FUHCTE MOT EQUALESIGHERD.i = 'H#Y?' .Y
7@ FRIMT "IN TEMT STRIMGS USE#' FOR MOT ERUAL. &' FOR Z.
AWD R FOR HHGLE . "
FRINTPRIMT “EWTER 77 FOR HELP ATANY TIME."FRIMT "TYPE '%3TOFR' TO STOPTHE PROGRAM"
416 FRINT "EMD ALL EMTRIES WITHTHE EWDLIME' KEY"
QISP “TYPE FUNCTION TO BE CODED"™IHPUT 1%L=LEM:{ I3! THITIALIZE STRINGS
! ¥PARSE 0OUT THE FUNCTION HNO AHY ARGUMENTSYTa%=1%GOSUE 500@IF T2 THEH 218I¥=T3%IF I$="%STOF" THEW 2TOP
5 IF L<=9 THEN 429988 FOR I=1 7O L ! FARSE LOOP
IF I$LCI,1J¥=" " THEN 638F$=F$%I3C1.17
I
AR | HO ARGS SO JUMP
Q #C£1.L3GOSUB 5688IF 75 THEN 218
668 AE=T3%565 IF LEM(AS$)Y <2 THEMN o238673 IF A$CL.13=""'" OR A%Li.1d="H
" AMD A$CZ.23="'" THEN 73@588 FOR I=1 TD L
IF A$CI.Id=" " THEN 738Ai$=A1$8AFCT. 1]MEXT 1GOTO 286 | OHLY OHE ARGT2 #CI.L1
748 GOSUB Soes7o@ IF T9 THEHW 3i@7ed A2$=T9%
GOTO S@n1=3IF R$CL.13=""'" THEN I=FOR I=1 70 L-1IF ASLCI.IX="'" THEM 2358HEXT TR1$=R%GOTO 66At¥=A$C1.13I=1+1GOTO 738! ¥EHD OF Pr! WAS THERE AM IH:
m
oRa IF LEH(FF2:8 THEM316 DISP "ERROR IN ENTRY".I%22A GOTO 42692A LI1=LEM(F%)946 L4=LEM(R1%$)956 LS=LEH{AZ$:t@a@ IF F¥= THEH 2421@1@ IF FE="DATA" THEH18 IF F¥="DATASER" THENia 1 #HERE FOR FUNCTIOHS#14l K=11845 ¥=1211A46 I=LEH{F%:158 2i\B355 218561865 B1(30=01¢(Zr¥15+D2 01@8%6 IF FSC1.IdA=T$LI1.71+1-13 TH
EN 1138
76 HP-85A Adaptations of PRGMBR and FULFCN
1e35 IF FSC1, 1X<THL21.21+1~13 THEM ¥=Z-1
1128 IF F$L1.IXXTHE21.Z1+1-13F TH1
1 ‘ THEW 1@5u@1i1a DI‘%P "FUNCTIDN NOT FOUND IN
TRABLE" . F#%1128 GOTO 422 1 ASK FOR IHSTRUC112 IF A10ZY»6 THEH 123a1146 | #FUNCS WITH MO ARGS#115@ IF L4=@ AND LS=@ THEH 121@1166 DISP “THERE SHOULD BE NO AR
GUMENTS FOR THIS FUNCTIOH ¥1%
DISP "PLEASE ENTER THE FUHCTIOH AGATIN"GOTO 4382H=3GOTO 1464! FUNCS WITH ARGUMENTSGOSUB 2388 ! TYPE OF ARG?IF A4>4 OR AT:4 THEN 4Zz@
A 2 THEN zZ@358E ARG FUNMCTIOHSH#
IF L4>@ THEN 13141296 DISF "ARG REGUIRED";I§1388 GOTO 1178121@ IF At$="IND" THEN 1548
THEM 14328THEM 1643 ! (fA-J2S THEN 1558 | (g—elTHEH 149@ ! STARCK
! SINGLE ARG. ALPHA TYPEIF AR(Z3=1 THEHN 1426DISP "ALPHA ARGUMEMTS NOT ALLOWED FOR THIS FUNCTIOM®GOTD 1178S1=4
UEB 3528UB Z@38 ! CHECKSIUMUE 29%@ 1 DUTPUT
1430 GOTO 428
1438 | #5IMGLE ARG.HUMERIC TvPE#
1508 IF A4<>4 THI:N 1578 | STACK?a THEN 1S
THEH 114THEM X=113THEHN 11zTHEH 118
" THEM 1778ZE" THEH 177&
fa THEN 177816808 X=INT(VAL{R1$2D1618 IF X>=@8 AND X<=9% THENW loga1628 DISP " ARGUMENT OUT GF RRANG
E1638 GOTO 11741648 IF A THEN X=NUMCAL1$:+3716508 IF R4=3.5 THEN X=NUM(R1$x+2
&1638 IF F$=“KER" THEN E1<{3) 241696 IF GTO" THEN B1{3) &1788 IF LBL® THEMN BI(Z)=2871716 Bl{41728 H=41736 GOTO 14661748 ! %HERE FOR DEL-GTO ~SIZE%778 IF F$="GTO." AND Ai$=" " TH
EN Bli4)=13 !
1TR
DIBYP
19T
FAT9PRIR
1P
IF F#="GTO “ AND A1%=% “ [HEN B1{5r=255IF F$="GTO * AHD Al$=" ° THEN 1228 !Elud ALCAISY DIy 25¢B1:50 ALCARL$: MOD 256H=5GOTO 1468IF L5»@ THEHN 8DISP "MISSING ARGUMENT FURTIHD' YL IF
GOTO 117@IF AS<»*4 THEH 1944IF THEN x=11%IF THEH ¥=114IF Z" THEH X=113IF “T" THEH X=11Z2IF A2%="L" THEN X=11#&GOTo 2a1@
aIF RS=8 THEH 13* "IMPROFER RPFUHLHT Fur
YLIFGOTO 1176H=INTCUALCAZF)IF H<B OR ¥>9% THEH 19%5@Bli4)=128+%H=4GOTO 146@! #THO ARG FUHCTIONS#IF L4>8 AKND LS5>® THEM zasa
DISF "TWO ARGUMENTS ARE RE:UIRED."GOTO 117@IF A4=1 THEH 211wOISF "IMPROFER 1ST RRG®GOTD 1178IF RS=8 THEN 2146OISP "IMPROPER ZHD ARGGOTO 117@RE=VAL{AZ3>
SCASY {85 THEH 2z@wKEYCODE IS5 OUT OF RAM
GE _":RA2¥GOTD 117&
RESCAEY OIV 148
<@ THEN U4={ABSAc) OIMaD 1
Bildo=ud¥iesndS1=!
M=4+LEN(H1$3GUSUE 3898GOTO 1468! DATASEG TYPE LODEA%=fili[l L4-13 | 3TRIP ¢
L5LENCAZF! DATA TYPE BAR CODEGOSUB 2380 | FIND ARG TYPEIF L4=8 THEHW 2744IF R4>4 OR RS>4 THEN 428IF A4=8 THEN 2388IF A4=1 THEH 2548IF R4=2z THEN 277@! # NUMERIC DATA #! SET THE DIGITSFOR I={f T0 L4H1=HUM(A1$LCI. IIF X1>=48 AHD X1<=S7 THEN DCI>=VALCAL$LCI. IO
2418 1F ALSLL.13=" * THEH Oufr=1
24209 IF ALSCI.Id="+" THEN D<I)=1
2438 IF ALFCI.IJ="-" THEM D:li=
Z44a }F RLFCI. IX="E" THEM D(Ix=14
24358 IF DOId<@ OF D(I»>14 THEN 2748
2468 HEXKT I2478 IF F$=“"DATASEE" THEN 25932471 IF LEMCAL$Y:1 THEN 24762472 B1423=96+10
LRa=16@+001)
2438 IF L4 MOD zZ=8 THEN 25242498 EL1{2¥=96+011>
FUF‘ I=0 TO L4-1 STEP 2Bl Kar=1ek0oIx+D0I+10
K+1
NE.»T IM=2+LEM{A1$: DIVGOTO 146&
S¥1E+052-1, D
B1e2a=(52-1> MID 2%4
IF LEMCALFY MODoR
Bled4r=16%18+0¢1>FOR I=J TO LEH(A1%: STEF ZBIoKI=16XDCIa+DCI+1 sK=k+1NEXT I+LENfHI$‘ MOD Z+LEMCAL$:
DI‘»‘GOTO l4r6
DISP "ERROR IN HUMERIC DATHI8GOTC 117a@{ ALPHA AFPEND DATA
"DATASER" THEM 2852AFFEND"&™ ' Ugf1gan e=128+L4
! SET BYTES 70O RSCII YALUES1=3H=LENCA1$)>+2GOSUB 3894GOTO 1466SE=YALI{A2%>
FL" "LAZFL": APPENO"&"TEgplggn NB1{2>=1i%16+(52~1) DIV 258H=LEH(A1$3+3GOTO 2825! # ALPHA REPLACE #IF F$="DATASEQ" THEN 301iaI¢=A1%B1e2)=112+L4GOTO0 28484
ALCAZS$YD=10¥1R+(52-13 DIV 256
HP-85A Adaptations of PRGMBR and FULFCN 77
2 H=LEM(AL1$)>+3S BI¢3)=(SZ-1> MOD 256
Bz 4ZA3R SUB 3529@35 COTO 14682046 ! FEMD OF MAIN ROUTIHEX3838 ! CALCULATES AHM & BIT CKSUM
FOR M BYTE BAR CODE.@6l | M MUST BPE INITIALIZED TO
NUMBER OF BYTES IN THE CODE3@7e | BEFORE THIS ROUTINE IS CR
LLED .JBga C=aIB9@ FOR2189 C=C+B1{IxF12@ HEXT I2138 C=C DIV Z56+C MOD2146 C=C DIV Z5&+C MOD2158 Bioly=C2178 RETURNZ18@ ARGUMENT TYPE ROUTIHE3i%@ ! DECIDES TYFE OF 2 POSSIBL
E RARGUMENTS AND3288 | RETURNS INFO TO MAIN PROG
RPAM IM A4 FOR THE 15T ARG2218 ! AND RS FOR THE ZHD.THE AR
G TYPES ARE DEFIMED:! TYPE MEANING
NUMERIC DATAALPHA REFLACE DATAALPHA RFPEHD DATA
A THROUGH 1a THROUGH e
STACKE ARGUMENTSERRORS IM ARGE
IFL4=g THEM RETURHIF R1$="IND" THEM Z€1@IF L4=1 AND A1%="E" THEHM 341@FOR I=1 TO L4Al=HUMCALIECT. 10DIF (X1<43 OR Hi>37: AHD X1<>63 THEHW 2468MEKT IGOTO 3616IF L4>1 THEM 3438
HUMCAL$2 264 AMD NUMCALS$)
IF HUMCAL1€Y>96 AHD NUMCALS$?4182 THEN A4=3 5F THEN fd4=4
THEN Ad4=4THEH Ad=4THEH A4=4THEH R4=4
2439 GOTO 35983499 IF AL$C1.13="R" AND ALs$LZ, 2
3="'" AND A1$CL4.L43=""'" THEH R4=2IF AL$C1.13="'" AND A14$CL4,L43=0'" THEH A4=1IF A4:B THEH 353@A4=5
DISF “ERROR IN DATH CHECEFOR MISSING ° OR IMPROPER
HUMBER"3548 RETURM3558 IF A4=1 THEM AL$=A1$L2.L4-1
22568 IF A4=2 THEM R1$=R1%L3.L4-1
I
78 HP-85A Adaptations of PRGMBR and FULFCN
THEH RL1$=A1%S THEM A1$=A1%
L4=LENIAL$2! SECOND ARGUMENT
THEHM RETURHI=1 TO LSUM{AR$LCT, 132H1<42 DR X135V AND ¥14
»B3 THEH ZA7@
NEXT IGOTD 32819IF LS»1 THEHW 37s@
X" THEM AS=4¥ THEH AS=4Z" THEM RS=4T THEHW RS5=L" THEW fA5=4
IF NUM{AZ$3:6E4 AND NUMORZSF 5<75 THEM A:IF HUMCAZ$)>96 AND HUMCA2$)<182 THEN AS=3.5GOTo 3gieIF AZ¥E1.13="A" AND RZ$SE2.2d="'" AHD AZ$LLS.L3] *THEH RAS=2IF R2$L1.11=""'" AND R2Z$LCLS,LEJ="'" THEM AS=1IF RS»@ THEN 3818AS=5GOTOIF A
aTHEM RZ$=R2EL2,0L5-1
31IF AS=2 THEH RA2$=AZ$C3.L5-1a
THEN A2%=A2%5 THEHW AZ$=RAZ2%THEHM RA2%=A2%
LO=LENCAZ$?RETURHN! ALPHA STRHG PLACEMENT Subk=1FOR 51 TOHB1<J)=NUMLIAL$EK. K1)IF RISEK, KI="&" THEN B1(Ja=128IF AL$CK. KI="2" THEN B1{ )=1zIF BLI$EK.KI="#" THEN Bl(b=
o
IoT
RETURN! DUTPUT STRING GEHERATIONo oM
FOR I=J%s ToO CA-13%8+1 STEFP-1
Ba2(Ix=
3¢y MODoIy M
BE="3> 3y *FOR I=1 TO 8NIF B2C1)=8 THEN BS=Hss">> IF B2(I>=1 THEN B$=B3$&">>>:
8322923
9a SU
ULet
10=gT2i
T28
DPIVEOEOTEHD
HEXKT IB$=B3&.">
CHR$ (31 0%
DATASEG
PRINT USINGtzeap”
IF AL(ZIF R1CZG070 4993PRINT USIMG "8SeA" . EfFRINT CHR$(27Y&CHR$(33>L=L+1IF L<15 THEHPRINT CHR$(1
4Bz4
TURH
I ERRORS
DISP "IMNPUT STRING MWAS TooLONG. PLERSE CHECK IT.“:ERRLGOTD Li7@T9=B | FLAG FOR WULL STRFOR I=1 TO LEHCTS%IF T9$CI,I3<>" " THEN S865&HEXT 1T=1 ! GET HERE IF MULL STRETURHTo$=T2%CI1]L=LENCTO%IF TO$LL.LI<>" " THEH 5858T3%$=T93$E1.L-11GOTO 5276E=ERRHNE1=ERRLIF E<>62 THEHW Buas@DISP “CARTRIDGE MOT IN PLALCE."GOT0 3i@8IF E<>66 THEH 2686GISP "FILE MOT OPENEG. WILLTRY AGAIN.™
GOTo 1asIF E<»E7 AMND E<>73 THEM SieaDISP “CAN MOT FIND FILE '41FCHS' ™DISP “GET TAPE WITH '41FCNS
' FILE OM IT.®DISP “HAVE YOU IHWSERTED THETAPE? 'Y'OR'N'™INPUT X#IF M&="¥" THEN 185IF H$<{>“MN" THEH 3119GOTO 2158DISP “TAPE READ ERROR *GOTD 914@E=ERENEi1=ERRLPRINT "ERROR®E."AT LINHE".E1DISF "ABORTED"END
HP-85A Adaptations of PRGMBR and FULFCN 79
5 13 8 @& .8 B B3.8 . 1.8
& . -. Sl
5.8 .8 .6.8 .5 ., 8 ., B
. -. 71z .e 4.1
7 5.1o1 @, 12
1 5,03,1 @ 4 141 6. @ a 181 8 . @ FI . z .,1 1.8 CPROMET, & 142.8, FSE -1 R-0 . & . 111 .4 . 15 .
o1 LB S . ]S S8 L1 aSt . .8 a
g . s oT o 14 . ]a . §. 5.8 .8
. 7.4 .8 .84 . g 5 .13 Ba . L 717,v . 2 18 .08 .15 3 7 g .4 .z 3 - =1B . 5. " 3 8. 1z. 8.0 3 ;5 . 5
.7 .8 . 8@ a 3. a .8.3 .1 .1 = - A5 .18, 8,8 3 T LR L1.18 . 8, 8 23 57— . 3 . 15. 15 .8 .8 tBa .2 .5 .1 &L8 LB . 121 |
g, 2 .1, 1 2. 4,8, 84. 11,8 . 1 LS 11 .8, o8S L7 .1 . 1 L2 .15 .1 ..1z .8 .8 1 3,08, .2. 14, 1 1 £ 02,5., 3.8 1 7 .e5.5, 8 1 -S .3 .8 1 .7& .2 .8 1 S 4 L818 . 1 iz .1@ 1 STtI 1 So4 .45 1 LB .71@ 1 7.818 1 5 . 43 1 4 .51. 1 1.1a 11 ig .5 12 5.14 . 12 5. 34 . 2.9
()Jyretd1000 N.E. Circle Blvd., Corvallis, OR 37330
821563-90019 Printedin U.S.A.