6300 Clock

broehl at watdcsu.UUCP broehl at watdcsu.UUCP
Wed Jan 21 08:20:09 AEST 1987


<line eater food>

I may have a solution for you.

We have some 6300's around here, and they came with DOS 2.11; since we
needed the 3.1 features, we switched over.  Much to our chagrin, we also
found that the clock was no longer being read automagically at boot time.

After disassembling choice parts of the ATT MS-DOS (notably the clock
driver) we figured out how to read the battery-powered clock.  We then
proceeded to write the two programs below.  One, RDATTCL, reads the clock
and sets the DOS time; the other, WRATTCL, does exactly the opposite.  To
set the battery-powered clock, use the date and time commands to set the
current time through DOS and run WRATTCL; the RDATTCL should be be included
in your autoexec.bat file to set the time properly whenever you boot.

Sorry for the lack of comments in the code... this was done in a big rush,
and I never expected anyone else would have to read it.  Also many thanks
to "s. stern" of "jmb realty corp" for his julian date-handling routines.

Note that the code is written for DeSmet C and will require some (hopefully
fairly obvious) mods to work with other C compilers...

======================== Cut Here ======================

/* Read the AT & T 6300 built-in clock */

/* Written by Bernie Roehl, October 1986 */

#define HIGH(x) (((x) >> 8) & 0xFF)
#define LOW(x) ((x) & 0xFF)

#define J1180 2444240L  /* Julian date of 1-1-1980 */

extern unsigned _rax, _rbx, _rcx, _rdx;

main()
        {
        long ndays;
        int month, day;
        _rax = 0xFE00;
        _doint(0x1A);
        ndays = (long) (_rbx + 0x5B5);
        _rax = 0x2D00;
        _doint(0x21);
        jdate(J1180 + ndays, &day, &month, &_rcx);
        _rdx = (month << 8) | day;
        _rax = 0x2B00;
        _doint(0x21);
        }

/* ------ jdate: convert a julian day number to a calendar date
*
*        reference:
*           collected algorithms of the acm, number 199
*
*        purpose:
*           jdate converts a julian day number to the
*           corresponding gregorian calendar date.  the procedure
*           is valid for any valid gregorian calendar date.
*        note: this is the true julian date, not the serial date
*
*        usage:
*           jdate(julian,&day,&month,&year)
*
*        parameters:
*           julian - julian day number (long int)
*           day    - day of month
*           month  - month 
*           year   - year
*
*       note:  day, month, year must be pointers since values are
*              returned!
*
*        pgm: s. stern, jmb realty corp, chicago; feb, 1980.
*************************************************************************/

      jdate(julian,day,month,year)
      
      long julian;
      int *day,*month,*year;
      
      {
      long d,m,y;
      
/*
 *  use long ints as work space for returning values
 */
      
      julian = julian - 1721119L;
      y = (4*julian - 1)/146097L;
      julian = 4*julian - 1 - 146097L*y;
      d = julian/4;
      julian = (4*d+3)/1461;
      d = 4*d + 3 - 1461*julian;
      d = (d + 4)/4;
      m = (5*d - 3)/153;
      d = 5*d - 3 - 153*m;
      d = (d + 5)/5;
      y = 100*y + julian;
      
      if (m < 10) 
            m = m + 3;
         else
            {
            m = m - 9;
            y++;
            }
/*
*        move results into caller's space
*/
      *year = y;
      *month = m;
      *day = d;
      return;
}
=================== Cut Here ===================
/* Write to the AT & T 6300 built-in clock */

/* Written by Bernie Roehl, October 1986 */

#define HIGH(x) (((x) >> 8) & 0xFF)
#define LOW(x) ((x) & 0xFF)

extern unsigned _rax, _rbx, _rcx, _rdx;

main()
        {
        long int jday();
        unsigned days;
        _rax = 0x2A00;  /* get month, date, year from DOS */
        _doint(0x21);
        days = (unsigned) (jday(LOW(_rdx), HIGH(_rdx), _rcx) - jday(1, 1, 1980));
        _rax = 0x2C00;  /* get hour, minute, second from DOS */
        _doint(0x21);
        _rbx = days - 0x5B5;
        _rax = 0xFF00;  /* set hardware clock through AT&T rom bios */
        _doint(0x1A);
        }

/* ------ jday: convert a calendar date to a julian date --------------

        reference: algorithm 199, collected algorithms from the acm

        purpose:
           jday converts a calendar date, gregorian calendar,
           to the corresponding julian day number.  the procedure
           is valid for any valid gregorian calendar date.
        note:  this is the true julian date, not the serial date.

        usage:
           julian = jday(day,month,year)

        parameters:
           day    - day of month (spi)
           month  - month (spi)
           year   - year (all 4 digits; spi)
           julian - julian day number (long int)

        pgm: s. stern, jmb realty corp, chicago; feb, 1980.
-------------------------------------------------------------------------*/
      long int
      jday(day,month,year)
      int day,month,year;
      {
      long int c;
      long int julian;
      long num1 = 146097L;
      long num2 = 1721119L;
      
      if (month > 2) 
            month -= 3;
         else
            {
            month += 9;
            year--;
            }
      c = year/100;
      year -= 100*c;
      julian =  (num1*c)/4L;
      julian += (1461L*year)/4L;
      julian += (153L*month+2)/5L;
      julian += day+num2;
      return(julian);
      }

==================== Cut Here ====================

                                  --Bernie Roehl
                                    Mail:  broehl at electrical.watstar[.waterloo]
                                    Voice: (519) 885-1211 x 2607



More information about the Comp.sys.att mailing list