ca.portal.admin

Re: Arithmetic on FORMAT=(DTS) date from #GETIME

Discussion created by ca.portal.admin on Jul 8, 2010
Gary,

Do you have the luxury of being allowed to use assembler? If so, consider
writing a routine that simply does a Store Clock instruction into a 64 bit
area supplied by the caller:

GETSTCK CSECT
L 15,0(,1) Get Parm 1
STCK 0(15) Store System Time
NI 0(15),X'7F' Avoid Sign Issues
BR 14 Return To Caller

01 CLOCK-TIMES.
05 CLOCK1.
10 CLOCK1N PIC S9(18) COMP.
05 CLOCK2.
10 CLOCK2N PIC S9(18) COMP.
05 CLOCKDELTA PIC S9(18) COMP.
05 ELAPSEDMICS PIC S9(08) COMP.

CALL ""GETSTCK"" USING CLOCK1.
...Do What Ever...
CALL ""GETSTCK"" USING CLOCK2.
CLOCKDELTA = CLOCK2 - CLOCK1.
ELAPSEDMICS = CLOCKDELTA / 4096.

The routine stores the system's clock comparator value in the 64 bit field
passed by the caller and then eliminates the high order bit. The reason the
high order bit is eliminated is to avoid sign issues in the math. The
removal of the bit makes the result of the STCK unusable as a time of day
value, but the significance remains so that it can be used to determine the
amount of elapsed time, in machine timer units, that has transpired between
2 STCK values. Since the duration of the clock comparator is 140+ years, I
suspect that removing the high order bit will not be an issue.

Once you have 2 STCK values, you can take the difference between the 2 and
you will have the elapsed time.

Converting the time is now a matter of accuracy. If microseconds is
sufficient, then divide the difference by 4096 and you will have the number
of microseconds that has elapsed between the 2 STCK values.

Refer to the Principle of Operations for more information on the STCK
instruction.

Chuck

Outcomes