开发者

Mix ada with assembly

How I can mix Ada code with assembly (assembled using GAS)?

I know how to link Ada with C, but how I can link with assembly? I know that gcc generates assembly code from Ada code, and because of this, I think is possible to do开发者_JS百科 this cross-linking.


Presumably you would compile the assembly into a .o object file and give this as a parameter to your Ada compiler.


how can I work with the two codes?

If you are using GNAT on Intel x86, the Inline Assembler includes related examples.

Addendum: The -S option allows one "to examine the generated assembly code." This applies to Ada, C, C++, etc.


If you want to perform any kind of mixed-language programming with Ada, including Ada/Assember, you should probably look at your compiler's documentation on Interfacing pragmas, in particular its allowed calling conventions.

For example, Gnat provides an Assembler convention for pragma import/export.

Generally you will have to craft your assembler to act as a subprogram which uses a calling convention compatible with the "convention" used in your interfacing pragma.

Most compilers also support some kind of inline assembly, via the System.Machine_Code package. This allows you to mix small amounts of assembly language right in the same source files with your Ada.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜