Originally Posted by
rcgldr
If the data is in a single integer, you just need to do a right shift followed by an and operation. If it's two 32 bit integers, and you need to shift right "n" bits, you shift the "upper" word left (32 - n) bits then "and" off the unwanted bits, shift the lower word right "n" bits, "and" off unwanted bits, then "or" the result together. You could also use a structure with bit fields and let the compiler do the work for you. If this is a 2 way or more associative cache, you'll also need to implement a hashing algorithm to emulate the associative (content addressable) memory.