开发者

Calling Assembly in C++

开发者 https://www.devze.com 2023-01-26 01:52 出处:网络
I wan to learn 1). How to call assembly 开发者_StackOverflow中文版code so that I can call it from C++?

I wan to learn

1). How to call assembly 开发者_StackOverflow中文版code so that I can call it from C++?

2). I want to keep all my assembly code in separate files.

I am using Linux,GCC and other GNU developer tools.

Can you please provide some good references for it?


Write C++ header files declaring the functions you want. Define those functions with assembly language in another file. build object files of the assembly language code. Then in other C++ code files, #include the header which contains the declarations of your assembly code defined functions. Call the functions as any C++ functions, link against the object file as you link with any object file.

For references, read the code of some project that uses a mix of assembly language and C/C++. Device drivers could export functions that way.

0

精彩评论

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

关注公众号