The earlier discussion on HMS and that HP doesn't display it in a easy to read format got me thinking about the alpha cababilities on the 42S (and likewise the 41C).
I wrote a quick program that displays HMS as 20 H 10 M 30.12 S and allows for addition and subtraction. Enter the time as HH.MM.SSSS, execute HMS and then enter times to add or substract. It seems to work for positive times. Negative times don't diplay real well.
The display could be changed to ' and " for minutes and seconds.
Note: |- is Alpha Append.
LBL "HMS"
XEQ 01
LBL 00
CLMENU
"ENTER"
KEY 1 GTO 01
"+"
KEY 2 GTO 02
"-"
KEY 3 GTO 03
MENU
STOP
GTO 00
LBL 01
CLA
ENTER
AIP
|- " H "
FP
100
X
AIP
|- " M "
FP
100
X
AIP
|- "."
FP
100
X
AIP
|- " S "
RDN
AVIEW
RTN
LBL 02
>HR
X<>Y
>HR
X<>Y
+
>HMS
GTO 01
LBL 03
>HR
X<>Y
>HR
X<>Y
-
>HMS
GTO 01
Hi, Bill;
your program is clever and interesting! After buying my HP42S back in the 90's, I felt the need to represent degrees, minutes, seconds as well. So I wrote the following program: (this is a refined version, after a few "shrinking")
01 LBL "HF"
02 ENTER
03 X<0?
04 |- "-"
05 ABS
06 AIP
07 |- "º"
08 XEQ 00
09 R^
10 |-"'"
11 XEQ 00
12 R^
13 |-"""
14 LBL 00
15 FP
16 .1
17 X>Y?
18 |-"0"
19 X^2
20 ÷
21 AIP
22 Rv
23 END
Rv and R^ stand for "roll down" and "roll up" respectively. The program intends to be a subroutine that simply adds the HMS representation of the number in the X-register to any existing ALPHA contents (a tag?). It deals with negative numbers as well by simply adding a "-" (minus signal) prior to add the HMS representation. I used º, ' and " instead of D, M and S because of printing issues, mostly. A CLA can be added in the begining, if needed. Also, there is no additional AVIEW or the like to show final ALPHA contents, it must be performed by the "calling" main program.
BTW, if you allow me to, I'd also add a small suggestion:
LBL 03
CHS
LBL 02
HMS+
GTO 01
Both the HP41 and the HP42S have HMS+ and HMS- as standard HH.MMSSSS additon and subtraction. Both use angle/time values in HH.MMSSSSS format and return a valid HH.MMSSSS angle/time representation. I suggest the above "trick" in order to save some bytes by removing the to- and for- convertions and the extra GTO 01.
Hope you enjoy it.
Cheers.
Luiz (Brazil)
(I edditted the post more than four times; I think now it reads better)
Edited: 4 Aug 2004, 12:45 a.m.
Hi Luiz,
I'd totally forgoten about HMS+ and HMS-.
>>BTW, if you allow me to, I'd also add a small suggestion:
LBL 03
CHS
LBL 02
HMS+
GTO 01
>>
Great suggestion! Shortens it up quite a bit. Thanks.
I need to add a check in the display routine to see if negative before displaying. I'll take a look at your routine to see how you do it. Thanks for posting it.
I really don't have a requirement to do H.MS addition, but I do have a need sometimes to do Minute-Second sums. I think I'll modify my routine to take input as M.S instead of H.MS. Would be a lot easier to enter a long list of minute-seconds.
Thanks for yuor routine & suggestions.
Bill