I have a final 32 bit integer
int32_t final;
It has this format
6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
opcode rs rt rd shamt funct
I have opcode populated with 0. I have rs rt and rd populated with their respective integers. shamt has its value and so does funct. My only issue is, how do I load these into the final int? I know it has something to do with the << operator and logic like & and |. I have this function
unsigned mask(unsigned a, unsigned b)
{
unsigned r = 0;
unsigned i;
for (i=a; i<=b; i++)
r |= 1 << i;
return r;
}
which creates a mask that can be anded with a value to get it's bits a-b. Am I on the right track here?