a very weird 12c program Message #1 Posted by Don Shepherd on 29 May 2005, 8:55 p.m.
OK guys, I finally found a use for indirect addressing on a 12c. I know that Valentin and Katie, among others I'm sure, have used this concept before, and now it's my turn.
Here is the background. When I die, I want my tombstone to read "Here lies Don Shepherd. He lived 10110110110100101 days." That would be the number of days I lived, in binary. Yes, I know this is weird, but where is it written that you have to be normal? The problem is, I won't be around to tell the stonecutter what number to use. Thus the need for a program that my wife can run after I reach the pearly gates.
Since my 12c will surely be around in another 3040 years (probably using the current set of batteries too!), that is my platform. I will leave instructions for my wife to run the program: 8.141950 ENTER (the date I died in the format mm.ddyyyy) R/S. After the program runs, RCL 1 and write down the ones and zeroes, then RCL 2 and write down the ones and zeroes (when you RCL 2, if there are less than 10 digits displayed, add zeroes to the LEFT until you have 10 digits). Give these digits to the stonecutter.
It is necessary to use two registers for the binary equivalent of the decimal number of days. That is where indirect addressing works like a charm. Line numbers 22 to 24 in the listing are where the ones and zeroes are added, either to register 2 (for the first part) or 1 (for the last part).
Anyhow, I know this is kind of dumb, but it does point out that indirect addressing on a 12c can be a useful thing. Thanks to Katie and Valentin.
Here is the 12c program listing:
Register Usage
0 # of days between 2 dates, integer
1 output binary value, high order bits
2 output binary value, low order bits
3 multiplier (1, 10, 100, 1000, and so on)
4 10000000000 constant
5 temp use
01 dys days between 2 dates entered on stack
02 sto 0
03 clr stat clears R1R6 (only need 1 and 2 though)
04 1 multiplier starts at 1
05 sto 3
06 2 add into R2 at the start
07 n
08 1
09 eex
10 1
11 0
12 sto 4 R4 tests when to switch to R1
13 rcl 0
14 2 loop starts here
15 /
16 sto 5 temp storage
17 frac will be .0 or .5
18 2
19 x will be 0 or 1
20 rcl 3 multiplier
21 x
22 rcl cfj
23 +
24 sto cfj indirect add to R2 or R1
25 1
26 0
27 sto x 3 update multiplier
28 rcl 3 multiplier
29 rcl 4 if 10^10 switch to R1
30 
31 x=0
32 gto 34
33 gto 37
34 1
35 sto 3 start multiplier at 1 again
36 n switch to R1
37 rcl 5 recall temp value
38 intg only look at integer part
39 x=0
40 gto 00 you are done
41 gto 14 else keep looping
