Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #864 > unrolled thread

Setting & Clearing flags and C/C++ operators...

Started byGazza <usenet@garethlock.com>
First post2011-10-10 04:58 -0700
Last post2011-10-10 14:40 +0100
Articles 3 — 2 participants

Back to article view | Back to comp.sys.acorn.programmer


Contents

  Setting & Clearing flags and C/C++ operators... Gazza <usenet@garethlock.com> - 2011-10-10 04:58 -0700
    Re: Setting & Clearing flags and C/C++ operators... Chris Johnson <chrisjohnson+news@spamcop.net> - 2011-10-10 14:34 +0100
      Re: Setting & Clearing flags and C/C++ operators... Chris Johnson <chrisjohnson+news@spamcop.net> - 2011-10-10 14:40 +0100

#864 — Setting & Clearing flags and C/C++ operators...

FromGazza <usenet@garethlock.com>
Date2011-10-10 04:58 -0700
SubjectSetting & Clearing flags and C/C++ operators...
Message-ID<1c3f2663-1631-4eff-86b7-01676ec2eb64@i28g2000yqn.googlegroups.com>
This is very much related to the Moria conversion I'm carrying out at
the moment. I hope to have something to bring along to the ROUGOL show
in a couple of weeks. Won't be a working program I'm afraid, but at
least something concrete in the way of code listings.

However, bitmasks are used all over the place dealing with player
status, item drops, monsters etc. I'm coming up against various C
tricks  <variable> =& ~<variable> for example. The other common one is
|=. I understand what they are in C and I think I have most of them
covered. It's the usage of the tilde that I don't understand and it's
direct equivalent in BASIC.

Thanks in advance for any help given.

[toc] | [next] | [standalone]


#865

FromChris Johnson <chrisjohnson+news@spamcop.net>
Date2011-10-10 14:34 +0100
Message-ID<522000e1e6chrisjohnson+news@spamcop.net>
In reply to#864
In article
<1c3f2663-1631-4eff-86b7-01676ec2eb64@i28g2000yqn.googlegroups.com>,
   Gazza <usenet@garethlock.com> wrote:
> erstand what they are in C and I think I have most of them
> covered. It's the usage of the tilde that I don't understand and it's
> direct equivalent in BASIC.

The tilde is the bitmap negation operator - 1's become 0, and 0's
become one.

I guess something like  number% AND NOT 3 which would e.g. be used to
word align an address.

3 is %00000000000000000000000000000011 while
~3 is %11111111111111111111111111111100

(I think that's 32 bits above.

-- 
Chris Johnson

[toc] | [prev] | [next] | [standalone]


#866

FromChris Johnson <chrisjohnson+news@spamcop.net>
Date2011-10-10 14:40 +0100
Message-ID<522001746echrisjohnson+news@spamcop.net>
In reply to#865
To follow on.

To set a flag one would use (e.g. bit 3 is the flag)

flags | %001000 where | is the bitwise OR

To clear a flag

flags & ~%001000 where & is the bitwise AND and ~ is the bitwise
negate

-- 
Chris Johnson

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.acorn.programmer


csiph-web