Copying 8bits from PORTA to 4 bits PORTB

Quite a general programmin question.

Say I want to copy the contents of PORTA into PORTB

PORTA = PORTB

Now say I only want the 4 least significant digits copied (the 4 MSB should all be zero).

What the most efficient way to do this? Copy them to a variable, shift them and then copying them from the variable to PORTA?

Regards

Say I want to copy the contents of PORTA into PORTB

PORTB = PORTA & B00001111;

Or
PORTA = PINB & 0b00001111;

Are the bits at the Port B pins inputs or outputs?

CrossRoads:
Or
PORTA = PINB & 0b00001111;

Are the bits at the Port B pins inputs or outputs?

Thanks guys.

Porb B pins are outputs

Be careful that your code doesn't change bits in a Port that have some other use in the Arduino system. On an Uno some of the 8 bits in every Port are used by something else.

That means that you must use

&= 0b11110000 to clear all 4 low bits without disturbing the 4 high bits
|= 0b00001111 to set all 4 low bits

(hope I have this the right way round)

...R