#include	<stdio.h>
#include	<std.h>
#include	"bit.h"

main ()
{
char	string[80];
int	word, bit, array[4], mask, result;


FOREVER
	{
	for (word = 0; word < 64; word++)
		putchar ((word % 10) + '0');
	putchar ('\n');
	for (word = 0; word < 4; word++)
		for (mask = 1; mask; mask = mask << 1)
			putchar (((mask & array[word]) ? '1' : '0'));
	printf ("\nBit:  ");
	if (gets (string) == NULL) exit ();
	bit = atoi (string);
	printf ("Test, Set, Clear, Flip:  ");
	if (gets (string) == NULL) exit ();
	switch (toupper (*string))
		{
		case 'T':
			result = tst_bit(array, bit);
	printf ("Bit %d is %s.\n", bit, (result ? "on" : "off"));
			break;
		case 'S':
			set_bit(array, bit);
			break;
		case 'C':
			clr_bit(array, bit);
			break;
		case 'F':
			flip_bit(array, bit);
			break;
		default:
			break;
		}
	}
}
