What you need is the Bitwise operators "&" + "|" (OR).

Since you only want to output the lower bits of PORTB, you have to read PORTB first, mask out the lower bits, then OR the new bits in.

portb = (portb & %11110000) | (var & %00001111)
<br>