Article View: comp.lang.asm370
Article #660Re: Time conversion
From: Phil Howard KA9WGN
Date: Wed, 10 Apr 1991 23:01
Date: Wed, 10 Apr 1991 23:01
388 lines
31537 bytes
31537 bytes
ZPRM@AACC.BITNET (ZPRM000) writes:
>Does anyone know how to convert the SNNTTIME field in dsect
>DFHSNNT to a HHMMSS format that is easily usable for display
>purposes? I think its in STCK format?
I have some code I do this with. I am posting relevant samples here
which are good enough to copy and adapt to stuff. But if you want to
assemble what I post, you need more of my macros. You can get them by
requesting them from me by E-mail to phil-howard@uiuc.edu (give a BITNET
address if you have one) or by Anonymous FTP to host vmd.cso.uiuc.edu
(128.174.5.98) and cd to "phil.194".
The first program is a REXX function that gives the clock data in a format
a REXX program can play with easily. The second program is the macro that
I use to generate code to convert the clock.
:READ RXDATIM ASSEMBLE A
RXDATIM TITLE 'REXX function to convert TOD value to info' 00001000
*********************************************************************** 00002000
* Copyright: (C) 1990, Philip David Howard - All rights reserved. * 00003000
* Permission is granted to the public to distribute this * 00004000
* program unaltered provided that no profit is derived * 00005000
* from the distribution and that this permission is not * 00006000
* denied to others receiving this program. * 00007000
* * 00008000
* Program: RXDATIM ASSEMBLE * 00009000
* * 00010000
* Function: datim * 00011000
* * 00012000
* Purpose: To convert a TOD value in decimal such as that from * 00013000
* the tod() function into individual date and time * 00014000
* information. * 00015000
* * 00016000
* Usage: info = datim( todvalue ) * 00017000
* * 00018000
* todvalue - The TOD clock value in decimal. Value will * 00019000
* be from 0 to 2**63-1. * 00020000
* * 00021000
* info - Date and time information separated by * 00022000
* blanks as follows: * 00023000
* * 00024000
* year - 1900 to 2042 * 00025000
* month - 1 to 12 * 00026000
* date - 1 to 31 * 00027000
* day - 1 to 7 * 00028000
* hour - 0 to 23 * 00029000
* minute - 0 to 59 * 00030000
* second - 0 to 59 * 00031000
* microseconds - 0 to 999999 * 00032000
* * 00033000
* Program: No time zone adjustments are made. * 00034000
* Those must be made by the calling program. * 00035000
* * 00036000
* Author: Philip D. Howard * 00037000
* Post: Computing Services Office * 00038000
* Digital Computer Lab * 00039000
* University of Illinois at Urbana-Champaign * 00040000
* 1304 West Springfield Avenue * 00041000
* Urbana, IL USA-61801 * 00042000
* Phone: 217-244-6246 * 00043000
* Network: <PHIL@UIUCVMD.BITNET> * 00044000
*********************************************************************** 00045000
EJECT 00046000
*********************************************************************** 00047000
* General declarations. * 00048000
*********************************************************************** 00049000
INTREL DATIM,DECINT,INUDEC 00050000
RXDATIM NUCEXT ACODE=GODATIM,ZCODE=ENDATIM,(RXDATIM,GODATIM) 00051000
USING GODATIM,R12 00052000
SPACE 00053000
*********************************************************************** 00054000
* Begin main entry point. * 00055000
*********************************************************************** 00056000
GODATIM STM R14,R12,SAVER14(R13) preserve registers 00057000
SPACE 00058000
CLM R1,B'1000',F5+3 is this a REXX call? 00059000
BC NOT-EQUAL,EXIT4 no --> too bad 00060000
LTR R3,R0 is it a function (not call)? 00061000
BC NEG,EXIT4 no --> signal error 00062000
SPACE 00063000
ICM R11,B'1111',20(R3) get evalblok return word address 00064000
BC ZERO,EXIT4 zero --> signal error 00065000
SPACE 00066000
*********************************************************************** 00067000
* Allocate savearea and evalblok. * 00068000
*********************************************************************** 00069000
LA R0,9 size to allocate 00070000
DMSFREE DWORDS=(0) get a work area 00071000
ST R13,SAVEPREV(R1) link... 00072000
ST R1,SAVENEXT(R13) ...saveareas 00073000
LR R13,R1 use new save area 00074000
SPACE 00075000
LA R9,7 size of EVALBLOK / workarea 00076000
LR R0,R9 request size 00077000
DMSFREE DWORDS=(0) get an EVALBLOK / workarea 00078000
ST R1,0(,R11) pass EVALBLOK address to REXX now 00079000
LR R11,R1 use in this register 00080000
XC 0(8*7,R11),0(R11) clean it up 00081000
ST R9,4(,R11) put allocated size in header 00082000
SPACE 00083000
*********************************************************************** 00084000
* Convert number to internal binary form then to individual numbers. * 00085000
*********************************************************************** 00086000
$IF NOT-ZERO if 00087000
ICM R10,B'1111',16(R3) arg list is present 00088000
$AND NOT-EQUAL and 00089000
CLI 0(R10),X'FF' arg list has at least one arg 00090000
$AND NOT-ZERO and 00091000
ICM R2,B'1111',0(R10) address is not null 00092000
$AND NOT-ZERO and 00093000
ICM R3,B'1111',4(R10) length is not null 00094000
$AND CC0+CC1 and 00095000
DECINT , given number is valid 00096000
$THEN , then 00097000
$ELSE , else 00098000
STCK 16(R13) use the current TOD clock 00099000
LM R0,R1,16(R13) as if it were specified 00100000
$END , 00101000
SPACE 00102000
DATIM , >>> convert TOD to various info 00103000
SPACE 00104000
LA R3,1(,R3) add one to month 00105000
LA R4,1(,R4) add one to date 00106000
LA R5,1(,R5) add one to day 00107000
STM R2,R9,24(R11) array these numbers 00108000
SPACE 00109000
*********************************************************************** 00110000
* Convert numbers to decimal and build resultant value. * 00111000
* The binary values will be wiped over by the character values, but * 00112000
* not until they are no longer needed. The EVALBLOK overlay is: * 00113000
* 1 1 2 2 2 3 3 4 4 4 5 * 00114000
* 0 4 8 2 6 0 4 8 2 6 0 4 8 2 * 00115000
* ....SSSSLLLL............YYYYMMMMDDDDWWWWHHHHMMMMSSSSUUUU * 00116000
* ................1988_12_31_7_23_59_59_999999_........... * 00117000
*********************************************************************** 00118000
LA R2,16(,R11) where decimal numbers first go 00119000
SLR R6,R6 start index at 0 00120000
LA R8,8 8 numbers 00121000
SPACE 00122000
LOOP SLR R0,R0 clear upper part of 64 bits 00123000
L R1,24(R6,R11) get number 00124000
L R3,NUMTABLE(R6) get maximum size 00125000
LA R4,1 get minimum size 00126000
INUDEC , >>> convert to decimal 00127000
ALR R2,R4 adjust address 00128000
MVI 0(R2),X'40' add on a blank 00129000
LA R2,1(,R2) adjust again 00130000
LA R6,4(,R6) increment index 00131000
BCT R8,LOOP count data items 00132000
SPACE 00133000
LA R3,17(,R11) start of string offset +1 00134000
SLR R2,R3 length of string less 1 (chop blank) 00135000
ST R2,8(,R11) put actual length in header 00136000
SPACE 00137000
*********************************************************************** 00138000
* Return savearea and exit to caller. * 00139000
*********************************************************************** 00140000
RETURN LR R1,R13 remember where the savearea is 00141000
L R13,SAVEPREV(,R13) pop the savearea 00142000
LA R0,9 size of a savearea 00143000
DMSFRET DWORDS=(0),LOC=(1) return the savearea 00144000
SLR R15,R15 zero return code 00145000
SPACE 00146000
EXIT L R14,SAVER14(,R13) restore R14 00147000
LM R0,R12,SAVER0(R13) restore R0..R12 00148000
BR R14 >>> return 00149000
SPACE 00150000
EXIT4 LA R15,4 set return code to 4 00151000
B EXIT --> go do regular exit 00152000
SPACE 00153000
EJECT 00154000
*********************************************************************** 00155000
* Subroutines. * 00156000
*********************************************************************** 00157000
INTORG 00158000
EJECT 00159000
*********************************************************************** 00160000
* Constants. * 00161000
*********************************************************************** 00162000
F5 DC F'5' constant 5 00163000
SPACE 00164000
LTORG 00165000
SPACE 00166000
NUMTABLE DS 0D number size table 00167000
YEAR DC F'4' 1988 00168000
MONTH DC F'2' 12 00169000
DATE DC F'2' 31 00170000
DAY DC F'1' 7 00171000
HOUR DC F'2' 23 00172000
MIN DC F'2' 59 00173000
SEC DC F'2' 59 00174000
USEC DC F'6' 999999 00175000
SPACE 00176000
ENDATIM EQU * end of loaded code 00177000
EJECT 00178000
WORKAREA DSECT 00179000
SAVEAREA DS 9D save area 00180000
WORKEND DS 0D end of work area 00181000
WORKLEN EQU WORKEND-WORKAREA length of workarea 00182000
WORKSIZ EQU WORKLEN/8 size of workarea 00183000
EJECT 00184000
$EQU 00185000
NUCON 00186000
END RXDATIM 00187000
:READ DATIM MACRO A
MACRO 00001000
&LABEL DATIM &PARM,&TYPE=,&NAME= 00002000
.********************************************************************** 0000300
.* Copyright: (C) 1989, Philip David Howard - All rights reserved. * 0000400
.* Permission is granted to the public to distribute this * 0000500
.* program unaltered provided that no profit is derived * 0000600
.* from the distribution and that this permission is not * 0000700
.* denied to others receiving this program. * 0000800
.* * 0000900
.* Program: DATIM MACRO * 0001000
.* * 0001100
.* Purpose: To break down a TOD clock value (64 bit unsigned * 0001200
.* integer) into various date and time components. * 0001300
.* * 0001400
.* Author: Philip David Howard, Research Programmer * 0001500
.* Internet: <phil@vmd.cso.uiuc.edu>, Bitnet: <phil@uiucvmd> * 0001600
.* Voicenet: (USA) 217-244-6246 * 0001700
.* Papernet: Computing Services Office, Room 131-SW * 0001800
.* Digital Computer Lab, MC-256 * 0001900
.* University of Illinois at Urbana-Champaign * 0002000
.* 1304 West Springfield Avenue * 0002100
.* Urbana, IL USA-61801 * 0002200
.********************************************************************** 0002300
COPY $MACVAR 00024000
LCLC &NDX,&LAB 00025000
&MACLAB SETC 'DATIM' 00026000
&MACRET SETA 0 00027000
&NDX SETC '&SYSNDX' 00028000
&LAB SETC '' 00029000
COPY $MACFND 00030000
COPY $MACODE 00031000
COPY $MACORG 00032000
*********************************************************************** 00033000
* Copyright: (C) 1989, Philip David Howard - All rights reserved. * 00034000
* Permission is granted to the public to distribute this * 00035000
* program unaltered provided that no profit is derived * 00036000
* from the distribution and that this permission is not * 00037000
* denied to others receiving this program. * 00038000
* * 00039000
* Program: DATIM subroutine * 00040000
* * 00041000
* Purpose: To break down a TOD clock value (64 bit unsigned * 00042000
* integer) into various date and time components. * 00043000
* * 00044000
* Entry: R0-1: TOD clock value (64 bit unsigned integer) * 00045000
* R13: Standard savearea * 00046000
* * 00047000
* Exit: R0-1: TOD clock unchanged (64 bit unsigned integer) * 00048000
* R2: Year (1900-2042) (32 bit unsigned integer) * 00049000
* R3: Month (0-11) (32 bit unsigned integer) * 00050000
* R4: Date (0-30) (32 bit unsigned integer) * 00051000
* R5: Day (0-6) (MON=0) (32 bit unsigned integer) * 00052000
* R6: Hour (0-23) (32 bit unsigned integer) * 00053000
* R7: Minute (0-59) (32 bit unsigned integer) * 00054000
* R8: Second (0-59) (32 bit unsigned integer) * 00055000
* R9: Microseconds (0-999999) (32 bit unsigned integer) * 00056000
* * 00057000
* Author: Philip David Howard, Research Programmer * 00058000
* Internet: <phil@vmd.cso.uiuc.edu>, Bitnet: <phil@uiucvmd> * 00059000
* Voicenet: (USA) 217-244-6246 * 00060000
* Papernet: Computing Services Office, Room 131-SW * 00061000
* Digital Computer Lab, MC-256 * 00062000
* University of Illinois at Urbana-Champaign * 00063000
* 1304 West Springfield Avenue * 00064000
* Urbana, IL USA-61801 * 00065000
*********************************************************************** 00066000
EJECT 00067000
&LAB STM R0,R1,SAVER0(R13) preserve TOD registers 00068000
SRDL R0,12 divide by 4096 for total usecs 00069000
D R0,=F'60000000' microseconds per minute 00070000
SPACE 00071000
LR R5,R0 microseconds since minute 00072000
SLR R4,R4 clear upper half of 64 bit int 00073000
D R4,=F'1000000' microseconds per second 00074000
LR R9,R4 MICROSECOND 00075000
LR R8,R5 SECOND 00076000
SPACE 00077000
SLR R0,R0 clear upper half of 64 bit int 00078000
D R0,=F'60' minutes per hour 00079000
LR R7,R0 MINUTE 00080000
SPACE 00081000
SLR R0,R0 clear upper half of 64 bit int 00082000
D R0,=F'24' hours per day 00083000
LR R6,R0 HOUR 00084000
SPACE 00085000
LR R3,R1 temp copy of total days 00086000
SLR R2,R2 clear upper half of 64 bit int 00087000
D R2,=F'7' days per week 00088000
LR R5,R2 DAY 00089000
SPACE 00090000
$IF HIGH+EQUAL if 00091000
CL R1,=F'59' this is 1 Mar 1900 or later 00092000
$THEN , then 00093000
AL R1,=F'1' adjust dates for no 29 Feb 1900 00094000
$END 00095000
SPACE 00096000
SLR R0,R0 clear upper half of 64 bit int 00097000
D R0,=F'1461' days per quadyear 00098000
ALR R1,R1 multiple quadyear by... 00099000
ALR R1,R1 ...4 to get year offset 00100000
AL R1,=F'1900' plus epoch for real year of quad 00101000
SPACE 00102000
LA R3,12*4*2 offset to last month code 00103000
$WHILE LOW while 00104000
CH R0,MTAB&NDX.(R3) this month is a future month 00105000
$DO , do 00106000
SL R3,=F'2' look at previous month 00107000
$END , 00108000
SH R0,MTAB&NDX.(R3) reduce to just date in month 00109000
LR R4,R0 DATE 00110000
SRL R3,1 divide by 2 gives month in quadyear 00111000
SPACE 00112000
SLR R2,R2 00113000
D R2,=F'12' months per year 00114000
ALR R1,R3 add year in quadyear for final year 00115000
LR R3,R2 MONTH 00116000
LR R2,R1 YEAR 00117000
SPACE 00118000
LM R0,R1,SAVER0(R13) restore TOD registers 00119000
B RTRN&NDX all done --> 00120000
EJECT 00121000
MTAB&NDX DC H'0' Jan 1980 00122000
DC H'31' Feb 1980 leap month 00123000
DC H'60' Mar 1980 00124000
DC H'91' Apr 1980 00125000
DC H'121' May 1980 00126000
DC H'152' Jun 1980 00127000
DC H'182' Jul 1980 00128000
DC H'213' Aug 1980 00129000
DC H'244' Sep 1980 00130000
DC H'274' Oct 1980 00131000
DC H'305' Nov 1980 00132000
DC H'335' Dec 1980 00133000
SPACE 00134000
DC H'366' Jan 1981 00135000
DC H'397' Feb 1981 00136000
DC H'425' Mar 1981 00137000
DC H'456' Apr 1981 00138000
DC H'486' May 1981 00139000
DC H'517' Jun 1981 00140000
DC H'547' Jul 1981 00141000
DC H'578' Aug 1981 00142000
DC H'609' Sep 1981 00143000
DC H'639' Oct 1981 00144000
DC H'670' Nov 1981 00145000
DC H'700' Dec 1981 00146000
SPACE 00147000
DC H'731' Jan 1982 00148000
DC H'762' Feb 1982 00149000
DC H'790' Mar 1982 00150000
DC H'821' Apr 1982 00151000
DC H'851' May 1982 00152000
DC H'882' Jun 1982 00153000
DC H'912' Jul 1982 00154000
DC H'943' Aug 1982 00155000
DC H'974' Sep 1982 00156000
DC H'1004' Oct 1982 00157000
DC H'1035' Nov 1982 00158000
DC H'1065' Dec 1982 00159000
SPACE 00160000
DC H'1096' Jan 1983 00161000
DC H'1127' Feb 1983 00162000
DC H'1155' Mar 1983 00163000
DC H'1186' Apr 1983 00164000
DC H'1216' May 1983 00165000
DC H'1247' Jun 1983 00166000
DC H'1277' Jul 1983 00167000
DC H'1308' Aug 1983 00168000
DC H'1339' Sep 1983 00169000
DC H'1369' Oct 1983 00170000
DC H'1400' Nov 1983 00171000
DC H'1430' Dec 1983 00172000
EJECT 00173000
RTRN&NDX DS 0H 00174000
COPY $MACRET 00175000
COPY $MACALL 00176000
MEND 00177000
--
/***************************************************************************\
/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks /
\***************************************************************************/
Technical Details
Message-ID:
<9104110004.AA19768@ucbvax.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!uwm.edu!bionet!agate!ucbvax!UX1.CSO.UIUC.EDU!philShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!uwm.edu!bionet!agate!ucbvax!UX1.CSO.UIUC.EDU!phil
From: phil@UX1.CSO.UIUC.EDU (Phil Howard KA9WGN)
Newsgroups: comp.lang.asm370
Subject: Re: Time conversion
Message-ID: <9104110004.AA19768@ucbvax.Berkeley.EDU>
Date: 10 Apr 91 23:01:38 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: IBM 370 Assembly Programming Discussion List
<ASM370@OHSTVMA.BITNET>
Distribution: inet
Organization: The Internet
Lines: 388