Given a sequence of 16 bits, I want to recursively reverse these bits.
For example, 1001 1110 0010 0110 becomes 0110 0100 0111 1001.
I only have access to ADD, AND and NOT.
The subroutine accepts 2 parameters, the number of bits remaining to be reversed and the bit values. It returns the result.
I'm trying to think of ways to do this. One thing that's popped into my head is having a sequence of bits : 0000 0000 0000 0001 to start, and adding it with itself the number of bits left to be processed left -1 times, then anding these bits with the passed in bit pattern. The problem is this seems very ineficient, and also I'm not sure how I would store the result to reverse the bits.
Any hints on this? It is homework, so just hints please :)