Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Some basic c questions plz with & and |

Status
Not open for further replies.

Terminator Electricity

Member level 5
Joined
Feb 2, 2006
Messages
91
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,973
what does this expressions mean ?
how are & and | used for different purposes ?
plz help cuz i really need to know this

EICRA &= ~0xf0;
EICRA |= 0xe0;

int newState = trans[State->state]>>Event & 0x3;

also ,, plz how >> or << are used and how many meanings they have

your help is much appreciated
 

EICRA &= ~0xf0; is the abbreviated form of:
EICRA = EICRA & ~0xf0;
or
EICRA = EICRA & 0x0f;
So EICRA is read, ANDed with 0x0f, then written back to EICRA, in other words: the high nibble is cleared

similar in this expression:
EICRA |= 0xe0; is the abbreviated form of:
EICRA = EICRA | 0xe0;
So EICRA is read, ORed with 0xe0, then written back to EICRA, in other words: the 3 highest bits are set

The shift operators >> and <<:
better to write it like this (I'm too lazy to remember priorities ;-) )
int newState = (trans[State->state]>>Event) & 0x3;
means: trans[State->state] is shifted right "Event" times, then this value is ANDed with 0x03

<< means shift left. That's the only meaning I know of >> and <<
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top