if(ACSR&(_BV(ACO)))PORTB=_BV(PORTB2);

The above code was from a program about buck regulator using attiny13.

(ACSR&(_BV(ACO)))

I don't understand what the above line means, but if the value is true Port B2 is set as high.

But what is the condition?
ACO is a read only register
_BV sets value as 1

How can the value of read only register be changed?

Can anyone break the commands and explain briefly?

I know this is a very basic question, but help would be appreciated..

& is bitwise and - so it's just a quick way to test if the ACO bit is set.

Say ACO was bit 2 (I don't want to bother looking up that datasheet, just using as example), acsr is oh, 0b01000x01. 0b01000x01 & 0b00000100 = 0b00000x00 - so it's 0 (false) if ACO is 0, and 8 (which evaluates to true) if ACO is 1.

vijayrex:
ACO is a read only register

But ACO isn't the register but the position of ACO in the ACSR register

vijayrex:
_BV sets value as 1

No it does not. It creates a value of a 1 that is shifted ACO number of places. So the 1 is at the location of the ACO bit in the ACSR register.

And by bitwise AND this new value with the ACSR register (this will not change ASCR) you mask the register. You only see the ACO bit, like DrAzzy says.

vijayrex:
How can the value of read only register be changed?

So it's not. The value is only read (and saved in memory) and then used to mask it for the if.

DrAzzy thank you so much for the reply, at first i didn't understand it but @septillion's reply made me understand how simple and clear your explanation was.

Septillion, I just noticed i mentioned ACO as a register. Well, that's way too careless of me..
About the _BV, I just understood how it really works. Thank you!