Basic understanding of commands

OP #1171863
Hello,

im very new to ARM-GCC and c itself

so i have two very basic questions.
So "almost"-newbies have the pleasure to give an answer too.

what does the "~" do ?

example:

VICIntSelect &= ~0x00000040;

i was googling a lot but did not find anything at all
related to "c"

VICIntSelect is just a constant defined in the headerfile lpc2xxx.h

#define VICIntSelect   (*((volatile unsigned long *) 0xFFFFF00C))

das the commandline

VICIntSelect = 0x00000040;

mean: store value "0x00000040" in Memory-Adress "0xFFFFF00C" ?


thank you very much for helpful answers

greetings

Stefan
Guest #1171864
Stefan Ludwig wrote:
> what does the "~" do ?

~ (tilde) 1's complement

in German: "Komplementierung aller Bits eines Integer-Wertes
(NOT/Einer-Komplement)."

Examples:
~00000000 == 11111111
~11111111 == 00000000
~11001101 == 00110010

Links
http://www.schellong.de/c.htm#oper (German)
http://www.lysator.liu.se/c/bwk-tutor.html#bit

> VICIntSelect = 0x00000040;
> mean: store value "0x00000040" in Memory-Adress "0xFFFFF00C" ?

Yes.

Another Stefan ;-)
#1171865
Stefan Ludwig wrote:
> i was googling a lot but did not find anything at all
> related to "c"
What did you googler on? Obviously typing '~' into google would not get
you far! Googling of "C Operators" would have got you the answer - as
would any good C reference (in fact even a bad reference!). Get yourself
a copy of K&R for example.

Clifford
#1171866
Clifford Slocombe wrote:
> Stefan Ludwig wrote:
>> i was googling a lot but did not find anything at all
>> related to "c"
> What did you googler on? Obviously typing '~' into google would not get
> you far! Googling of "C Operators" would have got you the answer - as
> would any good C reference (in fact even a bad reference!). Get yourself
> a copy of K&R for example.
>
> Clifford

Just for the record, this is the response this ilicited from Stefan by
privaed e-mail:

====================================
so you're just another one of this arrogant guys
throwing around special TLA*s like "K&R"

What if I even did not know that "~" is an OPERATOR?

judging about your answer: NOT HELPFUL AT ALL
just satisfying your frustration about what ever
====================================

I am sorry Stephan, if you found the response unhelpful. That was not
the intention. I felt that the specific question had been adequately
answered, so rather than duplicate the information I thought that
perhaps a better approach to problem solving than posting to a forum
might be helpful. Also the suggestion would have provided information on
all the other C operators as well. It is interesting that you found that
unhelpful.

It did not seem unreasonable to me that if you are going to use a
programming language that you should have some sort of language
reference. "The C Programming Language" by Kernighan and Ritchie (K&R)
is the seminal work on the language. It commonly referred to as K&R, and
Google'ing on just that will certainly tell you what it is if you were
not familiar.

If you did not realise that '~' was an operator, than you don't really
understand the syntax of C. All the more reason to get a reference.
Guest #1171867
Another suggestion if you find a search engine does not work for you, is
to head over to wikipedia which will always lead to a starting point to
find out about such things.

Good Luck with learning ANSI C, I have been using it for 18 years so I
think I have the hang of it now!
Guest #1171868
I took some of my own medcine and found this :-

http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B

Not bad for 5 clicks!


FordP wrote:
> Another suggestion if you find a search engine does not work for you, is
> to head over to wikipedia which will always lead to a starting point to
> find out about such things.
>
> Good Luck with learning ANSI C, I have been using it for 18 years so I
> think I have the hang of it now!

Reply

A question of your own? This thread is over 20 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.