Understanding Probleme

Hi,

i have a little prob to understand this :

if( pir1 & (1

Reply to
chris
Loading thread data ...

Well, at the risk of doing your homework for you....

if (variable) pir1 BITWISE AND with [1 (shifted left) by the number of bits specified in the (constant or variable) SSPIF] evaluates true (i.e. the appropriate bit in pir1 is set), then execute code

Somewhat like

#define MASKBIT 0x4 a = 0x10;

if(a & (1

Reply to
PeteS

would that be his English homework .....

Reply to
Dave but not "Dave"

Snort

I must admit the readability of some posts is less than others

Cheers

PeteS

Reply to
PeteS

thanks for the Answer ! So the code would always run ?

if I good undestand, it will be the same as :

if (SSPIF == 1) { Code }

It is right ?

Thanks

Chris

Reply to
chris

Not really. If the bit position specified in SSPIF is set in the variable, the code will run, otherwise not.

This is a common piece of code to determine if a particular bit is set in some variable and run some code if so, and perhaps some other code if not.

Consider a typical short;

short bitflags;

#define b15position 15; // number of shifts to move a one to the bit 15 position

// .. do some manipulation of bitflags

if(bitflags & (1

Reply to
PeteS

You bad understand. If think you this same as before is. It is wrong.

Look up "shift left" for starters.

Reply to
xray

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.