comp.lang.ada
 help / color / mirror / Atom feed
* Linking Ada with large Assembler libs?
@ 2007-02-21 21:29 freejack
  2007-02-25 22:47 ` Gene
  2007-03-08  8:58 ` Rolf
  0 siblings, 2 replies; 3+ messages in thread
From: freejack @ 2007-02-21 21:29 UTC (permalink / raw)


The Machine Code Insertions sections of the relevant reference manuals
have been informative.

However, I'm linking my Ada code with pre-existing libs written in
Assembler. The GNAT manuals are a little sketchy on how to do this
properly. I'm using NASM and FASM Assembler code. Most of the
Assembler code deals primarily with I/O. I'm using Pragma No_Run_Time
and writing my own Binder files, with a good bit of success.
It's not such a big problem, as I can do it by fiddling with the
linker and manipulating the object code. But the result is messy and
error prone.

What are the best methods you guys have come up with for doing this
sort of manipulation?

freejack
Chris




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

* Re: Linking Ada with large Assembler libs?
  2007-02-21 21:29 Linking Ada with large Assembler libs? freejack
@ 2007-02-25 22:47 ` Gene
  2007-03-08  8:58 ` Rolf
  1 sibling, 0 replies; 3+ messages in thread
From: Gene @ 2007-02-25 22:47 UTC (permalink / raw)


On Feb 21, 4:29 pm, "freejack" <freej...@tds.net> wrote:
> The Machine Code Insertions sections of the relevant reference manuals
> have been informative.
>
> However, I'm linking my Ada code with pre-existing libs written in
> Assembler. The GNAT manuals are a little sketchy on how to do this
> properly. I'm using NASM and FASM Assembler code. Most of the
> Assembler code deals primarily with I/O. I'm using Pragma No_Run_Time
> and writing my own Binder files, with a good bit of success.
> It's not such a big problem, as I can do it by fiddling with the
> linker and manipulating the object code. But the result is messy and
> error prone.
>
> What are the best methods you guys have come up with for doing this
> sort of manipulation?
>
> freejack
> Chris

Add a C-call compliant shim layer to your existing lib code.  Writing
this in C + embedded assembly is a good idea of possible.  Compile and
link to make C-callable static or dynamic libs.  In Ada, Import and
link the shims just as any C function.




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

* Re: Linking Ada with large Assembler libs?
  2007-02-21 21:29 Linking Ada with large Assembler libs? freejack
  2007-02-25 22:47 ` Gene
@ 2007-03-08  8:58 ` Rolf
  1 sibling, 0 replies; 3+ messages in thread
From: Rolf @ 2007-03-08  8:58 UTC (permalink / raw)


On Feb 21, 10:29 pm, "freejack" <freej...@tds.net> wrote:
> The Machine Code Insertions sections of the relevant reference manuals
> have been informative.
>
> However, I'm linking my Ada code with pre-existing libs written in
> Assembler. The GNAT manuals are a little sketchy on how to do this
> properly. I'm using NASM and FASM Assembler code. Most of the
> Assembler code deals primarily with I/O. I'm using Pragma No_Run_Time
> and writing my own Binder files, with a good bit of success.
> It's not such a big problem, as I can do it by fiddling with the
> linker and manipulating the object code. But the result is messy and
> error prone.
>
> What are the best methods you guys have come up with for doing this
> sort of manipulation?

I either used inline assembly code in the body of an Ada procedure
(preferred) or pragma Import (Convention => C, ...) when programming
the AVR microprocessors.  In the latter case you have to follow
exactly gcc's parameter passing mechanism in the assembly code (e.g.
for AVR the first arg is in r24/r25, the second arg in r26/r27, etc.).

In the recent AVR-Ada releases we don't use assembly anymore;
everything is Ada now with almost identical asm code.  I'm considering
to use Asm code for bin->ascii conversions, though.

In the beginning I also used my own hand written binder file, now I
have a patch to gcc in order to generate a binder file that fits my
needs.

Have a look at pragma Linker_Options. You can use it for simple things
like including the object file for your assembler code, but also for
using special linker scripts.

HTH

    Rolf





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

end of thread, other threads:[~2007-03-08  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-21 21:29 Linking Ada with large Assembler libs? freejack
2007-02-25 22:47 ` Gene
2007-03-08  8:58 ` Rolf

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