comp.lang.ada
 help / color / mirror / Atom feed
* Take controll of the assignment operator
@ 2000-04-11  0:00 Rainer Aigner Tel. XXXX
  2000-04-11  0:00 ` Robert A Duff
  0 siblings, 1 reply; 7+ messages in thread
From: Rainer Aigner Tel. XXXX @ 2000-04-11  0:00 UTC (permalink / raw)


Hello ,
!Please excuse by bad english!

I'm a new one in this news group, and a beginner in programming ADA95.
Right now I have to write some TSAP's in RISC Class 1.
The question I have I just an idea I had, and I just didn't find a
solution for over 2 weeks or so.

Here's the problem:

I define some types:

type unsigned_byte is mod 2**8;
for unsigned_byte'size  use 8;

type unsigned_word is mod 2**16;
for unsigned_word'size use 16;

type unsigned_longword is mod 2**32;
for unsigned_longword'size use 32;

Up to here everythings fine.
Now, my question: How can I make sure that the compiler uses the right
assembler for load and store operations?

My target is a PowerPC and has for each type it's own assembler
statement, and I got to sure (RISC Class 1) that a particular assembler
statment is used.

My first intention was to overload the assignment operator for each type
to get controll over the load/store operations.
But after several hours I kicked this idea, because the assignment
operator is the only one which can not be overloaded.
The workaround right now are sperate load/store procedures.
But that's not what I wanted. Okay You can live with it but..

So if anybody has an idea, I would be very thankfull.

cu
Rainer Aigner

mailto:
aigner@newtec.de





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Take controll of the assignment operator
  2000-04-11  0:00 Take controll of the assignment operator Rainer Aigner Tel. XXXX
@ 2000-04-11  0:00 ` Robert A Duff
  2000-04-12  0:00   ` Rainer Aigner
  0 siblings, 1 reply; 7+ messages in thread
From: Robert A Duff @ 2000-04-11  0:00 UTC (permalink / raw)


"Rainer Aigner Tel. XXXX" <aigner@newtec.de> writes:

> Up to here everythings fine.
> Now, my question: How can I make sure that the compiler uses the right
> assembler for load and store operations?

I'm not sure exactly what you're asking, but you might want to look up
the Atomic and Volatile pragmas.

- Bob




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Take controll of the assignment operator
  2000-04-11  0:00 ` Robert A Duff
@ 2000-04-12  0:00   ` Rainer Aigner
  2000-04-12  0:00     ` Robert Dewar
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Rainer Aigner @ 2000-04-12  0:00 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1368 bytes --]

Robert A Duff wrote:
> 
> "Rainer Aigner Tel. XXXX" <aigner@newtec.de> writes:
> 
> > Up to here everythings fine.
> > Now, my question: How can I make sure that the compiler uses the right
> > assembler for load and store operations?
> 
> I'm not sure exactly what you're asking, but you might want to look up
> the Atomic and Volatile pragmas.
> 
> - Bob
Hello Bob,

all right I thougth of that too, but maybe I rearange the question:

I got two types one is 8-Bit and the other is 16-Bits wide.
I make two variables, one of eache type, and tell the compiler where
they are located (eg. registers).

Now I make a simple read from both variables to a temp variable of each.
(for modify and write back).

And I want to make sure, that a read with the 8-bit type is performed by
a "load byte", 
and the 16-bit type by a "load halfword" assembler statement.

The pragmas You told me, would do (correct me if I didn't get right)
volatile: make sure that the compiler doesn't opimize them out. eg. two
consecutive writes and a subsequent read.

atomic: Is trying to perform the load and store in a single assembler
statment. That okay, but it's only half the rent.
   In addition to this I want that the compiler thates care of the size.

unfortunatly the compiler I have to use doesn't work with the pragma
volatile (still some bug).

thank You for the answer.

cu
rainer

[-- Attachment #2: Card for Rainer Aigner --]
[-- Type: text/x-vcard, Size: 184 bytes --]

begin:vcard 
n:Aigner;Rainer
x-mozilla-html:FALSE
org:NewTec GmbH;Software developer
adr:;;;;;;
version:2.1
email;internet:aigner@newtec.de
x-mozilla-cpt:;0
fn:Rainer Aigner
end:vcard

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Take controll of the assignment operator
  2000-04-12  0:00   ` Rainer Aigner
  2000-04-12  0:00     ` Robert Dewar
  2000-04-12  0:00     ` Jean-Pierre Rosen
@ 2000-04-12  0:00     ` Robert A Duff
  2 siblings, 0 replies; 7+ messages in thread
From: Robert A Duff @ 2000-04-12  0:00 UTC (permalink / raw)


Rainer Aigner <aigner@newtec.de> writes:

> And I want to make sure, that a read with the 8-bit type is performed by
> a "load byte", 
> and the 16-bit type by a "load halfword" assembler statement.

If you need exact control of which instructions are executed, then you
need to write in assembly.  Look at code statements (package
Machine_Code) and intrinsics.  These things are highly implementation
dependent, so you need to read the documentation for the Ada compiler
you're using.

Try to write *most* of the code in portable Ada, and use assembly just
where it's needed.

- Bob




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Take controll of the assignment operator
  2000-04-12  0:00   ` Rainer Aigner
@ 2000-04-12  0:00     ` Robert Dewar
  2000-04-13  0:00       ` Rainer Aigner
  2000-04-12  0:00     ` Jean-Pierre Rosen
  2000-04-12  0:00     ` Robert A Duff
  2 siblings, 1 reply; 7+ messages in thread
From: Robert Dewar @ 2000-04-12  0:00 UTC (permalink / raw)


In article <38F437C5.D525C847@newtec.de>,
  Rainer Aigner <aigner@newtec.de> wrote:
> And I want to make sure, that a read with the 8-bit type is
> performed by a "load byte", and the 16-bit type by a "load
> halfword" assembler statement.

There is absolutely NOTHING in the RM, or anywhere else that
would imply it is appropriate to expect this usage of
instructions, and there is nothing wrong in a compiler that
does not follow this expectation, and there is no way to
insist that the compiler follow this expectation.

If your code depends on this, then the ONLY legitimate way
to achieve this is to write machine language insertions
or instrinsics that generate the instructions you need.
Any other solution is incorrect, and may cause significant
difficulties in porting the application to another compiler
or to another system.


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Take controll of the assignment operator
  2000-04-12  0:00   ` Rainer Aigner
  2000-04-12  0:00     ` Robert Dewar
@ 2000-04-12  0:00     ` Jean-Pierre Rosen
  2000-04-12  0:00     ` Robert A Duff
  2 siblings, 0 replies; 7+ messages in thread
From: Jean-Pierre Rosen @ 2000-04-12  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 646 bytes --]


Rainer Aigner <aigner@newtec.de> a �crit dans le message :
38F437C5.D525C847@newtec.de...
> And I want to make sure, that a read with the 8-bit type is performed by
> a "load byte",
> and the 16-bit type by a "load halfword" assembler statement.
>
If your need is precisely to make sure that a precise machine instruction is
used, by all means use machine code insertion, and do not try to play with
the compiler.
That's exactly what machine code statements are made for.

--
---------------------------------------------------------
           J-P. Rosen (Rosen.Adalog@wanadoo.fr)
Visit Adalog's web site at http://pro.wanadoo.fr/adalog






^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Take controll of the assignment operator
  2000-04-12  0:00     ` Robert Dewar
@ 2000-04-13  0:00       ` Rainer Aigner
  0 siblings, 0 replies; 7+ messages in thread
From: Rainer Aigner @ 2000-04-13  0:00 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1684 bytes --]

Robert Dewar wrote:
> 
> In article <38F437C5.D525C847@newtec.de>,
>   Rainer Aigner <aigner@newtec.de> wrote:
> > And I want to make sure, that a read with the 8-bit type is
> > performed by a "load byte", and the 16-bit type by a "load
> > halfword" assembler statement.
> 
> There is absolutely NOTHING in the RM, or anywhere else that
> would imply it is appropriate to expect this usage of
> instructions, and there is nothing wrong in a compiler that
> does not follow this expectation, and there is no way to

That completle correct, and I got the problem.
My idea was, if I can overload all the other operators
and even can implement my own heap, and many more (and all by language),
maybe I have a chance to influence the assignment.
Regarding to the point, that my sw is in RISC Class 1 and code
coverage...
It would also be much less effort to validate the code. cause right now 
I have some 2000 line just with direct assembler. And it will be many
more.

Up to this point, I can live it, but couldn't it been that I just
doesn't saw
the right way?

> insist that the compiler follow this expectation.
> 
> If your code depends on this, then the ONLY legitimate way
> to achieve this is to write machine language insertions
> or instrinsics that generate the instructions you need.
> Any other solution is incorrect, and may cause significant
> difficulties in porting the application to another compiler
> or to another system.
Right now I writing code on 3 different plattforms, with 3 different
compilers.
The thing with porting to another system will be difficult for a TSAP
(Target Specific ADA Package).

> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

[-- Attachment #2: Card for Rainer Aigner --]
[-- Type: text/x-vcard, Size: 184 bytes --]

begin:vcard 
n:Aigner;Rainer
x-mozilla-html:FALSE
org:NewTec GmbH;Software developer
adr:;;;;;;
version:2.1
email;internet:aigner@newtec.de
x-mozilla-cpt:;0
fn:Rainer Aigner
end:vcard

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2000-04-13  0:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-11  0:00 Take controll of the assignment operator Rainer Aigner Tel. XXXX
2000-04-11  0:00 ` Robert A Duff
2000-04-12  0:00   ` Rainer Aigner
2000-04-12  0:00     ` Robert Dewar
2000-04-13  0:00       ` Rainer Aigner
2000-04-12  0:00     ` Jean-Pierre Rosen
2000-04-12  0:00     ` Robert A Duff

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