Iron Phoenix wrote:
> ANSI C allows me *direct* access to the hardware clock:
Really?
>
> #define BIOS_TIME_SERVICES_INTERRUPT 0x1a
> #define BIOS_GET_RTC_TIME_SERVICE 2
>
> int hour_high,
> hour_low,
> minute_high,
> minute_low;
>
> void get_bios_time(void)
> {
> int hour,minute;
> regs.h.ah=BIOS_GET_RTC_TIME_SERVICE;
> int86(BIOS_TIME_SERVICES_INTERRUPT,®s,®s);
> hour=BcdToBinary(regs.h.ch);
> minute=BcdToBinary(regs.h.cl);
> hour_high=(hour/10);
> hour_low=(hour%10);
> minute_high=(minute/10);
> minute_low=(minute%10);
> }
> unsigned char BcdToBinary(unsigned char val)
> {
> return (val/16)*10+val%16;
> }
rjh@tux:~/scratch> cat foo.c
#define BIOS_TIME_SERVICES_INTERRUPT 0x1a
#define BIOS_GET_RTC_TIME_SERVICE 2
int hour_high,
hour_low,
minute_high,
minute_low;
void get_bios_time(void)
{
int hour,minute;
regs.h.ah=BIOS_GET_RTC_TIME_SERVICE;
int86(BIOS_TIME_SERVICES_INTERRUPT,®s,®s);
hour=BcdToBinary(regs.h.ch);
minute=BcdToBinary(regs.h.cl);
hour_high=(hour/10);
hour_low=(hour%10);
minute_high=(minute/10);
minute_low=(minute%10);
}
rjh@tux:~/scratch> gcc -W -Wall -ansi -pedantic -O2 -c -o foo.o foo.c
foo.c: In function `get_bios_time':
foo.c:12: `regs' undeclared (first use in this function)
foo.c:12: (Each undeclared identifier is reported only once
foo.c:12: for each function it appears in.)
foo.c:13: warning: implicit declaration of function `int86'
foo.c:14: warning: implicit declaration of function `BcdToBinary'
The compiler refused to provide an object file.
So much for that.
--
Richard Heathfield :
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ:
http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc:
http://users.powernet.co.uk/eton