Skimask,
The desired end result is to use 4 bits on Port B as input, Port C as output to drive the display, and 1 bit on Port D as input to tell the difference between True and Complimentary encoded switches, rotary encoders.

TNX,
Terry