comp.lang.ada
 help / color / mirror / Atom feed
From: kilgallen@eisner.decus.org (Larry Kilgallen)
Subject: Re: How to perform bit-wise xor, and...?
Date: 1996/11/22
Date: 1996-11-22T00:00:00+00:00	[thread overview]
Message-ID: <1996Nov22.105049.1@eisner> (raw)
In-Reply-To: 5747oa$svi@umacss1.umac.mo


In article <5747oa$svi@umacss1.umac.mo>, d941686@sp2 (Leong San Io Francisco) writes:

> 	Can someone teach me how to perform bit-wise "xor", and, "or" of two
> integers in Ada so that it can generate code as close as to the underlying
> computer's instructions like the C's ^, &, | operators? I am trying to write
> some computer instructions emulation stuff as well as bitmap graphics
> manipulation which requires "xor", "or" bytes. Is multiplication by 2 really
> equal to shift left and division by integer 2 to shift right?

Someone else may care to go into conversion tricks, but let me just
comment that when you declare something as an integer it specifies
the manner in which you intend to use it.  If you find you have a
need to apply logical operations to a numeric, then either:

   1) You were wrong to declare it as an integer
or
   2) Some external definition has horribly overloaded the
      meaning of a given location*

This is true for all programming languages, but with Ada the mismatch
is detected and you are alerted to the inconsistency.  Other languages
will allow your program to run, and so long as you do not care about
the results of that run, things are much easier than with Ada :-)

> 	My Ada compiler only provides xor, and operations for booleans and
> not integers...

One thing you will find about Ada at this level is that what _your_
Ada compiler provides is quite the same as what anybody else's Ada
compiler provides.  Ada customers are quite fussy about compilers
matching the standard language definition, and the discussions
you may read in this group about nuances of interpreting that
definition delve into details far too obscure to be a problem
for you in the near term.

Larry Kilgallen

* I am reminded of those delightful machine IO registers which have
  one set of meanings for bits on Read and another set of meanings
  on Write.




  reply	other threads:[~1996-11-22  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-22  0:00 How to perform bit-wise xor, and...? Leong San Io Francisco
1996-11-22  0:00 ` Larry Kilgallen [this message]
1996-11-23  0:00   ` Leong San Io Francisco
1996-11-24  0:00   ` Michael F Brenner
1996-11-22  0:00 ` Matthew Heaney
1996-11-24  0:00   ` Brian
1996-11-27  0:00     ` Robert Dewar
1996-11-25  0:00 ` Robert I. Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox