I am writing a program in assembly language and need help. I am given two 16 bit integers that represent a candidate and a reference respectively. The object is to see if the candidate and the reference are equal. The 16 bit integer represents eight colors around a square and the graphical representation is:

0 1 2
7 X 3
6 5 4

The X in the center is just there to show a blank space.
The possible colors that can be in the eight positions are red, yellow, green, blue and their values are 0,1,2,3 respectivly. The task is to see if the candidate square is equal to the reference square and it can be either a direct match or the candidate square can be rotated, flipped, or both.

I am able to check for a direct match without a problem, but I have no idea how to check for a match if the candidate has been rotated, flipped, or both. I know some operations need to be done on the 16 bit integer value to check for these conditions and then after this the reference and candidate can be compared to see if they are equal, but I have no idea how to approach this.

Any help would be appreciated. thanks.