Bitshifting bytes to form a long var fails!

dhenry:
By the way, for this kind of shifts, you can execute them a lot faster with unions or pointers.

...

dhenry:
The solution I will provide you is built on that and takes just two instruction cycles to shift any number of bits (less than 8 obvious as you can break any shifts down). It is a hardware based solution available to any avr.

When (if) you provide this solution be prepared for me to compare its speed to the speed generated by the compiler for the "or" method.

I'm prepared to believe you might have a faster one, shifting left 8 or 16 bits could indeed be done by simply moving into a struct or a union.

Bear in mind though that any "faster" solution doesn't address the OP's question. S/he wanted to know why it didn't work, not how to make it faster. I've shown how you can make it work with two casts.

To make it faster, I would be wondering, personally, why you (the OP) are constructing an address out of 4-bit numbers. Why do that? Why not 8-bit numbers?