james@alberta.UUCP (James Borynec) (05/13/87)
/* due to popular demand, here is my AT real time clock reader */
/* it produces on standard output the numbers needed for the */
/* date -q command. */
/* port_in and port_out routines can be had from klib88.s */
/* james borynec james@alberta */
#define cl_out_port 0x70
#define cl_in_port 0x71
#define sec_addr 0
#define min_addr 2
#define hr_addr 4
#define date_addr 7
#define mon_addr 8
#define yr_addr 9
main ()
{
int seconds,minutes,hours,date,month, year;
port_out(cl_out_port,sec_addr);
port_in(cl_in_port,&seconds);
port_out(cl_out_port,min_addr);
port_in(cl_in_port,&minutes);
port_out(cl_out_port,hr_addr);
port_in(cl_in_port,&hours);
port_out(cl_out_port,date_addr);
port_in(cl_in_port,&date);
port_out(cl_out_port,mon_addr);
port_in(cl_in_port,&month);
port_out(cl_out_port,yr_addr);
port_in(cl_in_port,&year);
printf("%02d",(month/16)*10 + month%16);
printf("%02d",(date/16)*10 + date%16);
printf("%02d",(year/16)*10 + year%16);
printf("%02d",(hours/16)*10 + hours%16);
printf("%02d",(minutes/16)*10 + minutes%16);
printf("%02d",(seconds/16)*10 + seconds%16);
printf("\n");
}