comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: Problem using Ada.Text_IO.Modular_IO
Date: Wed, 16 Jul 2008 07:47:11 GMT
Date: 2008-07-16T07:47:11+00:00	[thread overview]
Message-ID: <3Ihfk.237474$SV4.171883@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: 93bcf03d-dd09-4cdd-b4a7-98bf56284ee3@k37g2000hsf.googlegroups.com

In GNAT the types and functions define by packages "Standard.ads" and 
some others like "Interfaces.ads" are treated as special. 

Note: In GNAT you will not see a package called "Standard" it 
is built-into the compiler.  To check this package you can use 
"-gnatS" (version GNAT 2005-8) in a command line. Such as:

  gnat1 <any ada source file>adb -gnatS  >standard.ads

As for the "Interfaces" package the compiler uses if possible a machine 
instruction to preform the function. So, when the compile encounters a 
call to the function "Rotate_Left" for example on a Intel cpu the 
compiler will use the Intel processor instruction "rol".

To see an example. Create a test program and compile it using either 
the following commands. Two files are create (*.s, and *.ali).

   gnat compile <test file name>.adb  -S  <other options if needed>

or

   gnat1 <test file name>.adb  <other options if needed>

Note: the output of "GNAT1" when excuted by a command line/batch file 
is normally a assembly source file for the target cpu with its assoc *.ali 
file.

Then just check the file: <test file name>.s 

Note: the "*.s" can be compiled and then you can use gnatbind/gnatlink 
to continue to build the program.




In <93bcf03d-dd09-4cdd-b4a7-98bf56284ee3@k37g2000hsf.googlegroups.com>, micronian2@gmail.com writes:
>On Jul 14, 6:12=A0am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
>wrote:
>> anon schrieb:
>[snip]
>> Q: What routines does the compiler generate for Unsigned_64
>> =A0 =A0 but not for "mod 2**64" and vice versa?
>> A: None.
>>
>
>Your "mod 2**64" won't get Shift_Arithmetic_Right, Rotate_Left, and
>Rotate_Right. After some thought, I realized that you can simulate
>Rotate_Left/Right with shift operations. For example,
>Rotate_Left(Value, 3) can be performed by doing:
>
> Value :=3D (Value * 2**3) or (Value / 2**29) (note: assuming value is
>32-bits)
>
>For constant values, the compiled output has a good chance of being
>the same for either "mod 2**64" and Unsigned_64. But what about cases
>where the shift offsets are not known at compile time?  I wrote two
>little test programs to see how user defined shift and rotate
>operations for "mod**64" compared to those that were predefined for
>Interfaces.Unsigned_64 using GNAT GPL2008. For the shift left/right
>operations, the output was the pretty much the same. For the rotate
>left/right, the ones for Unsigned_64 generated less code and did not
>need as many calls to the run-time system. Of course, this is all just
>based on one compiler. I don't know what other compilers do. Actually
>I do recall the old GreenHills AdaMULTI 3.0 compiler implemented the
>operations as calls to C functions.
>
>Anyhow, I think I said enough on this.
>




  reply	other threads:[~2008-07-16  7:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-09 16:52 Problem using Ada.Text_IO.Modular_IO jujosei
2008-07-09 19:03 ` Anh Vo
2008-07-09 19:22   ` Adam Beneschan
2008-07-09 21:50 ` Adam Beneschan
2008-07-10 15:00   ` jujosei
2008-07-10  0:48 ` anon
2008-07-10  1:52   ` Adam Beneschan
2008-07-10  7:25     ` anon
2008-07-10 14:59       ` Adam Beneschan
2008-07-11  0:34         ` anon
2008-07-11  9:49           ` Georg Bauhaus
2008-07-11 10:05             ` christoph.grein
2008-07-11 13:21               ` John McCormick
2008-07-11 12:16             ` anon
2008-07-11 13:26               ` petter_fryklund
2008-07-11 21:10                 ` anon
2008-07-12 10:06                   ` Georg Bauhaus
2008-07-13  0:51                     ` anon
2008-07-13 16:03                     ` Georg Bauhaus
2008-07-14  2:03                       ` anon
2008-07-14 13:12                         ` Georg Bauhaus
2008-07-16  6:16                           ` micronian2
2008-07-16  7:47                             ` anon [this message]
2008-07-17 16:33                               ` micronian2
2008-07-14 16:34                       ` micronian2
2008-07-14 17:26                         ` Georg Bauhaus
2008-07-16  6:28                           ` micronian2
replies disabled

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