From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Bit operators
Date: 2000/02/13
Date: 2000-02-13T00:00:00+00:00 [thread overview]
Message-ID: <886feg$qgr$1@nnrp1.deja.com> (raw)
In-Reply-To: 884o85$jjv$1@news.fsu.edu
In article <884o85$jjv$1@news.fsu.edu>,
grant@cs.fsu.edu (Joshua Grant) wrote:
> I was recently assigned a project for one of my classes that
gave us the
> option of implementing a simplified MIPS assempler in any
preferred higher
> level language. I have choosen ADA, but I am running into a
problem with
> the bit operators. I can't find them! In case someone isn't
sure of my
> question. In C++ if you perform an 'and' operation with the
'&'
> operator like...
All the answers you got were inappropriate (a not uncommon
occurrence around here :-) :-)
You approached the problem with a "how-do-I-write-C-in-Ada"
viewpoint, and three people answered you to tell you how :-)
But the proper answer is to use the features of Ada that allow
this to be done nicely without such nasty low level gizmos.
MIPS assembly instructions have a very regular format, there
are only a very few instruction formats.
For each of these define a record type, with nicely typed fields
and then use a record representation clause to lay out the
record in a manner that matches the MIPS layouts (you may have
to worry about endian considerations here, but the same is
true using the low level C approach anyway).
Now you assign to the fields of this record with full type
checking, e.g. if you try to put an immediate value in a
register field, you will get a compile time error.
There is no point in writing C in Ada, if you want to write
C, write C in C, it is less trouble :-)
Sent via Deja.com http://www.deja.com/
Before you buy.
next prev parent reply other threads:[~2000-02-13 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-02-12 0:00 Bit operators Joshua Grant
2000-02-13 0:00 ` Robert Dewar [this message]
2000-02-13 0:00 ` Gautier
2000-02-13 0:00 ` Matthew Heaney
2000-02-13 0:00 ` Bit operators & asm in Ada (novice question) G
2000-02-13 0:00 ` Vladimir Olensky
2000-02-13 0:00 ` Gautier
2000-02-13 0:00 ` Bit operators Gautier
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox