x86 Assembly

Moderators: None (Apply to moderate this forum)
Number of threads: 4556
Number of posts: 16011

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Using 'c++' in 'assembly' Posted by saeidmscs on 24 Aug 2009 at 11:38 PM
Hi every one
Is it possible to use functions and file coded by c++ in assembly?
for example,we have written a function in a 'cpp file',can we use this function in 'asm file'?
If we can,how?
Cheers
Report
Re: Using 'c++' in 'assembly' Posted by anthrax11 on 25 Aug 2009 at 5:03 AM
You can compile the c++ file and assemble the asm file into object files and then statically link them together into one executable. Or you can make a dynamically linked library of the c++ file and call it from the asm program. If they are small functions, then the first option makes more sense.
Report
Re: Using 'c++' in 'assembly' Posted by 3y3ty on 22 Sept 2009 at 6:11 PM
Give me convenience, or give me death...

I'm not sure if C++ uses the same calling convention as
C, but if your going to call modules written for a high-level
language you have to obey the language's calling convention.
Same rule applies if your assembly module is being
called by a high-level language.
For the C calling convention the functions arguments
are pushed in reverse order onto the stack.
int func(int a,int b) --->

|###b###| sp+2
|###a###| sp

End of message.
LLLLLLLLlllllaaaaabbbbbBBBBBbGGGZx
muFx |____________________________
CONSCIOUSNESS SUPPRESSION...
Report
Re: Using 'c++' in 'assembly' Posted by kazdax on 23 Sept 2009 at 4:09 PM
why does someone not show him..how its actually done..isntead of making stories about this and that..perhaps other people might need a tutorial on this ? cant you take 15 mintuea of your time to hel pthe guy ? like actually help ..not retardation
Report
Re: Using 'c++' in 'assembly' Posted by anthrax11 on 23 Sept 2009 at 10:11 PM
There was no mention of what the purpose was or what assembler or compiler is used, so it doesn't make sense to give out links to random tutorials if we don't know half the details. Some assembly languages have built-in syntax for setting the calling convention, some don't. Some compilers need specially named functions in the object files, some don't. Some development environments have specific ways to set the link dependencies in an IDE, others use the command line. If DLLs are used, then an entirely different approach would be needed.

Linking c++ to assembly is a relatively advanced thing to do, you can't expect easy solutions where one size fits all. A general question was asked, a general answer was given. If you need more information, then we'll be happy to give it. Just ask, give more details and we'll guide a person to the right path. That's how a forum works.

I hope this was a good enough explanation.
Report
Re: Using 'c++' in 'assembly' Posted by neocambell on 2 Oct 2009 at 5:21 AM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.