HP Articles Forum
[Return to the Index ]
[ Previous | Next ]
AWK Translator for Keycodes
Posted by bill duncan, ve3ied on 23 Apr 2000, 1:08 a.m.
I have a number of calculators I can reach for.
I have three generations of the venerable HP-41C (a C, CV and a CX), HP-16C, HP-95lx, and an HP-48GX. (I also used to have an HP-15C, but someone else reached for it when I wasn't looking...)
So which one do I reach for the most? It's the old 80/20 rule. I'm not a "rocket scientist", so I don't spend my days doing much calculus. My trusty old HP-29C does what I need most of the time. It's the oldest design, and the least capable machine I have. I guess I just like the solid feel of the Woodstock series. The HP-41's seem frail by comparison and the HP-48GX is just, well, big.
While pulling out a pad of graph paper to copy down (yet again) the routines which happened to be in the HP-29C (sort of like a manual backup), I decided that this was silly. I'm surrounded by Linux systems. Why copy the contents of the calculator to paper?
Of course, like all the old "keystroke programmables", the keycodes that needed to be translated back to English. Boring. Why not get the computer to do that too?
I've designed the following program such that theoretically it can also be used for calculators other than the HP-29C. If I ever get a replacement for my HP-15C, I may even test that theory... (Anyone have a line on one for a good price?)
It was written in AWK which is readily available if you have a Unix or Linux based system. (Some Unix systems will call this "nawk", or you may have "gawk" or "mawk" installed.)
If you are still using a Microsoft or Apple based system, there are versions
of AWK available. I recommend
"mawk" or "gawk".
(And I really recommend switching to
Linux...
There is nothing spectacular about the program. It's fairly simple, and uses a separate symbol table which might be changed for another calculator. I thought that I might improve the program by doing page headers etc., but that's left as an exercise for another day (or for someone else). Email me if you have suggestions or improvements you'd like to make.
The awk script is available here and the symbol table for the HP-29C is available here.
The program will convert simple keycode listings (without the line numbers) such as the following snippet:
# -------------------- # %CH - Percent change # -------------------- 15 13 01 21 41 14 73 71 33 02 61 15 12 13 01 ... ...
Here is a sample output formatted listing of what I happen to have in my calculator now. The lines starting with an octothorpe (hash mark, "#") are just comments which I placed in the input file and come out the other end unaltered. The program generates the mnemonics and the line numbers, so that if I need to rekey the programs it is relatively easy. Certainly much more fun than looking at keycodes.
# @(#) HP-29C contents as of April 21, 2000 # @(#) $Id: 29c.html,v 1.1 2000/04/23 06:36:42 bduncan Exp bduncan $ # # Author: Bill Duncan (except where noted) # -------------------- # %CH - Percent change # -------------------- 01 15 13 01 LBL 1 02 21 x<>y 03 41 - 04 14 73 LASTx 05 71 / 06 33 EEX 07 02 2 08 61 * 09 15 12 RTN 10 13 01 GTO 1 # --------------------- # %T - Percent of total # --------------------- 11 15 13 02 LBL 2 12 15 74 1/X 13 15 21 % 14 15 74 1/X 15 15 12 RTN 16 13 02 GTO 2 # --------------------- # FIB # --------------------- # number in both x and y, flashes successive numbers in the series. # Standard Fibonacci sequence starts x=1, y=1. # Try y=1, x=3 which is an interesting sequence in that the numbers # approach integer powers of phi. # 17 15 13 08 LBL 8 18 51 + 19 14 73 LASTx 20 21 x<>y 21 14 74 PAUSE 22 13 08 GTO 8 # --------------------- # parallel resistors # --------------------- 23 15 13 04 LBL 4 24 15 74 1/X 25 21 x<>y 26 15 74 1/X 27 51 + 28 15 74 1/X 29 15 12 RTN 30 13 04 GTO 4 # --------------------- # degrees C to F # --------------------- # 31 15 13 05 LBL 5 32 09 9 33 61 * 34 05 5 35 71 / 36 03 3 37 02 2 38 51 + 39 15 12 RTN 40 13 05 GTO 5 # --------------------- # fib #2 # --------------------- # related to fib sequence # phi [(SQR(5)+1) / 2] stored in REG 05 before running! # key number in X, good approximation out to 35 or so... # this sequence comes close to phi^n # simple change to get standard Fibonacci sequence # just change the last instruction from a "+" to "-" and divide by sqrt(5) # 41 15 13 06 LBL 6 42 24 05 RCL 5 43 21 x<>y 44 14 64 Y^X 45 14 73 LASTx 46 24 05 RCL 5 47 01 1 48 41 - 49 32 CHS 50 21 x<>y 51 14 64 Y^X 52 51 + 53 15 12 RTN # --------------------- # quadradics # --------------------- # from 29c applications book page 6. # 54 15 13 07 LBL 7 55 23 00 STO 0 56 22 RDN 57 21 x<>y 58 23 71 00 STO / 0 59 71 / 60 02 2 61 71 / 62 32 CHS 63 23 01 STO 1 64 31 ENTER 65 15 63 x^2 66 24 00 RCL 0 67 41 - 68 74 R/S 69 15 41 x<0? 70 13 00 GTO 0 71 14 63 SQRT 72 23 41 01 STO - 1 73 21 x<>y 74 51 + 75 24 01 RCL 1 76 14 73 LASTx 77 15 51 x>0? 78 22 RDN 79 22 RDN 80 23 71 00 STO / 0 81 24 00 RCL 0 82 13 03 GTO 3 83 15 13 00 LBL 0 84 15 64 ABS 85 14 63 SQRT 86 21 x<>y 87 15 13 03 LBL 3 88 74 R/S 89 21 x<>y 90 13 03 GTO 3 # --------------------- # H.MS+ # --------------------- # numbers in x and y both in H.MS format # LASTx is lost. Ah well... # 91 15 13 09 LBL 9 92 15 72 ->H 93 21 x<>y 94 15 72 ->H 95 51 + 96 14 72 ->H.MS 97 15 12 RTN 98 13 09 GTO 9