Advertisement

Assembly in MSVC++

Started by May 26, 2000 04:54 PM
4 comments, last by Densun 24 years, 6 months ago
I''m interested in writing some functions out in assembly, but I don''t know how much MSVC++ supports assembly. Is it possible to compile some asm files with something like MASM (I don''t know what compilers are out there) and call the functions from functions written with C++?
I forgot one other thing to mention. I''ll be making functions that access memory, but not hardware.
Advertisement
assembly is supported in msvc++. if masm supports PE/COFF object files then they can be linked into the executable. inline assembly is also supported in msvc++.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
You can do inline assembly in MSVC with "__asm" command.

You can use MASM or TASM to compile your .asm files. Just add them as a custom build to your project.
Don't forget to make your asm functions PUBLIC and use an underscore for the asm function. Then declare the function in a C header file with __cdecl. If you use it in C++ don't forget extern "C". Here's a header example:
#ifndef __ASM_HEADER__#define __ASM_HEADER__//------------------------------------------------------#ifdef __cplusplusextern "C" {#endif//------------------------------------------------------extern long iPolygonCount;//------------------------------------------------------void __cdecl QuickSort();//------------------------------------------------------#ifdef __cplusplus}#endif//----------------------------------------------------------#endif  


(ps: have you already tried disassembling your C files. You can learn a lot from this)



Edited by - baskuenen on May 26, 2000 6:15:34 PM
Hey, if you are going to use assembly, do yourself a favor.. and try your best to use the inline assembler... using MASM, although makes large coding efforts easier, it complicates things greatly especially if you call anything from c++... (because of the stupid calling conventions... and getting them cooperate on a regular basis isn''t easy) in any case... use MASM only if you are doing a large function in asm.. use inline assembler for smaller jobs.. and you will be happier...

RanXacT
RanXact@yahoo.com
to add to ranxact''s post: keep in mind the stack frame overhead.


--
Float like a butterfly, bite like a crocodile.

--Float like a butterfly, bite like a crocodile.

This topic is closed to new replies.

Advertisement