EDITTIME CSECT Define program CSECT
USING *,12 Establish program addressability
SAVE (14,12),,'EDITTIME &SYSDATE &SYSTIME' Save registers
LR 12,15 Copy entry point address to reg 12
LA 2,10 Set reg 2 = 10
LOOP TIME DEC Get date and time
STM 0,1,SAVETIME Save time of day
UNPK SAVEWD1(9),SAVETIME(5) Convert
UNPK SAVEWD2(9),SAVETIME+4(5) SAVETIME
TR SAVEWD1,HEXTAB to
TR SAVEWD2,HEXTAB hexadecimal
MVI SAVEWD1+L'SAVEWD1,C' ' digits
LA 0,L'LISTSAVE Write translated SAVETIME
LA 1,LISTSAVE to the TSO terminal
TPUT (1),(0),R
AP SAVETIME(8),=P'1900000' Convert 0cyy in p'0cyyddd' ->
to a proper year
MVC TIMEOFDAY,EDITMASK Init TIMEOFDAY data area
ED TIMEOFDAY,SAVETIME Translate packed decimal digits to ->
numeric characters
LA 0,L'TIMEOFDAY-1 Load length of data area
LA 1,TIMEOFDAY+1 Load address of data area
TPUT (1),(0),R Write data area to the TSO terminal
MVI ECB,0 Reset the completion ECB
STIMER REAL,ITIMEUP,BINTVL==F'100' Start the timer interval
WAIT 1,ECB=ECB Wait for the time interval to ->
complete
BCT 2,LOOP Do it again
RETURN (14,12),T,RC=0 Restore registers
DROP ,
* STIMER timer completion exit
CNOP 0,8
USING *,2 Establish ITIMEUP addressability
ITIMEUP LR 2,15 Copy entry point address to reg 2
LR 3,14 Copy return address to reg 3
POST ECB,0 Post the ECB
BR 3 Return to STIMER
SAVETIME DC 2F'0'
ECB DC F'0'
EDITMASK DC 0C' HH:MM:DD:HH YYYY/DDD'
DC C' ',X'2120',C':',X'2020',C':',X'2020',C'.',X'2020'
DC C' ',X'20202020',C'/',X'202020'
LISTSAVE DC 0C'HHHHHHHH HHHHHHHH'
SAVEWD1 DC C'HHHHHHHH',C' '
SAVEWD2 DC C'HHHHHHHH',C' '
TIMEOFDAY DC CL(L'EDITMASK)' ',0D'0'
LTORG , Insert the literal pool here
ORG EDITTIME+C'0'
ORG ,
DC 0D'0'
HEXTAB EQU *-C'0'
DC C'0123456789ABCDEF'
END EDITTIME
USING *,12 Establish program addressability
SAVE (14,12),,'EDITTIME &SYSDATE &SYSTIME' Save registers
LR 12,15 Copy entry point address to reg 12
LA 2,10 Set reg 2 = 10
LOOP TIME DEC Get date and time
STM 0,1,SAVETIME Save time of day
UNPK SAVEWD1(9),SAVETIME(5) Convert
UNPK SAVEWD2(9),SAVETIME+4(5) SAVETIME
TR SAVEWD1,HEXTAB to
TR SAVEWD2,HEXTAB hexadecimal
MVI SAVEWD1+L'SAVEWD1,C' ' digits
LA 0,L'LISTSAVE Write translated SAVETIME
LA 1,LISTSAVE to the TSO terminal
TPUT (1),(0),R
AP SAVETIME(8),=P'1900000' Convert 0cyy in p'0cyyddd' ->
to a proper year
MVC TIMEOFDAY,EDITMASK Init TIMEOFDAY data area
ED TIMEOFDAY,SAVETIME Translate packed decimal digits to ->
numeric characters
LA 0,L'TIMEOFDAY-1 Load length of data area
LA 1,TIMEOFDAY+1 Load address of data area
TPUT (1),(0),R Write data area to the TSO terminal
MVI ECB,0 Reset the completion ECB
STIMER REAL,ITIMEUP,BINTVL==F'100' Start the timer interval
WAIT 1,ECB=ECB Wait for the time interval to ->
complete
BCT 2,LOOP Do it again
RETURN (14,12),T,RC=0 Restore registers
DROP ,
* STIMER timer completion exit
CNOP 0,8
USING *,2 Establish ITIMEUP addressability
ITIMEUP LR 2,15 Copy entry point address to reg 2
LR 3,14 Copy return address to reg 3
POST ECB,0 Post the ECB
BR 3 Return to STIMER
SAVETIME DC 2F'0'
ECB DC F'0'
EDITMASK DC 0C' HH:MM:DD:HH YYYY/DDD'
DC C' ',X'2120',C':',X'2020',C':',X'2020',C'.',X'2020'
DC C' ',X'20202020',C'/',X'202020'
LISTSAVE DC 0C'HHHHHHHH HHHHHHHH'
SAVEWD1 DC C'HHHHHHHH',C' '
SAVEWD2 DC C'HHHHHHHH',C' '
TIMEOFDAY DC CL(L'EDITMASK)' ',0D'0'
LTORG , Insert the literal pool here
ORG EDITTIME+C'0'
ORG ,
DC 0D'0'
HEXTAB EQU *-C'0'
DC C'0123456789ABCDEF'
END EDITTIME
- Why does AP SAVETIME(8),=P'1900000' work?
- What is the purpose of the following code?ORG EDITTIME+C'0'
ORG , - Why do this complicated business with STIMER and WAIT when STIMER WAIT is much simpler?
- If you understand the answer to the first question, this one is real easy: why does the edit mask work?
- The "main" program does not obtain a new save area, yet the contents of the original save area are not damaged. Why does the system work this way?
- This one is the hardest. This code looks like a subroutine. It is clearly destroying registers 2 and 3 before it returns, but it runs correctly. Why?USING *,2
ITIMEUP LR 2,15
LR 3,14
POST ECB,0
BR 3