Hello, I have decided to use arrays as suggested by Allen. Arrays are=20 easier for me to understand. Here is what I did: int porta[3]; //The PORTA output array int portb[3]; //The PORTB output array int a; //The PORTA index=20 variable int b; //The PORTB=20 indexvariable //Load the arrays bits 7 6 5 4 =20 3 2 1 0 porta[0] =3D 132; //Drk-Red 1 0 N =20 N 0 1 I I porta[1] =3D 8; //Lit-Grn 0 =20 0 N N 1 0 I I porta[2] =3D 64; //Lit-Yel 0 =20 1 N N 0 0 I I porta[3] =3D 128; //Lit-Red 1 =20 0 N N 0 0 I I bits 7 6 5 4 3 2 1 0 portb[0] =3D 36; //Drk-Red N N =20 1 0 0 1 I I portb[1] =3D 8; //Lit-Grn N =20 N 0 0 1 0 I I portb[2] =3D 16; //Lit-Yel N =20 N 0 1 0 0 I I portb[3] =3D 32; //Lit-Red N =20 N 1 0 0 0 I I So the next step is to use a =3D PORTA and b =3D PORTB. Then we do=20 this: PORTA =3D porta[a]; and PORTB =3D portb[b]; Am I doing this correctly= ? Thanks, rich! P.S. All of the help is greatly appreciated. Thanks, rich! On 9/15/2015 9:48 AM, Byron Jeff wrote: > Denny's previous post is essentially defines it: > > // Defining the table: > unsigned char TableA[] =3D {0x82,0x04,0x40,0x80}; > unsigned char mask =3D 0x33; // mask out bits 7,6,3, and 2 > > // Using the table: > shadowA =3D PORTA & mask; // Get PORTA masking out output bits. > inputA =3D shadowA & 0x03; // input is PORTA bits 1,0 > shadowA =3D shadowA | TableA[inputA]; // Get output from table and merge = with shadow > PORTA =3D shadowA; // Write the output from shadow back to PORTA > > Of course C can be obfuscated into a single statement: > PORTA =3D shadowA | TableA[(shadowA =3D PORTA & mask) & 0x03]; > > Interesting what you can do when assignment is an expression and not a > statement. > > BAJ > > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .