int CLoad(int CounterNum, char LoadValue[]) { int TempByte, TempByte1, Register, CounterMask; int WriteLowByteMask1 = 0x20; /* RL1 | */ int WriteLowByteMask2 = 0xef; /* RL0 & */ int WriteHighByteMask1 = 0xdf; /* RL1 & */ int WriteHighByteMask2 = 0x10; /* RL0 | */ char LowByte[5]; char HighByte[5]; long HighByteValue, LowByteValue; int test; switch (CounterNum) { case 1: Register = LOADREAD1; CounterMask = 0x3f; break; case 2: Register = LOADREAD2; CounterMask = 0x7f; break; case 3: Register = LOADREAD3; CounterMask = 0xbf; break; default: return(1); break; } HighByte[0] = LoadValue[0]; HighByte[1] = LoadValue[1]; HighByte[2] = LoadValue[2]; HighByte[3] = LoadValue[3]; LowByte[0] = '0'; LowByte[1] = 'x'; LowByte[2] = LoadValue[4]; LowByte[3] = LoadValue[5]; HighByteValue = (int)strtol(HighByte, NULL, 0); LowByteValue = (int)strtol(LowByte, NULL, 0); TempByte = (CounterMask | WriteLowByteMask1) & WriteLowByteMask2; TempByte1 = TempByte & 0xf0; printf("The value in config low is --> %x.\n", TempByte1); outb(TempByte1, CCONFIGPORT); outb(LowByteValue, Register); printf("The register chosen is --> %x.\n", Register); test = inb(Register); printf("The value read in counter low is --> %x.\n", test); TempByte = (0x30 & WriteHighByteMask1) | WriteHighByteMask2; printf("The value in config high is --> %x.\n", TempByte); outb(TempByte, CCONFIGPORT); outb(HighByteValue, Register); outb(TempByte, CCONFIGPORT); test = inb(Register); printf("The value in counter high is --> %x.\n", test); return(0); }