comp.lang.ada
 help / color / mirror / Atom feed
* Ada and assembler
@ 1997-09-16  0:00 Frederic Deshaies
  1997-09-18  0:00 ` Samuel Tardieu
  1997-09-19  0:00 ` Robert Dewar
  0 siblings, 2 replies; 8+ messages in thread
From: Frederic Deshaies @ 1997-09-16  0:00 UTC (permalink / raw)



Hello,

I would like to know how i can put assembler instructions in an
Ada program ?

Thanks




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

* ADA and assembler
@ 1997-09-17  0:00 Frederic Deshaies
  0 siblings, 0 replies; 8+ messages in thread
From: Frederic Deshaies @ 1997-09-17  0:00 UTC (permalink / raw)




Hello,

I would like to know how I can put assembler instructions in an ADA
program.

Thank you for your reply




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

* Re: Ada and assembler
  1997-09-16  0:00 Ada and assembler Frederic Deshaies
@ 1997-09-18  0:00 ` Samuel Tardieu
  1997-09-19  0:00 ` Robert Dewar
  1 sibling, 0 replies; 8+ messages in thread
From: Samuel Tardieu @ 1997-09-18  0:00 UTC (permalink / raw)
  To: Frederic Deshaies


>>>>> "Frederic" == Frederic Deshaies <Frederic.Deshaies@wanadoo.fr> writes:

Frederic> Hello, I would like to know how i can put assembler
Frederic> instructions in an Ada program ?

If you are using GNAT, then you can use the System.Machine_Code
package just as you use "asm" directive in C with GCC. Here is an
example coming from a Sparc/Solaris-specific file of the GNAT library: 

      function Get_G7 return Interfaces.C.Unsigned;
      pragma Inline (Get_G7);

      ------------
      -- Get_G7 --
      ------------

      function Get_G7 return Interfaces.C.Unsigned is
         Result : Interfaces.C.Unsigned;
      begin
         Asm ("mov %%g7,%0", Interfaces.C.Unsigned'Asm_Output ("=r", Result));
         return Result;
      end Get_G7;

Note that this is a very powerful and efficient mechanism, because in
this example if you use for example:

      if Get_G7 = Some_Value then

then there will be no function call (thanks to inlining) and the code
used to retrieve the value of the G7 register will be scheduled
efficiently by the GCC backend.

Of course, if you are using another target, you have to put i386+
opcodes in your Asm statements.

The best source of information for assembly inlining in GNAT is the
GNAT documentation and the GCC documentation (the first one describes
how you can use from Ada the features describe in the latter).

  Sam
-- 
Samuel Tardieu -- sam@ada.eu.org




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

* Re: Ada and assembler
  1997-09-16  0:00 Ada and assembler Frederic Deshaies
  1997-09-18  0:00 ` Samuel Tardieu
@ 1997-09-19  0:00 ` Robert Dewar
  1 sibling, 0 replies; 8+ messages in thread
From: Robert Dewar @ 1997-09-19  0:00 UTC (permalink / raw)



F. Deshaies asks

<<Hello,

I would like to know how i can put assembler instructions in an
Ada program ?

Thanks>>


This is highly target and implementation dependent, so the question cannot
be answered without knowing exactly what version of what compiler you
are using on what machine with what operating system.

In general this is the kind of question which will have a detailed answer
and you will need to read the documentation that comes with your compiler.

All versions of GNAT support a full implementation of package Machine_Code
and also the use of intrinsics. For full details on how to use this you
will have to read the section on "Machine Code Insertions" in the GNAT
reference manual, and most likely also the relevant sections in the
"Using and Porting GNU CC" manual if you are not familiar with the use
of machine language insertions in GNU C (since GNAT shares the same
approach).





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

* Ada and Assembler
@ 2002-03-31 13:10 Henrik Quintel
  2002-03-31 13:34 ` David C. Hoos, Sr.
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Henrik Quintel @ 2002-03-31 13:10 UTC (permalink / raw)


Dear all,
is it possible to link an external assembler file to an Ada program and to
call an assembler operation from an Ada program?
If yes, please let me know how. Perhaps it is also possible to include
assembler code direct in the Ada Code? I have searched in the AARM but I
haven't found anything that has something to do with interfacing to
assembler code. So it would be very friendly if someon ecan give me a hint
for this problem.

Thanks in adavance.

Yours Henrik





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

* Re: Ada and Assembler
  2002-03-31 13:10 Ada and Assembler Henrik Quintel
@ 2002-03-31 13:34 ` David C. Hoos, Sr.
  2002-03-31 14:02 ` Dr. Michael Paus
  2002-03-31 21:09 ` John R. Strohm
  2 siblings, 0 replies; 8+ messages in thread
From: David C. Hoos, Sr. @ 2002-03-31 13:34 UTC (permalink / raw)



----- Original Message ----- 
From: "Henrik Quintel" <henrik.quintel@gmx.de>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: March 31, 2002 7:10 AM
Subject: Ada and Assembler


> Dear all,
> is it possible to link an external assembler file to an Ada program and to
> call an assembler operation from an Ada program?
> If yes, please let me know how. Perhaps it is also possible to include
> assembler code direct in the Ada Code? I have searched in the AARM but I
> haven't found anything that has something to do with interfacing to
> assembler code. So it would be very friendly if someon ecan give me a hint
> for this problem.
>
The Ada terminology for what you are wanting is Machine Code Insertions.

Please consult your compiler documentation for information on that subject.

David Hoos
 
> Thanks in adavance.
> 
> Yours Henrik
> 
> 
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
> 
> 





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

* Re: Ada and Assembler
  2002-03-31 13:10 Ada and Assembler Henrik Quintel
  2002-03-31 13:34 ` David C. Hoos, Sr.
@ 2002-03-31 14:02 ` Dr. Michael Paus
  2002-03-31 21:09 ` John R. Strohm
  2 siblings, 0 replies; 8+ messages in thread
From: Dr. Michael Paus @ 2002-03-31 14:02 UTC (permalink / raw)


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

Henrik Quintel schrieb:
> 
> Dear all,
> is it possible to link an external assembler file to an Ada program and to
> call an assembler operation from an Ada program?
> If yes, please let me know how. Perhaps it is also possible to include
> assembler code direct in the Ada Code? I have searched in the AARM but I
> haven't found anything that has something to do with interfacing to
> assembler code. So it would be very friendly if someon ecan give me a hint
> for this problem.

Would that fit your needs?

http://www.adapower.com/articles/gnatasm/inline_asm_1.html

Michael

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Visitenkarte f�r Dr. Michael Paus --]
[-- Type: text/x-vcard; charset=us-ascii; name="paus.vcf", Size: 332 bytes --]

begin:vcard 
n:Paus;Michael
tel;cell:0177-2238312
tel;fax:+49-(0)711-765-4095
tel;home:+49-(0)711-765-1493
tel;work:+49-(0)711-765-4094
x-mozilla-html:FALSE
url:www.ib-paus.com
org:Ingenieurb�ro Dr. Paus
adr:;;Sch�naicher Str. 3;Stuttgart;;70597;Germany
version:2.1
email;internet:paus@ib-paus.com
fn:Dr. Michael Paus
end:vcard

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

* Re: Ada and Assembler
  2002-03-31 13:10 Ada and Assembler Henrik Quintel
  2002-03-31 13:34 ` David C. Hoos, Sr.
  2002-03-31 14:02 ` Dr. Michael Paus
@ 2002-03-31 21:09 ` John R. Strohm
  2 siblings, 0 replies; 8+ messages in thread
From: John R. Strohm @ 2002-03-31 21:09 UTC (permalink / raw)


"Henrik Quintel" <henrik.quintel@gmx.de> wrote in message
news:a871rs$qdqnt$1@ID-79136.news.dfncis.de...
> Dear all,
> is it possible to link an external assembler file to an Ada program and to
> call an assembler operation from an Ada program?

Absolutely.  Appendix B.1 discusses "pragma import".  There will be some
vendor-specific incantations relating to actually doing the link; check your
vendor documentation.

> If yes, please let me know how. Perhaps it is also possible to include
> assembler code direct in the Ada Code? I have searched in the AARM but I
> haven't found anything that has something to do with interfacing to
> assembler code. So it would be very friendly if someon ecan give me a hint
> for this problem.

Chapter 13 discusses Ada machine code insertions.  CAUTION: machine code
insertions are NOT for the faint-of-heart.

> Thanks in adavance.
>
> Yours Henrik
>
>





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

end of thread, other threads:[~2002-03-31 21:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-09-16  0:00 Ada and assembler Frederic Deshaies
1997-09-18  0:00 ` Samuel Tardieu
1997-09-19  0:00 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1997-09-17  0:00 ADA " Frederic Deshaies
2002-03-31 13:10 Ada and Assembler Henrik Quintel
2002-03-31 13:34 ` David C. Hoos, Sr.
2002-03-31 14:02 ` Dr. Michael Paus
2002-03-31 21:09 ` John R. Strohm

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