In assembler on an old /370-125 running DOS/VS I can access the TOD (Time of day) with GETIME, i.e. the time since midnight. But I want to be able to print the date.

  • No grey beards where you work?
    – RonJohn
    Commented Dec 26, 2022 at 22:35
  • Didn't we already have a question about date/time on /370?
    – Raffzahn
    Commented Jan 13, 2023 at 20:16

2 Answers 2


While GETTIME returns the time in R1 as BCD, the day is noted in the Communication Area of a partition, as noted for example in the GETIME description on p.275 in section 7 of the 1973 DOS VS Supervisor and IO Macros Manual:

the job date and system date in the communication region are updated every time GETIME is issued. Those dates are therefore accurate at any given moment during processing as long as no DATE statement is encountered

A few lines down it mentions the location as 79:

enter image description here

The pages right before GETIME (273/274) introduce the communication region (*1):

Program Communication - For each partition the supervisor contains a storage area called the communication region. The supervisor uses the communication region, and your program also can use it. Your program can check the communication region of the partition in which your program runs; your program can also modify the user area of this communication region.

It also mentions how to get that address into R1 via COMRG:

The COMRG macro places the address of the communication region of the partition from which the macro is issued in register 1. Your program can read
any portion of its own partition's communication region by using register 1 as a base register.

As mentioned - and seen in the VS Handbook - the date is located at offset 79:

enter image description here

With 9 characters length it's ofc the usual YYMMDDJJJ format. Thus all to do is moving it into whatever your program's print area is:

* ... Do whatever to be done with the time
         MVC    PRINTYY,79(R1)    * 2 digit Year
         MVC    PRINTMM,81(R1)    * 2 digit Month
         MVC    PRINTDD,83(R1)    * 2 digit Day
         MVC    PRINTJJ,85(R1)    * 3 digit Day of Year
* Now print it...


* Lets print it as 'YY/MM/DD (JJJ)'
         DC     C'/'
         DC     C'/'
         DC     C' ('
         DC     C')'

Of course it gets a it more comfortable by using a structure definition for the common region - or define it if not already existing, maybe like this:

* Define Labels for the COMMON REGION
         DS     0F
         DS     XL79              * First 79 bytes are undefined
DATE     DS     0CL9              * The whole 9 Character date
DATEYY   DS     CL2               * Year
DATEMM   DS     CL2               * Month
DATEDD   DS     CL2               * Day
DATEJJ   DS     CL3               * Day of Year

(Yes, it uses all the cool parts data definition offers :))

Doing so will not only simplify life a lot, but also avoid any kind of one off due 'manual' counting:

         USING  COMR,R1 
         MVC    PRINTYY,DATEYY    * Year
         MVC    PRINTMM,DATEMM    * Month
         MVC    PRINTDD,DATEDD    * Day
         MVC    PRINTJJ,DATEJJ    * Day of Year
         DROP   R1

Enjoy Assembly :))

*1 - For micro-users, that's something a bit like the PSP in MS-DOS. Except there are others as well and usage is ... lets say 'grown'

  • great and simple solution! This helped me with my demo program. I guess IBM did some information hiding on how to retrieve the date. I had to modify the MOV to MVC and add the offsets. Thanks again.
    – monok
    Commented Jan 15, 2023 at 11:13
  • @monok It has to be. DOS, like /370, wasn't made at some university, but by men that worked on punch cards. thinking ahead to save work was essential back then :)) I'd would assume that the usage of a/the Communication Region was so inherent to DOS, that noone ever assuemed it has to be explained at every instance. Sorry for the MOV - was doing too much 8086 lately :)) But what offsets needed to be corrected?
    – Raffzahn
    Commented Jan 15, 2023 at 14:38
  • You said 79 repeatedly line after line, which unless MVC somehow increments R1 each time, sounds like repeatedly loading from the same place. Commented Jan 15, 2023 at 18:29
  • @MartinKochanski Oh, drats, yes. Did look at it several times but didn't notice. You're absolutely right. I looked several times at the labels to not have mixed them up, but not at the source address.. Would have only detected that after running the program and wondering about the strange result of '23/23/23 (230)' :) In the old days I would have had a DSECT for the ComRG and use names instead. Thought not needing that for this. Stupid me.
    – Raffzahn
    Commented Jan 16, 2023 at 0:30

Looks like I need to learn how to read :)) Please see here for a fitting answer

In assembler on an old /370-125 running DOS/VS I can access the TOD (Time of day) with GETIME, i.e. the time since midnight.

Jup. IIRC it's the same for all DOS versions and many later OS, so is there any specific reason to explicit ask forDOS/VS?

But I want to be able to print the date.

With STANDARD as format specifier time gets delivered as BCD in Register 1:

enter image description here

Handling this is as basic as /360 assembler can get.

... or is this question rather about basic /360 BCD handling?

In that case, store it and unpack it, or if you want luxury, format it. In either case it's a macro plus 3 assembler instructions:


* Get the time and store it for further in memory processing
         ST     R1,TEMP

* Simple unpacking:
* Turn BCD into a 6 character string at TIME1 using a straight unpack
         UNPK   TIME1,TEMP
         OI     TIME1+L'TIME1-1,x'F0'  * Remove sign on last character

* Luxurious formatting with colons:
* Turn BCD into an ISO date at TIME2 using ED
         MVC    TIMEMSK,=X'402120207A20207A2020' * Place edit mask
                * FFmmmmmmLLmmmmLLmmmm
                * FF - Fill char (unused here) 40 = Space
                * mm - Mask command
                *   20 - Print digit from BCD unless leading zero
                *   21 - start printing with next char regardless of leading or not
                * LL - Literal characters 7A = Colon
         ED     TIME2MSK,TEMP


TEMP     DS     0F              * Word to store the GETIME value delivered
TIME1    DS     CL6             * Time as basic text 'HHMMSS'
TIME2MSK DS     XL10            * Mask for ED/EDMK
         ORG    TIMEMSK+2       * Formatted time starts at Mask+2
TIME22   DS     CL8             * Time formatted as ISO 8601 'HH:MM:SS'

All left is moving the result to your print buffer - if not already prepared in place.

Usually this is stuff for the first few lessons in /360 assembly, so I'm a bit unsure if this is really what the question asks for.

  • 1
    Nice answer to wrong question. What about date?
    – ghellquist
    Commented Jan 14, 2023 at 10:10
  • OP asked about the date, not time.
    – RonJohn
    Commented Jan 14, 2023 at 11:08
  • Aiaiai ...my bad :)))
    – Raffzahn
    Commented Jan 14, 2023 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .