/* CMOSRAM.C * * * This example program stores a string (up to 31 bytes) in the * battery-backed CMOS RAM in the real-time clock. */ #include #ifdef __TURBOC__ extern int _Cdecl directvideo = 0; #endif void WriteRam(int offset, int dta) { union REGS regs86; regs86.h.ah = 0xDD; /* Micro/sys function */ regs86.h.al = 0x09; /* write byte to CMOS RAM */ regs86.h.bh = offset; regs86.h.bl = dta; int86(0x1A, ®s86, ®s86); } int ReadRam(int offset) { union REGS regs86; regs86.h.ah = 0xDD; /* Micro/sys function */ regs86.h.al = 0x08; /* read byte from CMOS RAM */ regs86.h.bh = offset; int86(0x1A, ®s86, ®s86); return (regs86.h.al); /* return data from CMOS RAM */ } void main(void) { int dta, n; char str[80]; printf("CMOSRAM\n"); printf("This program displays a string stored in CMOS RAM\n"); printf("and allows that string to be changed\n"); for(;;) { printf("\n\nCurrent string=\""); for(n=0;n<31;n++) /* up to 31 characters */ { dta = ReadRam(n); if (!dta) /* quit if end of string */ break; putch(dta); } printf("\"\nEnter new string: "); gets(str); for(n=0; n<31; n++) { WriteRam(n, str[n]); if (!str[n]) break; } } }