[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
6
Medium Priority
?
186 Views
Last Modified: 2010-04-15
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)

Open in new window

0
Comment
Question by:rem2722
  • 5
6 Comments
 
LVL 53

Expert Comment

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

Expert Comment

by:Infinity08
ID: 20862983
Oh, and ~ is the binary NOT operator.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20862989
And -> is the dereference with member selection operator.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 20863012
PPSAD = PPSAD & ~0x01;  // bitwise and of  PPSAD with bitwize complement of 0x01
PERAD = PERAD | 0x03; // bitwise or of PERAD with 0x03
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

by:Infinity08
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

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

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

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.

613 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question