Re: Displaying HMS on 42S Message #2 Posted by Vieira, Luiz C. (Brazil) on 4 Aug 2004, 12:30 a.m., in response to message #1 by Bill (Smithville, NJ)
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.
|