You don't need to clear R6 before doing DSGR. That's the whole point of the 
SINGLE

Pieter

-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]] On 
Behalf Of Ward, Mike S
Sent: 20 April 2017 21:21
To: [email protected]
Subject: Re: CONVTOD Help

Thanks for the help everyone. I used a combination of Tony's, Peter's, and 
Aldo's routines to do my routine. It also led me to do further study of these 
instructions in the poop.
I believe this is working.

         STCKE THATCLOK
         LA    R4,THATCLOK  Address save area
         LG    GR7,0(R4)    Load address into 64 bit register
         LA    R1,E1970     Address 1/1/1970 00:00:00 GMT
*                             in STCKE format
         LG    GR8,0(R1)    Load address INTO 64 bit register
         SGR   GR7,GR8      Subtract 1970 from current STCKE
         LA    R1,MILL16    Address 16 million
         LG    GR8,0(R1)    Load it into the register
         XR    R6,R6        Clear R6
         DSGR  GR6,GR8      Divide to get seconds
         LA    R4,THISCLOK  Address save area
         STG   GR7,0(R4)    Save the seconds
         XR    R15,R15      Clear R15
E1970     DC    X'007D91048BCA0000'
MILL16   DC    FL8'16000000'

R0       EQU   0,,,,GR32
R1       EQU   1,,,,GR32
R2       EQU   2,,,,GR32
R3       EQU   3,,,,GR32
R4       EQU   4,,,,GR32
R5       EQU   5,,,,GR32
R6       EQU   6,,,,GR32
R7       EQU   7,,,,GR32
R8       EQU   8,,,,GR32
R9       EQU   9,,,,GR32
R10      EQU   10,,,,GR32
R11      EQU   11,,,,GR32
R12      EQU   12,,,,GR32
R13      EQU   13,,,,GR32
R14      EQU   14,,,,GR32
R15      EQU   15,,,,GR32
RA       EQU   10,,,,GR32
RB       EQU   11,,,,GR32
RC       EQU   12,,,,GR32
RD       EQU   13,,,,GR32
RE       EQU   14,,,,GR32
RF       EQU   15,,,,GR32
GR0      EQU   0,,,,GR64
GR1      EQU   1,,,,GR64
GR2      EQU   2,,,,GR64
GR3      EQU   3,,,,GR64
GR4      EQU   4,,,,GR64
GR5      EQU   5,,,,GR64
GR6      EQU   6,,,,GR64
GR7      EQU   7,,,,GR64
GR8      EQU   8,,,,GR64
GR9      EQU   9,,,,GR64
GR10     EQU   10,,,,GR64
GR11     EQU   11,,,,GR64
GR12     EQU   12,,,,GR64
GR13     EQU   13,,,,GR64
GR14     EQU   14,,,,GR64
GR15     EQU   15,,,,GR64
GRA      EQU   10,,,,GR64
GRB      EQU   11,,,,GR64
GRC      EQU   12,,,,GR64
GRD      EQU   13,,,,GR64
GRE      EQU   14,,,,GR64
GRF      EQU   15,,,,GR64
-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]] On 
Behalf Of Tony Harminc
Sent: Monday, April 10, 2017 11:09 AM
To: [email protected]
Subject: Re: CONVTOD Help

On 10 April 2017 at 11:38, Ward, Mike S <[email protected]> wrote:
> Hello, list friends. I was wondering if one of you could give me a
> little
help with a time problem that I have not been able to solve. I have the need to 
provide the number of seconds since 1970 for a project that I'm working on. I 
have been using a combination of the STCK and the CONVTOD to try and get the 
results, but I'm just not that good at math or time functions. If someone could 
steer me in the right direction I would really appreciate it.

Hi Mike,

If you want to have truly accurate results, including all the leap seconds 
baggage (Hi Gil), you will need to dig a bit deeper. If you don't mind being 
potentially off by a second or three, here is some code I wrote about
20 years ago that works, and shows what you need to do. The result is left in 
R14.

         STCK  DWORD               S/370 clock in IBM TOD units (bit 51 = 1
uS)
         LM    R14,R15,DWORD       TOD CLOCK UNITS in R14,R15
         SRDL  R14,12              MICROSECONDS SINCE JAN 1, 1900
         SL    R15,=FL8'2208902400000000'+4 - RIGHT HALF of conversion
factor
         BC    11,*+6              BRANCH ON NO BORROW
         BCTR  R14,R0              -1 FOR BORROW
         SL    R14,=FL8'2208902400000000' - LEFT HALF of conversion factor
         D     R14,=F'1000000'     SECONDS SINCE JAN 1, 1970
         ...
DWORD    DS    D

This was written before zArch and its 64-bit registers, so it does a 64-bit 
calculation using 32-bit registers. Still works fine, of course, but could be 
shortened. That magic number 2208902400000000 is the conversion factor, in 
microsoeconds, between 1900 and 1970.

Of course the value in DWORD doesn't have to come directly from STCK. It can as 
well be a stored value, but take care that it's not before 1970...

Tony H.

==========================
This email, and any files transmitted with it, is confidential and intended 
solely for the use of the individual or entity to which it is addressed. If you 
have received this email in error, please notify the system manager. This 
message contains confidential information and is intended only for the 
individual named. If you are not the named addressee, you should not 
disseminate, distribute or copy this e-mail. Please notify the sender 
immediately by e-mail if you have received this message by mistake and delete 
this e-mail from your system. If you are not the intended recipient, you are 
notified that disclosing, copying, distributing or taking any action in 
reliance on the contents of this information is strictly prohibited.


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Reply via email to