HP41 program for programmable CAT 1 Message #25 Posted by PeterP on 29 Mar 2009, 8:05 p.m., in response to message #1 by Howard Owen
Hi,
The program below will show in reverse sequence all alpha labels as per Owain’s request. It makes good use of CCD functions that help decode the ENDs and Alpha Lables (and thanks to Clonix, et al they should be available to most of us in some shape or form). I hope it is at least a useful starting point.
Usage: - Execute a GTO.. (to be save…)
- XEQ ‘PCAT’
- See all alpha labels in reverse sequence.
PCAT only uses R00, leaving all other registers for any processing of the labels. Any such additional processing (e.g. saving to HP-IL) can be readily added to the LBL ‘CA’ (Check for Alpha label). An extension to only show the top level alpha is ‘straight forward and left to the ‘interested reader’ :-) (god, did I dread these words in my math books…)
The structure of the ENDs and alpha LBLs is (as everything else) exceptionally well explained on pp498-504 in Wlodeks ‘Extend your HP-41’ (if I’d be allowed only one book to bring about the HP-41, it would be this…). The first two bytes have always the structure |C bbbr | rrrr rrrr|. bbb is the number of bytes and r|rrrr rrrr| the number of registers to the next CAT 1 element. For alpha labels, this is followed by |F n+1 | kkkk kkkk | tttt tttt |…|, where n is the number of chars in the alpha label, |kkkk kkkk| is the keycode if it is assigned to a key and |ttttt tttt| are the chars.
CCD Functions used
- ’DCD’ – decode a NNNin x and append to alpha
- ‘A+’ - add one byte to the absolute address (in dec) in X
- ‘PEEKB’ – read the byte from absolute address in X
- ‘A+B’ – add the number of bytes in X to absolute address in Y
- ‘S>’ – shift X one bit to the right
- ‘bS?’ – check if the bit in X is set in the number in Y
Note: The listing below is not optimized for speed, elegance, length etc yet only meant as a starting point. (e.g. I used the unnecessary alpha labels and ends to test the program basically on itself…) I hope it is still helpful.
Cheers
Peter
LBL ‘PCAT’
RCL c
CLA
‘A’
DCD
ASHF
ASHF ;extract the right three digits = starting of .END.
XEQ ‘3H>D’ ;convert into dec
STO 00
A+
PEEKB
X<>Y
A+
PEEKB
X<>Y
RDN
XEQ ‘MA’ ;get distance in bytes to next CAT1 element
RCL 00
X<>Y
A+B ;abs address of next CAT1 element
STO 00
LBL 00
A+
PEEKB
X<>Y
A+
PEEKB
X<>Y
RDN
XEQ ‘MA’
X=0? ;first alpha label has 0 as distance to next CAT1 element
GTO ‘EXIT
RCL 00
X<>Y
A+B ;calc next CAT1 element’s abs addr
STO 00
XEQ ‘CA’ ;check if this is a alpha label
RCL 00
GTO 00
LBL ‘EXIT’
BEEP
END
LBL’3H>D’ ;convert 3-dig hex in alpha into dec in X
XEQ 14
16
x^2
*
XEQ 14
16
*
R^
+
XEQ 14
R^
+
RTN
LBL 14
64
ATOX
X>Y?
XEQ 13
48
-
RTN
LBL 13
7
-
RTN
END
LBL ‘MA’ – make alpha distance in bytes
192
- ;get rid of the leading ‘C’ nibble in the first byte
STO M
S> ;red rid of the r bit in the 2nd nibble which is bbbr
X<>M ;store number of bytes into M
0
bS? ;is the r-bit set?
XEQ 14
CLX
RCL M
X<>Y
7
*
+
RTN
LBL 14
CLX
896
ST+ Y
RTN
END
LBL ‘CA’ ;check if alpha label
PEEKB
241
-
X<0?
RTN
CLA
RDN
A-
LBL 01
A-
PEEKB
XTOA
RDN
DSE Y
GTO 01
AVIEW
;here you can ad any additional stuff you want to do with this label
RTN
END
.END.
Corrected typo in listing
Edited: 7 Apr 2009, 12:27 a.m. after one or more responses were posted
|