This program is Copyright © 2007 by Torbjörn Wigren and is used here by
permission. This program is supplied without representation or warranty
of any kind. Torbjörn Wigren and The Museum of HP Calculators therefore
assume no responsibility and shall have no liability, consequential or
otherwise, of any kind arising from the use of this program material or
any part thereof.
The code was developed using HP-41CV, SERIAL NO. 2124S13142. It was
independently tested using the HP-41 MCODE Emulator, Release 3. Files
for this emulator are available for download at
http://www.it.uu.se/katalog/tw/information .
OVERVIEW
This set of subroutines provides string functions for the HP 41C/CV.
The functions "LEN", "RIGHT", "LEFT", "MID", "ADD", "ROL", "ROR",
"FIND", "VAL", "NUM2STR", "STR2NUM", "STO", "RCL", "STOXYZT" and
"RCLTZYX" are provided. The functions operate on strings in the
alpha-register, according to arguments provided in the x- and
y-registers. String results are returned in the alpha-register whereas
numerical results are returned in the x-register of the stack. All
functions allow string operations on strings with a maximum length of
6, 12, 18 or 24 characters, the choice being made by the user. All
characters of the HP 41C/CV may be used. The characters of the strings
are numbered from 1 and upwards, starting with 1 for the leftmost
character. The extended functions module also contains a set of string
functions that extends the string handling functionality of the HP
41C/CV calculator itself. However, users that do not have access to this
module, are familiar with synthetic programming or own a HP 41CX are
limited to the basic append, compare and shift functions that operate on
strings in the HP 41C/CV. The intention has been to use basic
programming techniques, to allow for easy adaptation of the code to
specific applications. The provided string manipulating functionality
is believed to be useful for a number of programming tasks, including
encryption/decryption, password generation, logic simulation and the
design of games.
CHARACTER STRING MANIPULATION
All string handling functions require that the number of registers used
for holding strings (1,2,3 or 4) is stored in register 15. This results
in string handling of strings with a maximum of 6, 12, 18 or 24
characters. The selected number of registers affects the execution
times significantly.
"LEN"
The function returns the length (number of characters) of the string in
the alpha-register, in the x-register. The string remains in the
alpha-register after execution. In case the string in the alpha-register
is longer than what can be stored according to the specified number of
registers used for holding strings, the right part of the string is
first truncated, after which the function is applied. If the stack needs
to be preserved, "STOXYZT" / "RCLTZYX" can be applied.
Subroutines: "INIT"
"RCL" (address 11)
Stack: Used
Data registers: 00 (length of string)
02 ("" - empty string)
03 (last set of 6 removed characters)
04 (" " - one space)
Labels: 00
01
02
Flags 00
Arguments: alpha-register 0-24 characters
The algorithm operates by first applying ASHF to remove 6 characters
at a time until the alpha-register is empty. The number of removed
characters are increased by 6 for each shift. The last non-empty
character string of the alpha-register is then restored to the
alpha-register, after which one space is appended to this string. It is
then checked if an ASHF leaves the alpha-register empty or not. If
still empty, the value of the length counter is reduced by one and the
space addition is repeated. The process terminates when the ASHF
operation does no longer result in an empty alpha-register.
"RIGHT"
The function returns the right characters of the string stored in the
alpha-register, from and including the character with the number stored
in the x-register. The result is returned in the alpha-register, with
the argument remaining in the x-register at end of execution. In case
the string in the alpha-register is longer than what can be stored
according to the specified number of registers used for holding strings,
the right part of the string is first truncated, after which the
function is applied. If the stack needs to be preserved, "STOXYZT" /
"RCLTZYX" can be applied.
Subroutines: "INIT"
"STO" (address 6)
Stack: Used
Data registers: 00 (counter)
01 (argument of x-register)
03 (number of characters (or blocks) to include
in the result)
04 (" " - one space)
06 (part of result)
07 (part of result)
08 (part of result)
09 (part of result)
Labels: 03
04
05
Arguments: alpha-register 0-24 characters
x-register 1-25 (25 resulting in empty string)
The algorithm first removes blocks of 6 characters from the string in
the alpha-register, decreasing the argument until it is less than 6.
This is handled by register 03 that is initialized appropriately by
"INIT". The remaining string is stored in registers 06 to 09, at label
04. The remaining characters to remove are processed at label 05.
A string of spaces with a length such that the length plus the remaining
characters to remove equals 6 is first created. The first 6 characters
of the remaining string are then added to the sting of spaces and ASHF
is applied. This removes the remaining characters. The rest of the
blocks of characters of the result are finally retrieved from registers
07 to 09.
"LEFT"
The function returns the left characters of the string stored in the
alpha-register, up to and including the character with the number
stored in the x-register. The result is returned in the alpha-register,
with the argument remaining in the x-register at end of execution. In
case the string in the alpha-register is longer than what can be stored
according to the specified number of registers used for holding strings,
the right part of the string is first truncated, after which the
function is applied. If the stack needs to be preserved, "STOXYZT" /
"RCLTZYX" can be applied.
Subroutines: "INIT"
"RCL" (address 6)
Stack: Used
Data registers: 00 (counter)
01 (argument of x-register)
03 (number of character blocks to remove)
04 (" " - one space)
05 (indirect storage address (6))
Labels: 06
07
08
09
10
16
Arguments: alpha-register 0-24 characters
x-register 0-24 (0 resulting in empty string)
The algorithm first stores blocks of 6 characters in register 06 and on,
decreasing the argument until it is less than 6. This is handled by
register 03 that is initialized appropriately by "INIT", and by the
indirect address stored in register 05. The number of remaining
charcters to include in the result are then computed at label 07 from
the updated indirect address of register 05. If the number of remaing
characters equals 0 the algorithm proceeds to label 16 and terminates.
Otherwise the last block of 6 characters (of which a subset is to be
included in the result) is stored. The final step of the algorithm is
to generate the string of the remaning characters to add from the last
saved block. In order to do so, a string of spaces of length equal to 6
minus the number of characters to add is first constructed at label 8.
The last block of 6 characters is appended to the constructed space
string in the alpha-register. The first 6 characters are then stored.
The remaining characters to add are now at the end of the stored result.
At label 9 a new string of spaces is generated so that the TOTAL number
of spaces in the generated strings of spaces equals 6. The string of
length 6 with the characters to add at the end is appended to the
alpha-register, rendering a string with 6 spaces at the beginning and
the remaining characters to add at the end. Applying an ASHF operation
removes the spaces, after which the final block of the result can be
stored. Finally, at label 16, the result is appended in the
alpha-register from the stored blocks of 6 characters, and the argument
is restored to the x-register.
"MID"
The function returns the mid characters of the string stored in the
alpha-register. The x-register specifies the right inclusive character
number defining the extracted string, whereas the y-register specifies
the left character number defining the extracted string. The result is
returned in the alpha-register, with the arguments remaining in the
x-register and the y-register at end of execution. In case the string
in the alpha-register is longer than what can be stored according to the
specified number of registers used for holding strings, the right part
of the string is first truncated, after which the function is applied.
If the stack needs to be preserved, "STOXYZT" / "RCLTZYX" can be
applied.
Subroutines: "LEFT" (right argument)
"RIGHT" (left argument).
Stack: Used
Data registers: 10 (left argument)
16 (right argument)
Arguments: alpha-register 0-24 characters
x-register 1-24
y-register 1-24
The function first extracts the left part, using "LEFT" and the desired
right argument. Then the result is produced by execution of "RIGHT" with
the desired left argument.
"ROL"
The function rotates the string of the alpha-register the number of
steps left specified in the x-register. The x-register remains after
execution. In case the string in the alpha-register is longer than what
can be stored according to the specified number of registers used for
holding strings, the right part of the string is first truncated, after
which the function is applied. If the stack needs to be preserved,
"STOXYZT" / "RCLTZYX" can be applied.
Subroutines: "STO" (address 21 - the string,
address 34 - the result after "LEFT")
"LEN"
"LEFT" (minimum steps to rotate)
"RCL" (address 21 - the string)
"RIGHT" (argument to compute part of the string forming
the leftmost part of the result)
"ADD" (address 34)
Stack: Used
Data registers: 28 (argument)
29 (length of string)
30 (minimum steps to rotate - modulo applied)
Arguments: alpha-register 1-24 characters
x-register any integer (negative results in "ROR")
The function first stores the string at address 21 and computes its
length with "LEN". The MOD operation avoids any need to rotate more than
one complete revolution. The part to become the last part is first
extracted by "LEFT" and stored at address 34. The stored complete string
is restored to the alpha register and the part that is to form the first
part of the result is extracted with "RIGHT". "ADD" applied to address
34 then forms the result.
"ROR"
The function rotates the string of the alpha-register the number of
steps right specified in the x-register. The x-register remains after
execution. In case the string in the alpha-register is longer than what
can be stored according to the specified number of registers used for
holding strings, the right part of the string is first truncated, after
which the function is applied. If the stack needs to be preserved,
"STOXYZT" / "RCLTZYX" can be applied.
Subroutines: "LEN"
"ROL" (equivalent steps of left rotatation)
Stack: Used
Data registers: 29 (length of string)
31 (argument - steps to rotate right)
Arguments: alpha-register 1-24 characters
x-register any integer (negative results in "ROL")
The function computes the number of steps that would result in the same
result by a left rotation, then applies "ROL".
"ADD"
The function augments the string with the address provided in the
x-register, to the string in the alpha-register. The use of indirect
addressing ensures that all registers can be used for storage of
strings. The argument remains in the x-register at end of execution. If
the stack needs to be preserved, "STOXYZT" / "RCLTZYX" can be applied.
Note: No truncation of the right part of the string in the
alpha-register is applied.
Stack: Used
Data registers: 00 (string block counter)
03 (argument plus number of registers per string)
10 (argument - string address)
15 (number of registers per string (1,2,3 or 4))
Labels: 17
Arguments: alpha-register 0-24 characters
x-register any valid register address
The function adds each register of the string by indirect addressing.
"FIND"
The function returns the (2-digit) positions of an up to 6 character
string, stored at the address specified in the x-register, in the string
of the alpha register. The string in the alpha register remains after
execution and the result is presented in the x-register. In case the
string in the alpha-register is longer than what can be stored according
to the specified number of registers used for holding strings, the right
part of the string is first truncated, after which the function is
applied. If the stack needs to be preserved, "STOXYZT" / "RCLTZYX" can
be applied.
Subroutines: "STO" (address 21 - string to search)
"LEN"
"RCL" (address 21)
"MID" (arguments to extract a piece of
the searched string, the piece having the length of
the search string)
Stack: Used
Data registers: 17 (argument - address of 6 character string)
18 (length of searched string)
19 (length of search string minus 1)
20 (pointer to the currently investigated position)
27 (multiplier to encode 2 digit positions
as an integer)
28 (result)
Labels: 34
35
Arguments: alpha-register 1-24 characters
x-register any valid register address,
reg x (the string searched for) 1-6 characters
The function first stores the original string and computes its length.
The function also computes the length of the string searched for. Then
all possible positions of the string searched for, in the searched
string, are extracted from the searched string by "MID". It is then
tested whether the extracted part is the same as the string searched
for. If so, the position (leftmost character) is encoded as a two bit
number in the integer result.
NUMERICAL STRING MANIPULATION
"VAL"
The function transforms a string in the alpha-register consisting of the
characters 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9, to the corresponding
numerical nonnegative integer value. The result is displayed in the
x-register and the string remains in the alpha-register after execution.
In case the string in the alpha-register is longer than what can be
stored according to the specified number of registers used for holding
strings, the right part of the string is first truncated, after which
the function is applied. If the stack needs to be preserved, "STOXYZT" /
"RCLTZYX" can be applied. Note that the execution time is significantly
higher than for the character manipulating string functions.
Subroutines: "LEN (string in alpha register)"
"STO" (address 21)
"MID" (current character pointer)
"RCL" (address 21)
Stack: Used
Data registers: 05 (indirect address (character))
17 (current character pointer)
18 (result)
19 (void)
20 (number multiplier)
Labels: 13
14
15
"1"
"2"
"3"
"4"
"5"
"6"
"7"
"8"
"9"
"0"
Arguments: alpha-register 1-24 characters
The algorithm first calls "LEN" to compute the length of the character
string, in order to set up loops. The provided string is also stored,
starting at register 21. "MID" is then used to extract each character,
starting at the right. For each character, the value of register 20 is
multiplied by 10, thereby allowing the contribution of each character to
be added to the result after multiplication with register 20 of the
number obtained by transforming the character to a numerical value. This
transformation is performed by an indirect addressing, using the
extracted character as the address to one of the charactre labels "0" to
"9".
"NUM2STR"
The function transforms any numerical value of the x-register to a
string in the alpha register. All formats are covered.
Data register: 00 (numerical value)
"STR2NUM"
The function transforms a string corresponding to a floating point
numerical value, to the numerical value. The string remains in the
alpha-register after execution and the result appears in the x-register.
The functions handles FIX, SCI and ENG formats, however there must only
be ONE SEPARATOR. This must be the COMMA that separates the integer and
fractional parts of the mantissa. If the stack needs to be preserved,
"STOXYZT" / "RCLTZYX" can be applied. Note that the execution time is
significantly higher than for the character manipulating string
functions. Note also that the number of registers used for string
storage (register 15) needs to be set to 3 or 4.
Subroutines: "STO" (address 34)
"RCL" (address 34)
"LEN" (to combine mantissa)
"LEFT" (argument 1 (sign))
"MID" (argument counter, argument to retrieve fractional
and integer parts of mantissa)
"RIGHT" (argument to retrieve exponent)
"VAL" (transforms nonnegative part of exponent,
fractional and integer parts of mantissa,
to numerical values)
Stack: Used
Data registers: 27 (length of string)
28 (sign of mantissa)
29 (integre part of mantissa,mantissa and result)
30 (sign of exponent, 10^(exponent * sign of exponent))
31 (position of ",")
32(position of "E")
33 (counter)
38 ("-")
39 (",")
40 ("E")
41 (currently processed character)
Labels: 18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Arguments: alpha-register 1-24 characters representing a valid floating
point number
The function first initializes necessary registers for storage of the
different parts of the floating point number. It also stores the string
at string address 34. It then uses character manipulating string
functions to find the sign of the exponent (if any), the sign of the
mantissa, the position of the separator (if any) between the integer and
fractional parts of the mantissa, the position of the exponent (if any),
represented by the character E. Given this information, the three
strings corresponding to the nonnegative integer part of the mantissa,
the nonnegative fractional part of the mantissa (if any) and the
nonnegative integer part of the exponent can all be extracted from the
original string, again using character manipulating string functions.
The results are then converted to numerical values using "VAL". From
this it is straightforward to build up the umerical result.
GENERAL STRING HANDLING AND SUPPORT FUNCTIONS
"STO"
The function stores the string in the alpha-register indirectly in the
registers starting with the address provided in the x-register. The
indirect addressing secures that all registers can be used for storage
of strings. The string remains in the alpha-register after execution.
In case the string in the alpha-register is longer than what can be
stored according to the specified number of registers used for holding
strings, the right part of the string is first truncated, after which
the function is applied. If the stack needs to be preserved, "STOXYZT" /
"RCLTZYX" can be applied.
Subroutines: "RCL" (argument of x-register)
Stack: Used
Data registers: 15 (number of registers per string, 1,2,3 or 4)
25 (running register address)
26 (string address plus number of registers)
Labels: 11
Arguments: alpha-register 0-24 characters
x-register any valid register address
The function applies indirect addressing to store a string starting in
the register specified in the x-register. The number of registers used
for storage equals the number spcified in register 15. Six characters
are stored in each register.
"RCL"
The function recalls the string specified with the address provided in
the x-register. The string is recalled to the alpha-register. The
indirect addressing applied secures that all registers can be used for
storage of strings. The argument remains in the x-register after
execution. If the stack needs to be preserved, "STOXYZT" / "RCLTZYX" can
be applied.
Stack: Used
Data registers: 15 (number of registers per string, 1,2,3 or 4)
25 (running register address)
26 (string address plus number of registers)
Labels: 12
Arguments: x-register any valid register address
The function applies indirect addressing to recall a string starting in
the register specified in the x-register. The number of registers used
for recalling equals the number spcified in register 15. Six characters
are recalled from each register.
"STOXYZT"
This function stores the stack. To be applied before string function
calls whenever the stack should be preserved.
Data registers: 42 (x-register)
43 (y-register)
44 (z-register)
45 (t-register)
"RCLTZYX"
This function restores the stack, as saved by "STOXYZT". To be applied
after string function calls whenever the stack should be preserved.
Data registers: 42 (x-register)
43 (y-register)
44 (z-register)
45 (t-register)
"INIT"
The function performs common initial storing of the string in the
alpha-register and any argument of the x-register. The subroutine also
sets up common register values needed for string manipulation.
Subroutines: "STO" (address 11)
"RCL" (address 11)
Stack: Used
Data registers: 00 (argument of x-register)
01 (argument of x-register)
02 ("" - empty string)
03 (integer part of (argument in x-register)/6)
04 (" " - one space)
05 (indirect storage address (6))
06 ("" - empty string)
07 ("" - empty string)
08 ("" - empty string)
09 ("" - empty string)
Flags: 00
SETS OF FUNCTIONS
The minimum number of functions that form a useful set include "LEN",
"RIGHT", "LEFT", "ADD", "STO", "RCL", ("INIT"). These functions need no
other supporting functions for their execution. The following resources
are consumed by this minimum set.
Data register used: <=26.
Labels used: <=17.
Flags used: Flag 0.
Remaining functions can be added to this set as desired. In case of
addition of VAL the limits on data registers and labels above still
holds, otherwise please consult the description above. In case a known
or fixed length is used, then LEN may be omitted by replacements in the
code. When the complete set of functions is used, the following limits
apply:
Data registers used: <=45.
Labels used: <= 35.
Flags used: Flag 0.
The complete set of functions consume 185 data registers for the code.
In case other combinations of string functions are used the user is
referred to the documentation of each function for information of which
subroutines, data registers and labels that are used. The minimum set
of functions do not need additional support. However, when other
functions are added this may not apply. "STR2NUM" e.g. makes use of
"VAL". The user is referred to the documentation of each function for
details.
EXAMPLE
3 data registers per string is to be used.
3
STO 15
Also store an empty space in data register 53.
" "
ASTO 53
Store a string in the alpha-register.
"HP-41CV CALCULATOR"
Then store it, starting at data register 50.
50
XEQ "STO"
The numerical display and the alpha-register remain unaffected. "HP-41C"
is now stored in data register 50, "V CALC" in data register 51 and
"ULATOR" in data register 52.
Compute the length of the string in the alpha-register.
XEQ "LEN"
The numerical display shows the result 18. The alpha-register remains
unaffected.
Find the location of the space in the string.
53
XEQ "FIND"
The numerical display shows the result 8.
Extract the first word of the string in the alpha-register.
7
XEQ "LEFT"
The numerical display is unaffected. The alpha-register shows the result
"HP-41CV".
Store the result, starting at register 54.
54
XEQ "STO"
"HP-41C" is now stored in register 54, "V" in data register 55 and ""
in data register 56.
Extract the fourth and fifth characters of the string in the
alpha-register.
4
ENTER
5
XEQ "MID"
The x- and y-registers remain unaffected. The alpha-register shows the
result "41".
Transform the result to a numerical value.
XEQ "VAL"
The alpha-register remains unaffected. The numerical dispaly shows the
numerical value 41.
Recall the original string and rotate left 7 steps.
50
XEQ "RCL"
7
XEQ "ROL"
The numerical display remains unaffected. The alpha-register displays
the result " CALCULATORHP-41CV".
Recover the original string.
7
XEQ "ROR"
The numerical display remains unaffected. The alpha-register shows the
result "HP-41CV CALCULATOR".
Then find the location of the letter "C" in the string of the
alpha-register. First store "C" in data register 60.
"C"
ASTO 60
"C" is now stored in alpha-register and in data register 60.
Recall the original string starting in data register 50, and search
for "C".
50
XEQ "RCL"
60
XEQ "FIND"
The display shows 120906, i.e positions 12, 09 and 06. The
alpha-register is unaffected.
Extract the second word of the string and add the string stored at data
register 54. Also compute the length of the result.
9
XEQ "RIGHT"
54
XEQ "ADD"
XEQ "LEN"
The numerical display shows the length 17. The alpha-register shows the
result "CALCULATORHP-41CV". This is because the space is now gone.
Then set the calculator in scientific mode with 4 decimals. Key in
-34.56e-78.
SCI 4
-34.56
EEX
-78
ENTER
The numerical display shows -3,4560 -77.
Then transform to a string and clear the display.
XEQ "NUM2STR"
CLX
The alpha-register displays the string -3,4560E-77. The numerical
display shows 0.
Finally, restore the numerical value.
XEQ "STR2NUM"
The numerical display shows the result -3,4560 -77. The alpha-register
remains unaffected.
CODE
Note: In case the code is keyed in manually, it is required to input all
alphanumeric labels first. The reasom is that overloading of names of
built in functions is used.
001 LBL "LEN"
002 XEQ "INIT"
003 0
004 STO 00
005 LBL 00
006 ASTO 03
007 ASHF
008 ASTO X
009 RCL 02
010 X=Y?
011 SF 00
012 6
013 ST+ 00
014 FC?C 00
015 GTO 00
016 LBL 01
017 ARCL 03
018 ARCL 04
019 ASTO 03
020 ASHF
021 ASTO X
022 RCL 02
023 X#Y?
024 GTO 02
025 1
026 ST- 00
027 GTO 01
028 LBL 02
029 11
030 XEQ "RCL"
031 RCL 00
032 RTN
033 LBL "RIGHT"
034 XEQ "INIT"
035 1
036 ST- 00
037 RCL 00
038 6
039 /
040 INT
041 STO 03
042 LBL 03
043 RCL 03
044 X=0?
045 GTO 04
046 ASHF
047 6
048 ST- 00
049 1
050 ST- 03
051 GTO 03
052 LBL 04
053 6
054 XEQ "STO"
055 CLA
056 LBL 05
057 ARCL 04
058 1
059 ST+ 00
060 RCL 00
061 6
062 x#Y?
063 GTO 05
064 ARCL 06
065 ASHF
066 ARCL 07
067 ARCL 08
068 ARCL 09
069 RCL 01
070 RTN
071 LBL "LEFT"
072 XEQ "INIT"
073 X=0?
074 GTO 07
075 LBL 06
076 ASTO IND 05
077 ASHF
078 1
079 ST- 03
080 ST+ 05
081 RCL 03
082 X#0?
083 GTO 06
084 LBL 07
085 RCL 05
086 6
087 -
088 6
089 *
090 ST- 00
091 RCL 00
092 X=0?
093 GTO 16
094 STO 03
095 ASTO IND 05
096 CLA
097 LBL 08
098 ARCL 04
099 1
100 ST+ 03
101 RCL 03
102 6
103 X#Y?
104 GTO 08
105 ARCL IND 05
106 ASTO IND 05
107 CLA
108 LBL 09
109 ARCL 04
110 1
111 ST- 00
112 RCL 00
113 X#0?
114 GTO 09
115 LBL 10
116 ARCL IND 05
117 ASHF
118 ASTO IND 05
119 LBL 16
120 6
121 XEQ "RCL"
122 RCL 01
123 RTN
124 LBL "MID"
125 STO 16
126 X<>Y
127 STO 10
128 X<>Y
129 XEQ "LEFT"
130 RCL 10
131 XEQ "RIGHT"
132 RCL 16
133 RTN
134 LBL "INIT"
135 STO 00
136 STO 01
137 6
138 STO 05
139 /
140 INT
141 STO 03
142 CF 00
143 11
144 XEQ "STO"
145 CLA
146 ASTO 02
147 ASTO 06
148 ASTO 07
149 ASTO 08
150 ASTO 09
151 " " - One space
152 ASTO 04
153 11
154 XEQ "RCL"
155 RCL 03
156 RTN
157 LBL "STO"
158 STO 25
159 STO 26
160 RCL 15
161 ST+ 26
162 LBL 11
163 ASTO IND 25
164 ASHF
165 1
166 ST+ 25
167 RCL 25
168 RCL 26
169 X>Y?
170 GTO 11
171 RCL 15
172 ST- 26
173 RCL 26
174 XEQ "RCL"
175 RTN
176 LBL "RCL"
177 CLA
178 STO 25
179 STO 26
180 RCL 15
181 ST+ 26
182 LBL 12
183 ARCL IND 25
184 1
185 ST+ 25
186 RCL 25
187 RCL 26
188 X>Y?
189 GTO 12
190 RCL 26
191 RCL 15
192 -
193 RTN
194 LBL "VAL"
195 XEQ "LEN"
196 STO 17
197 0
198 STO 18
199 STO 19
200 1
201 STO 20
202 21
203 XEQ "STO"
204 LBL 13
205 RCL 17
206 ENTER^
207 XEQ "MID"
208 ASTO 05
209 21
210 XEQ "RCL"
211 RCL 20
212 GTO IND 05
213 LBL 14
214 ST+ 18
215 10
216 ST* 20
217 1
218 ST- 17
219 RCL 17
220 X>0?
221 GTO 13
222 RCL 18
223 RTN
224 LBL "1"
225 1
226 GTO 15
227 LBL "2"
228 2
229 GTO 15
230 LBL "3"
231 3
232 GTO 15
233 LBL "4"
234 4
235 GTO 15
236 LBL "5"
237 5
238 GTO 15
239 LBL "6"
240 6
241 GTO 15
242 LBL "7"
243 7
244 GTO 15
245 LBL "8"
246 8
247 GTO 15
248 LBL "9"
249 9
250 GTO 15
251 LBL "0"
252 0
253 LBL 15
254 *
255 GTO 14
256 LBL "ADD"
257 STO 10
258 STO 00
259 STO 03
260 RCL 15
261 ST+ 03
262 LBL 17
263 ARCL IND 00
264 1
265 ST+ 00
266 RCL 00
267 RCL 03
268 X>Y?
269 GTO 17
270 RCL 10
271 RTN
272 LBL "NUM2STR"
273 STO 00
274 CLA
275 ARCL 00
276 RTN
277 LBL "STR2NUM"
278 0
279 STO 29
280 STO 30
281 STO 31
282 STO 32
283 34
284 XEQ "STO"
285 CLA
286 "-"
287 ASTO 38
288 CLA
289 "," - Assumes that , is the divider.
290 ASTO 39
291 CLA
292 "E"
293 ASTO 40
294 34
295 XEQ "RCL"
296 XEQ "LEN"
297 STO 27
298 1
299 XEQ "LEFT"
300 ASTO X
301 RCL 38
302 X=Y?
303 GTO 18
304 1
305 GTO 19
306 LBL 18
307 -1
308 LBL 19
309 STO 28
310 X<0?
311 GTO 20
312 1
313 STO 33
314 GTO 21
315 LBL 20
316 2
317 STO 33
318 LBL 21
319 34
320 XEQ "RCL"
321 RCL 33
322 ENTER^
323 XEQ "MID"
324 ASTO 41
325 ASTO X
326 RCL 39
327 X#Y?
328 GTO 22
329 RCL 33
330 STO 31
331 LBL 22
332 CLA
333 ARCL 41
334 ASTO X
335 RCL 40
336 X#Y?
337 GTO 23
338 RCL 33
339 STO 32
340 LBL 23
341 CLA
342 ARCL 41
343 ASTO X
344 RCL 38
345 X#Y?
346 GTO 24
347 -1
348 STO 30
349 LBL 24
350 1
351 ST+ 33
352 RCL 27
353 RCL 33
354 X<=Y?
355 GTO 21
356 34
357 XEQ "RCL"
358 RCL 32
359 X=0?
360 GTO 25
361 RCL 30
362 X=0?
363 GTO 26
364 RCL 32
365 2
366 +
367 GTO 27
368 LBL 26
369 1
370 STO 30
371 RCL 32
372 1
373 +
374 LBL 27
375 XEQ "RIGHT"
376 XEQ "VAL"
377 RCL 30
378 *
379 10^X
380 STO 30
381 34
382 XEQ "RCL"
383 LBL 25
384 RCL 32
385 X#0?
386 GTO 28
387 1
388 STO 30
389 RCL 27
390 1
391 +
392 STO 32
393 LBL 28
394 RCL 31
395 X=0?
396 GTO 29
397 1
398 +
399 RCL 32
400 1
401 -
402 XEQ "MID"
403 XEQ "VAL"
404 STO 29
405 XEQ "LEN"
406 10^X
407 ST/ 29
408 LBL 29
409 34
410 XEQ "RCL"
411 RCL 31
412 X=0?
413 GTO 30
414 1
415 -
416 GTO 31
417 LBL 30
418 RCL 32
419 1
420 -
421 LBL 31
422 RCL 28
423 X>0?
424 GTO 32
425 RDN
426 2
427 GTO 33
428 LBL 32
429 RDN
430 1
431 LBL 33
432 X<>Y
433 XEQ "MID"
434 XEQ "VAL"
435 ST+ 29
436 RCL 28
437 ST* 29
438 RCL 30
439 ST* 29
440 34
441 XEQ "RCL"
442 RCL 29
443 RTN
444 LBL "STOXYZT"
445 STO 42
446 RDN
447 STO 43
448 RDN
449 STO 44
450 RDN
451 STO 45
452 RDN
453 RTN
454 LBL "RCLTZYX"
455 RCL 45
456 RCL 44
457 RCL 43
458 RCL 42
459 RTN
460 LBL "ROL"
461 STO 28
462 21
463 XEQ "STO"
464 XEQ "LEN"
465 STO 29
466 RCL 28
467 X<>Y
468 MOD
469 STO 30
470 XEQ "LEFT"
471 34
472 XEQ "STO"
473 21
474 XEQ "RCL"
475 RCL 30
476 1
477 +
478 XEQ "RIGHT"
479 34
480 XEQ "ADD"
481 RCL 28
482 RTN
483 LBL "ROR"
484 STO 31
485 XEQ "LEN"
486 STO 29
487 RCL 31
488 X<>Y
489 MOD
490 CHS
491 RCL 29
492 +
493 XEQ "ROL"
494 RCL 31
495 RTN
496 LBL "FIND"
497 STO 17
498 21
499 XEQ "STO"
500 XEQ "RCL"
501 XEQ "LEN"
502 STO 18
503 CLA
504 ARCL IND 17
505 XEQ "LEN"
506 1
507 -
508 STO 19
509 1
510 STO 20
511 0
512 STO 27
513 STO 28
514 LBL 34
515 21
516 XEQ "RCL"
517 RCL 20
518 RCL 20
519 RCL 19
520 +
521 XEQ "MID"
522 ASTO X
523 RCL IND 17
524 X#Y?
525 GTO 35
526 RCL 27
527 10^X
528 RCL 20
529 *
530 ST+ 28
531 2
532 ST+ 27
533 LBL 35
534 1
535 ST+ 20
536 RCL 18
537 RCL 19
538 -
539 RCL 20
540 X<=Y?
541 GTO 34
542 21
543 XEQ "RCL"
544 RCL 28
545 RTN
546 END