• Please review our updated Terms and Rules here

RTC Support?

ab0tj

Experienced Member
Joined
Mar 4, 2015
Messages
116
Location
Colorado, USA
Hi all,

I'm finally to the point of adding RTC support to the "CheapBus" system I've been working on (see here if interested). Looking at the way CP/M expects the date to be formatted, I wonder if it is going to handle the year correctly? Has anyone implemented this and what do I need to look out for when it comes to Y2K compatibility?

Thanks!
Alex
 
I assume you're talking about CP/M 3 (Plus). The time is expressed in BCD values for hour, minute, and second. The date is 16-bit days since epoch (Jan 1, 1980). AT 65525 max, that allows dates into the year 2159. The problem has been that the original DRI programs computed a two-digit year naively, and so you get odd characters for years beyond 1999. There are Y2K fixes out there for the CP/M 3 utilities, that compute the two digit year correctly. Note, this only affects the display of dates, not the dates values themselves.

You then need to compute the CP/M date value from the MDY values in the RTC.
 
Thanks. I take it I'll need to write my own program to set the date, since the "date" command shipped with CP/M only inputs a two digit year?
 
If you can get the Y2K fixed version of DATE.COM, it should work for 4-digit years. Although, I did not try that as I am using a simulator that takes the Unix/Linux date and converts it to CP/M.

Here's an RTC driver I used for CP/M 3, that computes the CP/M date from RTC data. Assuming your RTC is similar, it might help:

View attachment rtc72421.asm.txt

Also, here's a JAVA code snipped that computes the CP/M time/date from a Unix/Linux date:

View attachment unix2cpmdate.txt
 
I should have mentioned, that RTC ASM code is in "extended Intel mnemonics for Z80" (a.k.a. DRI's Z80.LIB macros). If any are not obvious, or you are not using a Z80, just ask about them.
 
Hello,

I downloaded a set of utilities that have been converted to Y2K, and DIR and DATE both seemed to work OK. Was there something with certain options of SET?? as well, I cannot remember.

The problem was that you need a converted version of INITDIR as well. I think I remember finding the (supposed) source for a Y2K version of INITDIR, but I don't think there was a ready built version. Maybe I need to check this out further. Buried somewhere I have a disk marked 'Y2K versions' or something like.

Geoff
 
The utils that I have, which were Y2K fixed, are SETDEF.COM, DATE.COM, SHOW.COM, and DIR.COM. This suite allows for "US" or "UK" date formats, too. Note, most of these changes affect only the displaying of dates, not internal handling.

Looking at this modified DATE.PLM source file, when setting the date it scans a 2-digit year and assumes anything less that "78" is 20xx. This is not ideal, if you are still running CP/M 3 as of 2078, but oh well. (I misspoke about the epoch, it is 1978, not 1980. I must have been thinking MS-DOS *shudder*)
 
Back
Top