The number of seconds per TOD unit is too large to be represented in a signed fullword, but half the number of seconds is not too large. So they break the computation into 2 divides.
When the STCK value is hex ba9a048bca000000 (January 10 2004 13:37:05) or larger, the value after subtracting EPOCJ70 is hex 3D09000000000000, and a fixed-point divide exception occurs on the divide instruction. This is when the Unix time rolled over to hex 40000000. Since dividing by hex 7a120000 (decimal 2048000000) and then by 2 is the same as dividing by 4096 and then by 1 million, one way to avoid the divide exception is to replace the 4 instructions with these two: SRDL R14,12 DIVIDE BY 4096 D R14,=F'1000000' Bill On Tue, 18 Jul 2017 10:28:38 -0500, Kirk Wolf wrote: >Oh I get it now - Unix epoch second times are 32 bit *signed* integers. >So, they are doing SLR 14,14 prior to dividing by two to truncate at a >(signed) 31-bit integer. > >0x7FFFFFFF is Jan 19, 2038 (UTC), the latest time that can be represented >as a 32-bit signed integer seconds. > >Kirk Wolf >Dovetailed Technologies >http://dovetail.com > >On Tue, Jul 18, 2017 at 9:36 AM, Kirk Wolf wrote: > >> Dear ibm-mainers, >> >> I have a need to do something like this example: >> >> https://www.ibm.com/support/knowledgecenter/SSLTBW_1.13.0/ >> com.ibm.zos.r13.bpxb500/bpxzb5c076.htm >> >> I'm curious about one part - perhaps I am missing something in the details >> of the code. I would appreciate any insight. >> >> This bit: >> >> D R14,EPOCST divide by seconds per tod unit >> SLR R14,R14 >> LA R1,2 >> DR R14,R1 >> >> >> I'm curious about something - the EPOCST value they use is actually one half >> of >> the number of seconds per TOD unit. And so they divide by two. >> At first I thought that they were attempting some kind of rounding to the >> nearest second, but I don't see how this accomplishes that (or if rounding >> would even be desirable). >> >> >> Kirk Wolf >> Dovetailed Technologies >> ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
