English
Language : 

AM79C90 Datasheet, PDF (52/62 Pages) Advanced Micro Devices – CMOS Local Area Network Controller for Ethernet (C-LANCE)
AMD
{
int k,i, byte; /* temporary array indices */
int hashcode; /* the object of this program */
char buf[80]; /* holds input characters */
for (i=0;i<8;i++) ladrf[i] = 0; /* clear log. adr. filter */
printf (”Enter Ethernet addresses as 6 octets separated by blanks.\n”);
printf (”Each octet is one or two hex characters. The first octet \n”);
printf (”entered is the first octet to be transmitted. The LSB of \n”);
printf (”the first octet is the first bit transmitted. After each \n”);
printf (”address is entered, the Logical Address Filter contents \n”);
printf (”are displayed, least significant byte first, with the \n”);
printf (”appropriate bits set for all addresses entered so far.\n”);
printf (” To exit press the <Enter> key.\n\n”);
while (1)
{
loop:
printf (”\nEnter address: ”);
/* If 1st character = CR, quit, otherwise read address. */
gets (buf);
if ( buf[0] == ’\0’) break;
if (sscanf (buf, ”%x %x %x %x %x %x”,
&adr[0], &adr[1], &adr[2],&adr[3],&adr[4],&adr[5])
!= 6)
{ printf
(”Address must contain 6 octets separated by blanks.\n”);
goto loop;
}
if ((adr[0] & 1) == 0)
{ printf (”First octet of multicast address ”);
printf (”must be an odd number.\n”);
goto loop;
}
/* Initialize CRC */
for (i=0; i<32; i++) CRC[i] = 1;
/* Process each bit of the address in the order of transmission.*/
for (byte=0; byte<6; byte++)
for (i=0; i<8; i++)
updateCRC ((adr[byte] >> i) & 1);
/* The hash code is the 6 least significant bits of the CRC
in reverse order: CRC[0] = hash[5], CRC[1] = hash[4], etc.
*/
hashcode = 0;
for (i=0; i<6; i++) hashcode = (hashcode << 1) + CRC[i];
/* Bits 3–5 of hashcode point to byte in address filter.
Bits 0–2 point to bit within that byte. */
byte = hashcode >> 3;
52
Am79C90