Hello, I have always been taught almost never to use goto statements in programming, however we are required to do so as part of my most recent programming project. I have an if/else statement with various goto statements, and the goto statements are failing to execute. I have no idea why. Any help would be appreciated.
int myInt = XXXXXXX;
if((myInt>>22) & 7 == X)
goto a;
else if((myInt>>22) & 7 == Y)
goto b;
else if((myInt>>22) & 7 == Z)
goto c;
a:
printf("this always executes\n");
goto end;
b:
printf("this never executes\n");
goto end;
c:
printf("nor does this\n");
goto end;
end:
//more code
A brief explanation of the bit shifting and such: We are implementing a computer processer, and need to look at the first 3 bits of a 25-bit opcode. So (myInt >> 22) & 7 isolates the 3 bits in the opcode.
Any ideas as to what is going on here?