[Webinar] Streamline your web hosting managementRegister Today

x
Solved

What do these C expressions mean?  Don't recognize these operators.

Posted on 2008-02-10
Medium Priority
186 Views
I am trying to learn embedded C for the HCS12 processor.  Come across a few operators I haven't seen before.  What do the symbols in these four expression mean?

``````PPSAD &= ~0x01;   // pull-up on PAD0
PERAD |=  0x03;   // enable pull-up and pull-down
column>>=1;  //shift into position
while(pt->out)
``````
0
Question by:rem2722
• 5

LVL 53

Expert Comment

ID: 20862980
& is the binary AND operator.
| is the binary OR operator.
>> is the binary right-shift operator.
0

LVL 53

Expert Comment

ID: 20862983
Oh, and ~ is the binary NOT operator.
0

LVL 53

Expert Comment

ID: 20862989
And -> is the dereference with member selection operator.
0

LVL 85

Accepted Solution

ozo earned 2000 total points
ID: 20863012
column = colums>>1; // shift column one bit to the right.  equivalent to unsigned division by 2
while((*pt).out)  dereference pt and get .out field
0

LVL 53

Expert Comment

ID: 20863016
Or, with a bit more explanation :

1) binary AND : takes the binary AND of two values. For example :

0xAA & 0x0F == 0x0A

2) binary OR : takes the binary OR of two values. For example :

0xA0 | 0x0F == 0xAF

3) binary NOT : takes the binary NOT of a value. For example :

~0x0000FFFF == 0xFFFF0000

4) binary right shift : shifts the bits in a value a given number of positions to the right. For example :

0xA0 >> 4 == 0x0A

5) pt->out is the same as (*pt).out   or, dereference pointer to struct pt, and get the member out of that struct.
0

LVL 53

Expert Comment

ID: 20863036
Oh well, so I guess what I said wasn't helpfull ...
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Okay. So what exactly is the problem here? How often have we come across situations where we need to know if two strings are 'similar' but not necessarily the same? I have, plenty of times. Until recently, I thought any functionality like that wo…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses
Course of the Month8 days, 9 hours left to enroll