Category : Files from Magazines
Archive   : PCTJ8804.ZIP
Filename : CMOS.C1

 
Output of file : CMOS.C1 contained in archive : PCTJ8804.ZIP
/* This code calculates the CRC byte that protects the
* configuration data in CMOS addresses 10h through 31h.
* Uses Turbo C inportb() and outportb() for port I/O.
* Written by Dan Rollins
*/

main()
{
unsigned j,x,crc;
crc=0xffff; /* set initial value */
for (j=0x10; j <= 0x31; j++ ) {
outportb(0x70,j); x=inportb(0x71); /* read CMOS byte */
crc = (crc & 0xff) | ( ((crc >> 8) ^ x) << 8 );
x = (crc & 0xff00) >> 4;
crc ^= x;
x <<= 1;
crc = ((crc << 8) | (crc >> 8)) ^ x;
x = (x >> 4) & 0xffe0;
crc ^= x;
x >>= 1;
crc = (crc & 0xff) + (((crc >> 8) ^ x) << 8);
}
printf("CMOS CRC = %xh\r\n", crc);
outportb(0x70,0x33); outportb(0x71,crc & 0xff); /* save lo byte */
outportb(0x70,0x32); outportb(0x71,crc >> 8); /* save hi byte */
}

/* ASM pseudo-code follows:
* mov dx,0xffff
* mov ah,0
* For CMOS bytes between 10h and 31h, inclusive
* Get AL = CMOS byte
* xor dh,al
* mov al,dh
* shl ax,4
* xor dx,ax
* shl ax,1
* xchg dh,dl
* xor dx,ax
* shr ax,4
* and al,0e0h
* xor dx,ax
* shr ax,1
* xor dh,al
* Next
* Store DL in CMOS address 33h, DH in address 32h
*/

  3 Responses to “Category : Files from Magazines
Archive   : PCTJ8804.ZIP
Filename : CMOS.C1

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/