# Registers

hi, this is more of a beginner question. I wanted to understand the manipulation of bits in the registers, for example this code:

TCCR1B |= (1 << CS12);

My question is not about the registers and what they do, but more about the syntax of this code: why do we use a bitwise or to give the value, and also, how does the bitshift work here? usually we put a number than the bitshift and afterwards choose a number to shift it, like :

int a = 5;
int b = a << 3;

Here we are shifting by “CS12” why, why not use a number instead?
Also, why do we use the bitshift left and not the bitshift right?
really simple questions, just wanted to clarify them before starting anything on my own. Thanks

Here we are shifting by "CS12" why, why not use a number instead?

What number? Various Arduino models might assign different values to CS12.

Also, why do we use the bitshift left and not the bitshift right?

To multiply, not divide. The bitshifting stuff is simply setting the nth bit, while leaving all the other bits clear.

why do we use a bitwise or to give the value

Because the idea is to change only one bit in the value, without having to know the values of the other bits.

hm. ok thanks then

It is better to shift left because you might not know how big the datatype is. Believe it or not, there used to be computers with 9-bit "Bytes". If you shift right you would have to start with 0b1000 0000 for a byte and 0b1000 0000 0000 0000 [ spaces added for clarity ] for a 16 bit int. If you shift left you can always start at 0x01.